syntax for apply

Q&A's, tips, howto's
Locked
ghyll
Posts: 14
Joined: Mon Jul 14, 2014 1:15 am

syntax for apply

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

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: syntax for apply

Post 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

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

Re: syntax for apply

Post by ghyll »

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

Locked