At 09:36 PM 5/9/2001 -0400, Benjamin Sugars wrote:
>On Wed, 9 May 2001, Dan Sugalski wrote:
>
> > At 09:33 AM 5/9/2001 -0700, Larry Wall wrote:
> >
> > >I think that's silly.  You misuse a variable that requires an auto, the
> > >compile dies, that's all.  And macros can be very useful for an 
> abstraction
> > >layer that intended to *hide* the implementation.  Hoisting implementation
> > >details into the name defeats that abstraction.
> >
> > I really, *really* don't want to hide very much of the implementation
> > details at the C code level. We do that right now, and it makes for a
> > twisty maze of macros, all alike. And the resulting C code bears very
> > little resemblance to what's actually written. (I've seen size 
> increases of
> > two orders of magnitude--20 characters of source text become 2K or more
> > after macro expansion)
>
>But isn't that the whole point of macros?  Who wants to see the same 2K of
>code at the top of every function?

No, that's not the point of macros. When you find you have 5, or 10, or 20 
levels of substitution, it means you have a real problem somewhere. Macros 
should be simple. Fancy macros, or lots of little nested macros, show a 
lack of thought about the long term. It also contributes really badly to 
comprehending the code, and it gets in the way of stepping through 
intelligibly with a source-level debugger.

More importantly, if you have the same 2K of code at the top of every 
function (or in this case, scattered throughout a bunch of different 
functions) it means you really, *really* ought to be yanking it out into a 
separate function. Perl's main program is rather bigger than it probably 
ought to be because of this. (And yes, compilers can do some better 
optimization because of it, and can abstract things out automagically to 
some extent, but there's nothing to be gained from polluting the I cache 
with what's essentially eight or ten copies of the same code)

It's one of the signs of perl 5's core decay. I don't think it was nearly 
this bad when it started.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to