syntax for apply

Started by ghyll, October 29, 2014, 10:26:21 PM

Previous topic - Next topic

ghyll

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



(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!

Lutz

#1
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/newlisp_manual.html#apply">http://www.newlisp.org/downloads/newlis ... html#apply">http://www.newlisp.org/downloads/newlisp_manual.html#apply

ghyll

#2
That makes perfect sense. Thank you for the reply (and apologies for the delayed response on my part).