Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Tim Johnson

#16
I use this function

(define (merge)(transpose (args)))

Lutz is a man of few words ...
#17
Quote from: "Lutz"- bug fixes and additional syntax patterns for 'net-connect' and 'net-service'



for CHANGES notes and source package see here:



http://www.newlisp.org/downloads/development/">http://www.newlisp.org/downloads/development/



this is is a source-only release

Not to quibble, but it is v.10.2.4 at the link above.

Another successful compile and install on slack 13.0 32-bit

using configure-alt

--

tj
#18
Of the two other members of my family that are programmers, they are

both java programmers. One of them full-time, the other splits her time

about 60-40 between java and php.



I don't like java, and it is as verbose as C, which I used for 12 years, even for CGI programming.

I would hate to have to learn java. I see a trend toward scripting languages written in

java. It is that trend that interests me, not java itself.



See http://java-source.net/open-source/scripting-languages">http://java-source.net/open-source/scripting-languages, as an example. Jython and clojure are both very active communities.

I also belong to the jython mailing list (I am a python programmer). I have seen references in the jython ML to Javascript as

the "cobol of the 21st century" I would suggest that it may become another C of the 21st century.



And FYI :) I'm not going to be  coding in java the next few days, I'm going to be coding in newlisp.

Any job postings for newlisp programmers? Send them my way if you see any.

cheers
#19
Quote from: "Lutz"No sure what you mean. In the following smaller example you can see 'outer-var' recognized:

Note that I placed the define for 'typeHander inside of the context.

I moved the define outside of the context and now the hash functions have context scope. I.E. It appears

that the context members are now visible to the type handler functions.

Thanks for the example. That showed me what to do.



cheers

tim
#20
I have a solution, but don't fully understand the issue:

I've set up a typehandler/callback using a hash with functions as in

(define typeHandler:typeHandler)
(typeHandler "text"
    (fn (fl val ndxs DS DSndx)
        (letn((ndx (ndxs 0))(ele (fl ndx))
                (attrs(set-attr (list "value" val)(ele 2 1))))
         (setf (DS DSndx ndx 2 1) attrs)
         DS)))

Even though the code above is lexically within a context, the functions defined as members of

the hash do not recognize members of the outer context.

To elaborate, I have to pass the context member DS as the fourth argument to the

(typeHandler "test") lambda and the context member current-DS-index (DSndx)

as the fifth argument.

I can live with that, but I'd welcome comments or whether or not I may be missing

something.

thanks

tim
#21
I think that your method will make modification easier also.

Thanks very much Lutz.

I hadn't even considered hashes.
#22
And one more step, factoring out 'list calls by using eval in the dispatcher:
(set 'callback-list
'(("int" (fn(arg1 arg2)
                      (println "heellllooo from the 'int handler")
                      (println arg1 " " arg2)))
          ("text" (fn(arg1 arg2)
                        (println "heellllooo from the 'text handler")
                         (println arg1 " " arg2)))))
(define (dispatcher key params)
(apply (eval(lookup key callback-list)) params))
(dispatcher "int" '("one" "two"))
(dispatcher "text" '("three" "four")

Results:

heellllooo from the 'int handler
one two
heellllooo from the 'text handler
three four

Next step: Compose an anonymous function and either replace or add to

the callback list.

Cheers

tim
#23
Quote from: "cormullion"I suspect that part of the silence is to do with the fact that topics in this forum don't appear in the RSS feed or the Active topics list.

I only noticed it because I happened to look at the  Dragonfly section after seeing a tweet...

Why is that?

Is there something in my settings configuration that I can change?

thanks
#24
Hey, I like your approach. And taking it one step further using 'fn:

(set 'funcs
   (list
      (list "int" (fn(arg1 arg2)(println "DO-INT - arg1: " arg1 " arg2: " arg2)))
      (list "text" (fn(arg1 arg2)(println "DO-TEXT - arg1: " arg1 " arg2: " arg2)))))
(define (f key) (lookup key funcs))
((f "text") "one" "two")

Elegant indeed.

Thank you

tim
#25
In python I'm used to doing something like this:

funcs = {"one":func1,"two":func2} ## etc
## Called as:
funcs[task](arg1 arg2)

I did this in newlisp:

(set 'funcs '(("int" do-int)("text" do-text)))
(define (do-int arg1 arg2)
(println "DO-INT - arg1: " arg1 " arg2: " arg2) )
(define (do-text arg1 arg2)
(println "DO-TEXT - arg1: " arg1 " arg2: " arg2))
## Function call:
(set 'arglst '("one" "two"))
(apply (lookup "text" funcs) arglst)
## => DO-TEXT - arg1: one arg2: two

If anyone thinks there is a better and more idiomatic way to do this, I would welcome comments.

thanks

tim
#26
Frankly, I'm surprised that there isn't more interest in this topic. But I think that the simplicity

and practicality of newlisp just might attract a different "crowd" than what would be attracted

to java. But, hey I gotta eat and there's a market for java resources.



After looking thru the code in guiserver.lsp, I can see that what Lutz has done is similar to what

my business partner and I talked about doing years ago. That is:



Write a gui server in python or perl using the TCL/TK (as an example) libraries available for both

perl and python and implement it by talking to it on a dedicated port from either rebol or

perl scripts.



:) Great minds run in the same gutter.

cheers
#27
I agree with you on all of this.

I have no interest in a newlisp written in java. None.

However

The newlisp guiserver component is what interests me.

Let me rephrase what I said earlier:



1)There is a "java library". It is a file called guiserver.jar

2)There is a "newlisp interface". It is a file called guiserver.lsp

3)Following this paradigm, what other possibilities can use 1) and 2) as guides.



Here's a real-world example.

I'm a web programmer. To deploy newlisp for my business, I need a newlisp module

that will render an html form with embedded mysql data from a record and customized javascript data validation.

I've done this functionality in rebol and python, and I need to implement it in newlisp.

I've written some code, I can make it work in newlisp, but suppose there is a java

.jar file that does it already and can I write a newlisp interface to that (hypothetical)

jar that get it done without re-inventing the wheel a second time.



Here's another example: My business partner and my brother both have blackberries.

Blackberries have a java interface. ( at least I think they do and this is just an example, okay?)

I want to write an application that keeps them in touch 24/7.

(In the real world not a good idea, because one is a republican and the other is a democrat, but

bear with me here).

Javas assets (jar files) exist to accomplish this. I use newlisp as the glue to bind

it all together. After all, I know newlisp, I don't know java, newlisp is less verbose and

more "fun" to use.



So how am I doing? Am I any clearer?

Cheers

tim
#28
I do not currently code in java, but I can see it on the horizon. There is a growing list of scripting languages that are front

ends for java and are in part or in whole in java. See http://java-source.net/open-source/scripting-languages">http://java-source.net/open-source/scripting-languages



I've looked at clojure for the last couple of days, but I'm going to have to pass.

Reason: lots of problems installing. I believe I could overcome those issues myself, but  the thought

of trying to convince a system adminstrator to install it on a remote server for web deployment made me

want to weep!



I think it is likely there is going to be a very large niche for a scripting languages that can "talk to" or be

a "front end" for java. And I don't think it is filled yet.



Now, with the guiserver, I see some possibilities: I haven't really played with any of the sample scripts

(on my machine at usr/local/share/newlisp/guiserver). I've looked at guiserver.lsp and it is very thoroughly

documented. And as I understand it, guiserver.lsp is a "front end" for guiserver.jar.

So the possibilities of using newlisp as general-purpose front end for java would entail

1)Jar files being built on java

2)A newlisp interface designed specifically for the jar file?

Am I correct?

I'd welcome any and all comments on this topic.

thanks

tim
#29
Understood.

Thanks

tim
#30
OK. Let me take another crack at this: I will use examples that are not tested code but are meant to be illustrative:

I have a list, let's call it 'parent-list. It is composed of lists, and we will call them 'member-list(s). They can be

accessed by 'assoc
(set 'member-list (assoc key parent-list))
;; all sorts of code including possible changes to 'member-list
----
----
(setf (assoc key parent-list) member-list)  ;; we had to call 'assoc a second time. Redundant?

Suppose we had a $found system variable

(set 'member-list (assoc key parent-list)
      'found $found)
;; all sorts of code including possible changes to 'member-list
----
----
(setf (parent-list found) member-list)  ;; I'm assuming the Implicit indexing is more efficient

With the function I wrote, I could do something like this:
(letn ((found getAssocPos(key lst)) (member-list (lst found))
 (when found
  ;; all sorts of code including possible changes to 'member-list
----
----
  )
(setf (parent-list found) member-list) ;; implicit indexing  
) ;; end letn

That's all for today.

G'night

tim