Hi Lindsay,

> I am surprised that 'prog works. Why, in this context, does it treat it's
> argument as 'data'?

Because there is no difference between code and data ;)


I think it becomes easily understandable, if you consider what 'prog' does:

   (prog (foo) (bar))

Viewed as code, it *executes* first (foo), then (bar), and returns whatever
(bar) returned.

But in fact 'prog' is nothing more than a function which *evaluates* its
arguments in the normal way (here (foo) and (bar)), and which happens to return
the value of the last argument.

So for a single-argument case (prog (foo)) you have the identity function.

   : (prog 123)
   -> 123
   : (prog (+ 3 4))
   -> 7


> Given (NIL NIL NIL ("s" "p" "a" "a" "a" "c" "e" "s" ",") ....
> 
> : (prog NIL)
> -> NIL
> 
> : (prog ("s" "p" "a" "a" "a" "c" "e" "s" ","))
> !? ("s" "p" "a" "a" "a" "c" "e" "s" ",")
> "s" -- Undefined

Here 'prog' is called with a single argument, and expects the CAR to be a
function.


> ? (prog '("s" "p" "a" "a" "a" "c" "e" "s" ","))
> -> ("s" "p" "a" "a" "a" "c" "e" "s" ",")

This is fine, as the single argument is (quote "s" "p" ...) where 'quote' is a
function.

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

Reply via email to