From: Jonathon McKitrick
Subject: Norvig comment on macros
Date: 
Message-ID: <1154762040.909310.85220@i3g2000cwc.googlegroups.com>
I found this intriguing:

"Use macros freely to represent your /problem/, but shy away from new
macros in the implementation of your /solution/, unless absolutely
necessary." - p. 855

I've heard it said most macros should fall into the def-foo and
with-foo variety.  Frankly, I haven't seen the need to use them alot in
my field.

What do you guys think?

From: Bill Atkins
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <1154787455.141537.5290@b28g2000cwb.googlegroups.com>
Jonathon McKitrick wrote:
> I found this intriguing:
>
> "Use macros freely to represent your /problem/, but shy away from new
> macros in the implementation of your /solution/, unless absolutely
> necessary." - p. 855
>
> I've heard it said most macros should fall into the def-foo and
> with-foo variety.  Frankly, I haven't seen the need to use them alot in
> my field.
>
> What do you guys think?

What do we think about what?  Are we talking about macros in general,
or macros of "the def-foo and with-foo variety"?
From: Jonathon McKitrick
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <1154801662.106563.89050@i3g2000cwc.googlegroups.com>
Bill Atkins wrote:
> Jonathon McKitrick wrote:
> > I found this intriguing:
> >
> > "Use macros freely to represent your /problem/, but shy away from new
> > macros in the implementation of your /solution/, unless absolutely
> > necessary." - p. 855
> >
> > I've heard it said most macros should fall into the def-foo and
> > with-foo variety.  Frankly, I haven't seen the need to use them alot in
> > my field.
> >
> > What do you guys think?
>
> What do we think about what?  Are we talking about macros in general,
> or macros of "the def-foo and with-foo variety"?

Mostly the comment by Norvig suggesting macros as part of the problem
definition rather than the solution, which combined with the second
comment, would seem to suggest less use of macros.
From: Larry Clapp
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <slrned9uu9.2v2.larry@theclapp.ddts.net>
On 2006-08-05, Jonathon McKitrick <···········@bigfoot.com> wrote:
> I found this intriguing:
>
> "Use macros freely to represent your /problem/, but shy away from
> new macros in the implementation of your /solution/, unless
> absolutely necessary." - p. 855
>
> I've heard it said most macros should fall into the def-foo and
> with-foo variety.  Frankly, I haven't seen the need to use them alot
> in my field.
>
> What do you guys think?

"What's the limiting factor on the size of pocket calculators?"
"Um, the size of pockets?"

I think it depends on how you define "absolutely necessary".  I try to
follow the rule of "once, twice, automate."  (Some take this further
to "once, automate". :)  If you find yourself writing the same kind of
code several times (an "idiom" or "design pattern"), and you believe
that the cognitive load to understand/use/modify code in this "idiom"
will greatly exceed the cognitive load to understand/use/modify code
that uses a macro that abstracts out the common structure of the
idiom, then you should write the macro.

As an example, DO, COND, and CASE are all macros.  If CL didn't have
them, would you feel comfortable adding them in the implementation of
your /solution/?

-- Larry
From: Jonathon McKitrick
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <1154813051.323914.276160@h48g2000cwc.googlegroups.com>
Larry Clapp wrote:
> follow the rule of "once, twice, automate."  (Some take this further

I keep finding that functions solve the problem for me without needing
macros.  Maybe that's because I'm not 'meta-programming'.
From: Ken Tilton
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <O88Bg.443$qy1.340@fe11.lga>
Jonathon McKitrick wrote:
> Larry Clapp wrote:
> 
>>follow the rule of "once, twice, automate."  (Some take this further
> 
> 
> I keep finding that functions solve the problem for me without needing
> macros.  Maybe that's because I'm not 'meta-programming'.

Correct. I used macros in C. And COBOL.

kenny

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Christopher Browne
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <87psfewq2l.fsf@wolfe.cbbrowne.com>
Centuries ago, Nostradamus foresaw when "Jonathon McKitrick" <···········@bigfoot.com> would write:
> Larry Clapp wrote:
>> follow the rule of "once, twice, automate."  (Some take this further
>
> I keep finding that functions solve the problem for me without needing
> macros.  Maybe that's because I'm not 'meta-programming'.

When functions suffice, it is probably a mistake to adopt macros.

It seems to me there's room for both some "remapping the problem" and
"remapping the solution", but I doubt there will be much certainty as
to how much is (not enough|too much).
-- 
let name="cbbrowne" and tld="gmail.com" in String.concat ·@" [name;tld];;
http://linuxdatabases.info/info/slony.html
Rules of the Evil Overlord #85. "I  will not use any plan in which the
final step is horribly complicated, e.g. "Align the 12 Stones of Power
on the sacred altar then activate the medallion at the moment of total
eclipse."  Instead  it will  be  more along  the  lines  of "Push  the
button." <http://www.eviloverlord.com/>
From: Larry Clapp
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <slrnedacmf.2v2.larry@theclapp.ddts.net>
On 2006-08-05, Jonathon McKitrick <···········@bigfoot.com> wrote:
> Larry Clapp wrote:
>> follow the rule of "once, twice, automate."  (Some take this
>> further

I meant using functions, just by the way, but meant to imply that you
can use macros to follow a (perhaps less rigorous rule ("once, twice,
thrice, ... ninth, automate"?)) with code structure (i.e.  syntax),
the same way that you use functions to follow this rule with
functionality.

> I keep finding that functions solve the problem for me without
> needing macros.  Maybe that's because I'm not 'meta-programming'.

Well certainly you can just write (what would be) the macro expansion
yourself, time after time, and so strictly speaking you could
certainly argue that you don't /need/ macros.  I think eschewing them
on the grounds that Peter Norvig says "don't use them", without
thinking about why he says that, and if you agree with him, and if
those reasons apply to your project, would limit you for no reason.

But hey, wth, you're not me.  Do what you want.  :)

-- Larry
From: Ken Tilton
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <xl7Bg.2552$uw5.2303@fe08.lga>
> On 2006-08-05, Jonathon McKitrick <···········@bigfoot.com> wrote:
> 
>>I found this intriguing:
>>
>>"Use macros freely to represent your /problem/, but shy away from
>>new macros in the implementation of your /solution/, unless
>>absolutely necessary." - p. 855

You are quoting a guy who dumped Lisp for Python? On macros?!

hth, kenny

-- 
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon
From: Jonathon McKitrick
Subject: Re: Norvig comment on macros
Date: 
Message-ID: <1154812753.510770.180090@b28g2000cwb.googlegroups.com>
Ken Tilton wrote:
> You are quoting a guy who dumped Lisp for Python? On macros?!
>
> hth, kenny

I was specifically thinking of you and your 600+ (or was it 300+?)
macros in CliniSys.  I knew you'd toss your 0.02 into this thread.  ;-)