The parentheses are not strictly necessary for macros. They're just the
traditional LIspy way to do it. For instance, this is from UCBLogo's
help documentation (I copied the first screenful from a terminal
emulator):
.MACRO procname :input1 :input2 ... (special form)
.DEFMACRO procname text
A macro is a special kind of procedure whose output is evaluated
as Logo instructions in the context of the macro's caller.
.MACRO is exactly like TO except that the new procedure becomes
a macro; .DEFMACRO is exactly like DEFINE with the same exception.
Macros are useful for inventing new control structures comparable
to REPEAT, IF, and so on. Such control structures can almost, but
not quite, be duplicated by ordinary Logo procedures. For example,
here is an ordinary procedure version of REPEAT:
to my.repeat :num :instructions
if :num=0 [stop]
run :instructions
my.repeat :num-1 :instructions
end
This version works fine for most purposes, e.g.,
my.repeat 5 [print "hello]
But it doesn't work if the instructions to be carried out include
OUTPUT, STOP, or LOCAL. For example, consider this procedure:
to example
print [Guess my secret word. You get three guesses.]
repeat 3 [type "|?? | ~
if readword = "secret [pr "Right! stop]]
print [Sorry, the word was "secret"!]
end
This procedure works as written, but if MY.REPEAT is used instead
of REPEAT, it won't work because the STOP will stop MY.REPEAT
instead of stopping EXAMPLE as desired.
The solution is to make MY.REPEAT a macro. Instead of actually
carrying out the computation, a macro must return a list containing
Logo instructions. The contents of that list are evaluated as if
they appeared in place of the call to the macro. Here's a macro
version of REPEAT:
···
--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"It's just incredible that a trillion-synapse computer could actually
spend Saturday afternoon watching a football game." - Marvin Minsky