[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
"delete" and the Smalltalk translator
- To: <michael@xxxxxxxxxxx>
- Subject: "delete" and the Smalltalk translator
- From: Mark S. Miller <vlad!mark>
- Date: Sun, 24 Jun 90 12:29:09 PDT
- Cc: <xtech@xxxxxxxxxxx>
- In-reply-to: <Michael>,42 PDT <9006210420.AA12772@xanadu>
Date: Wed, 20 Jun 90 21:20:42 PDT
From: xanadu!michael (Michael McClary)
...
Let's make it a LITTLE different:
(expr) destroy => DESTROY (expr)
and include the macro:
#define DESTROY(expr) \
{ \
Heaper * tmp = (expr); \
delete tmp; \
}
in tofux.hxx. ...
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;
}
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.
[Also by the way: I strongly prefer "func(...)" to "func (...)".]
My convention is to use "func (...)", and "MACRO(...)". To each his
own.