Bill Atkins wrote:

> But why should I have to worry about any of this?  Why can't I do:
>
>   (with-indentation (pdf (+ (indentation pdf) 4))
>      (out-header)
>      (out-facts))
>
> and then within, say out-facts:
>
>   (with-indentation (pdf (+ (indentation pdf) 4))
>     (write pdf "some text"))
>
> More readable, and no bookkeeping to worry about.  This is great!  And
> here's the macro:
. [...]

Can you explain to a non-Lisper why macros are needed for this ?  I'm a
Smalltalker, and Smalltalk has no macros, nor anything like 'em, but the
equivalent of the above in Smalltalk is perfectly feasible, and does not
require a separate layer of semantics (which is how I think of true macros).

    aPdf
        withAdditionalIndent: 4
        do: [ aPdf writeHeader; writeFacts ].

and

    aPdf
        withAdditionalIndent: 4
        do: [ aPdf write: '... some text...' ].

Readers unfamiliar with Smalltalk may not find this any easier to read that
your Lisp code, but I can assure them that to any Smalltalker that code would
be both completely idiomatic and completely transparent.  (Although I think a
fair number of Smalltalkers would choose to use a slightly different way of
expressing this -- which I've avoided here only in order to keep things
simple).


> Macros rock.

I have yet to be persuaded of this ;-)

    -- chris


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to