Common Lisp style macros in Smalltalk?

Martin B. Pomije pomije at inav.net
Tue Jan 11 07:05:33 UTC 2000


"Martin B. Pomije" wrote:
> 
> Stephen Travis Pope wrote:
> >
> > "Martin B. Pomije" wrote:
> > >
> > > Has anybody on this list ever contemplated incorporating CL style macros
> > > into Smalltalk?  Or am I just stuck in Lispish thinking?
> >
> > I think the latter ("stuck in Lispish thinking"). I, too, came to
> > Smalltalk from LISP, and initially missed several features of LISP, but
> > the only one I still pine after is multiple value returns.
> >
> 
> What sort of techniques would you use in place of CL style macros?

For example:

Re: TerseMan challenge, 
Travis Griggs wrote:
(snip)
> 
> ((1.3 raisedToInteger: 2) + (2.7 raisedToInteger: 2)) < ((3.9 raisedToInteger: 2)
> + (4.3 raisedToInteger: 2))
> 
> which chews up 2344 milliseconds (20% speed boost)
> 
> Now here's a surprise for the unintiated. Integers are *NOT* always the fastest
> thing around, and it's kind of amusing sometimes. Having some previous experience,
> it dawned on me to try:
> 
> ((1.3 raisedTo: 2.0) + (2.7 raisedTo: 2.0)) < ((3.9 raisedTo: 2.0) + (4.3
> raisedTo: 2.0))
> 
> The difference is that this one uses raisedTo: aFloat, rather than
> raisedToInteger: anInteger. This only cranks away for 2281 mills (24% spped boost
> from the original).
> 
> And finally, to really crank things up, one should drop the raisedTo: altogether
> replacing with regular multiplies:
> 
> ((1.3 * 1.3) + (2.7 * 2.7)) sqrt < ((3.9 * 3.9) + (4.3 * 4.3))
> 
(snip)

If I remember correctly (and it has been a long time), if the equivalent
of raisedToInteger: were written as a CL macro, it could return an
expression with the effiency gains of the last expression and the
clarity of the first.





More information about the Squeak-dev mailing list