syntax for apply

Q&A's, tips, howto's

syntax for apply

Postby ghyll » Thu Oct 30, 2014 5:26 am

This code (shown below) from the "Namespace context switching" section of "Expression Evaluation in newLISP" does not seem to follow the syntax given in the manual: (apply func list [int-reduce]).

Code: Select all
(context 'Foo)
(set 'var 123)
(define (func)
    (println "current context: " (context))
    (println "var: " var))
(context 'MAIN)

...

(apply 'Foo:func)

prints:
current context: Foo
var: 123


Is there an unlisted second syntax for apply? If not, can someone help me to understand how the above example fits (apply func list [int-reduce]) (e.g. is the second parameter also optional)?

Thanks!
ghyll
 
Posts: 14
Joined: Mon Jul 14, 2014 1:15 am

Re: syntax for apply

Postby Lutz » Thu Oct 30, 2014 9:04 am

Yes, apply with only a function or primitive is a valid syntax when the function or primitive can be used without arguments. Added now to the manual:
http://www.newlisp.org/downloads/newlis ... html#apply
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: syntax for apply

Postby ghyll » Mon Dec 22, 2014 1:32 am

That makes perfect sense. Thank you for the reply (and apologies for the delayed response on my part).
ghyll
 
Posts: 14
Joined: Mon Jul 14, 2014 1:15 am


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron