3 ms·
(setq foo (1 2 3)) So how does evaluation work here? Why isn't (1 2 3) evaluated? Or is it not evaluated because 1 is not a function? In which case, is it not
by Grue3 10y ago
(setq foo (1 2 3))
So how does evaluation work here? Why isn't (1 2 3) evaluated? Or is it not evaluated because 1 is not a function? In which case, is it not possible to create a literal list where the first element is a function?
- marklgr 10y agosetq is called a 'special form', which does not evaluate its args as other s-expr would.
- masklinn 10y agosetq would in fact evaluate its second argument (and bind it to the name specified by the 1st). Picolisp has a special rule for (literal) lists starting with a (literal) number, they're implicitly quoted instead of the CAR being interpreted as a function: > if the CAR of the list is a number, the whole list is returned as it is This makes more sense considering a second quirk of Picolisp: numbers can be used as functions, in which case they're interpreted as a pointer to the executable code to run. And from what I understand Picolisp's execution model doesn't have special forms as such, rather function definition specifies whether they receive their arguments evaluated or not.
- qwertyuiop924 10y agoIt also has macros now, but they're rarely used.
- provemewrong 10y agoI think I found the explanation in the PicoLisp reference [1]. > [...] as a special case - if the CAR of the list is a number, the whole list is returned as it is [...] This is not really a function call but just a convenience to avoid having to quote simple data lists. [1]: http://folk.uio.no/jkleiser/pico/doc/ref.html#ev http://folk.uio.no/jkleiser/pico/doc/ref.html#ev