Page 1 of 1

syntax for apply

Posted: Thu Oct 30, 2014 5:26 am
by ghyll
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!

Re: syntax for apply

Posted: Thu Oct 30, 2014 9:04 am
by Lutz
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

Re: syntax for apply

Posted: Mon Dec 22, 2014 1:32 am
by ghyll
That makes perfect sense. Thank you for the reply (and apologies for the delayed response on my part).