Hi Alex,

> In PicoLisp, as you know, 'prog' is a function.

I think we just use different terminology.  I prefer distinguishing
different flavours of "functions".  For me, the traditional definition
of "function" is a piece of code that works with already evaluated
arguments.  "Macro" would then fit somewhere between "function" and full
FEXPR.  But probably distinguishing between "function", "macro" and
"fexpr" doesn't make sense when everything happens at the same time,
i.e. run-time?

> There is no processing taking place, at any time, which would
> transform the body of 'prog' into some other form. Instead, it is
> executed directly.

That is only an implementation detail, that you decided to optimize
'prog' and write it directly in native language (because of the need for
speed and the lack of a compiler).

> There is a 'macro' (in the above sense) function in PicoLisp.
>
>    (de macro "Prg"
>       (run (fill "Prg")) )
>
> It takes an executable body (list of expressions) in "Prog", processes
> it with 'fill' (which results in a modified list), and then uses that
> result for execution (running it).

If you implemented 'macro' directly in C, you wouldn't think of it as
a macro anymore?

> To my understanding, a "macro" is a piece of code which is processed
> (by a (pre)compiler or an equivalent software), resulting in a _new_
> piece of code which is then used instead.

Conceptually, 'prog' can be easily written as a syntactic transformation
passing the result to 'run'.

   (de prog P (run P 1))

Looks pretty much the same as the 'macro' definition above.

> BTW, a good example for a "macro" in PicoLisp is the 'lazy' function
>
>    (de lazy Args
>       (def (car Args)
>          (list (cadr Args)
>             (cons 'cache (lit (cons))
>                (list 'pack (list 'char (list 'hash (caadr Args))) (caadr 
> Args))
>                (cddr Args) ) ) ) )
>
> from http://rosettacode.org/wiki/Formal_power_series

Nice:-D

Cheers,

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

Reply via email to