[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Re: "delete" and the Smalltalk translator

> I started coding this, and noticed that the above macro is a classic
> example of one that can and should be replaced by an inline.  I've
> just checked, and the following inline when used generates essentially
> the same cfront output as a direct delete.  
> 	inline void destroy (Heaper * tmp)
> 	{
> 	    delete tmp;
> 	}

Goodie.  Nice catch, too.  (Eliminates name collisions with "tmp" or
whatever gets chosen for the local variable.  Also scopes correctly,
rather than polluting the global name space with a new macro name.)

> It is interesting that cfront has such problems with:
> 	SPTR(X) p;
> 	delete p;
> But no problems generating fine code for:
> 	destroy (p);


>    (Hmmm...  If we didn't capitalize "destroy", does the translator still
>     need a special case?)
> Well, if we make it an inline member function of Heaper, then no
> special case is needed at all!  "(expr) destroy" simply becomes
> "(expr)->destroy()".  I'll try this.  I think it's curious how little
> our intuitions have even now been acclimated to the power of inlining. 

I thought inlines were broken this week.  B-)  Also, I'm an agnostic on
the inline/macro issue, and haven't been looking around for macros to
convert.  The name-scoping issue might have just converted me.


>    [Also by the way:  I strongly prefer "func(...)" to "func (...)".]
> My convention is to use "func (...)", and "MACRO(...)".  To each his
> own. 

I guess I wasn't clear.  Had I said "I prefer..." I'd have meant "...but
of course it's all a matter of taste."  I said "I strongly prefer..." which
means I have a reason for it (and in this case consider doing it the other
way to be almost as bad as not using indentation), intend to propose it as
a standard unless somebody comes up with an even better reason not to do it
that way, am contemplating writing a tool to reformat all our source, and
may stand on a soapbox at the next major convention and try to get all the
other programmers to do it that way, too.  I'm not QUITE ready to write a
networm to go reformat all the source in the world...  B-)

I threw it in as an aside because I didn't feel like starting a holy war
in the middle of the letter on the other subject, or before I'd sharpened
my sword and oiled my armor.