Uh... destructors?

Kevin Bealer kevindangerbealer at removedanger.gmail.com
Wed Feb 23 20:05:39 PST 2011


== Quote from Stewart Gordon (smjg_1998 at yahoo.com)'s article
> On 23/02/2011 18:07, Ary Manzana wrote:
> > On 2/22/11 10:36 AM, Simen Kjaeraas wrote:
> >> %u Wrote:
> >>> Well, the trouble is, pretty much all of these are invalid attributes:
> >>
> >>> - static obviously makes no sense
> >>
> >> And here is where you're wrong. You have defined a static destructor, which
is called
> >> with module destructor as the program goes out of scope, rather than when
your struct or
> >> class is destroyed.
> >
> > This is why attributes that make no sense must be an error: you don't know if
an attribute
> > you put is being ignored by the compiler or not (like what has just happened
here).
> Uh, that's a total non sequitur.  The point Simen is making is that static
_does_ make
> sense here.
> Stewart.

But if the compiler always rejected the nonsensical ones it would be clear that
the ones that
are not rejected have some meaning.  The ambiguity he is talking about (I think)
is between
the two ideas "the compiler accepted this but its meaningless" and "the compiler
accepted this
so it *must* be meaningful".  If you can't be sure the second is true, then you
don't realize
there is a bug, e.g. if you did not intend the destructor to be a class/module
destructor.

Kevin


More information about the Digitalmars-d mailing list