Hi Tomas,

> 'run' is more general and evaluating version, i.e. it's a function
> suitable for manipulating programs (aka eval) with other bell and
> whistles like "environment control".  'prog' is a "macro", i.e. a
> convenience shortcut for writing text of a program by hand.  You can
> build the macro version on to of the evaluating version.

Thanks for the explanation!

I would not use the term "macro" in this case, however. You had also
used it, btw, in a similar context in a previous mail.

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.

The first macro I encountered was the pre-defined REPT macro in some
assemblers (terminated by ENDM for "end macro"). Writing

   rept 4
      sal ax,1
      rcl si,1

is the same as writing

      sal ax,1
      rcl si,1
      sal ax,1
      rcl si,1
      sal ax,1
      rcl si,1
      sal ax,1
      rcl si,1

In C, a macro like

   #define Push(c,x)       (data(c)=(x), Save(c))

when called as

   Push(c1, foo(*p++) + bar(mumble()));

expands to

   data(c1)=(foo(*p++) + bar(mumble())),

This is what the C compiler sees and compiles.

I understand what you mean. In Common Lisp, you would need to write a
macro to implement 'prog'.

In PicoLisp, as you know, 'prog' is a function. 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.

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).

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

Reply via email to