Hi all,

while talking about 'set' and 'setq', let me clarify another issue. Quite often
I see here - or in IRC - expressions like

   (mapc 'set '(A B C) (1 2 3))


   (mapcar 'inc (4 5 6))

While this certainly works, it is actually wrong, or at least unnecessary.

The mapping functions want a *functional* first argument. If you look up in the
reference (under "Evaluation", doc/ref.html#ev), it says that a function is
either a number (a function pointer) or a cell (with parameter(s) in the CAR and
a 'prg' body in the CDR).

However, the above expressions pass a *symbol* to the mapping functions. So just

   (mapc set '(A B C) (1 2 3))
   (mapcar inc (4 5 6))

would be fine, because the first arguments are evaluated, resulting in proper

The quoted calls (resulting in symbols) happen to work just due to a lucky

When PicoLisp evaluates a function call, it tries to be tolerant. Instead of
throwing an error when hitting a symbol, it *evaluates* that symbol (or any
expressions in general which show up, until it gets to a proper function. For

   (de square (N)
      (* N N) )

      F 'square )
      L '(line square circle) )

   : (F 7)
   -> 49

   : ((cadr L) 7)
   -> 49

   : ((val (cadr L)) 7)
   -> 49

One more note: In case of *message* calls on objects you *must* pass a symbol.
They need a symbol to locate the right method in the class hierarchy

   (mapc 'lose> (collect 'key '+Cls))

so here the quote is correct.

- Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to