using a typedefed variable with library classes

bearophile bearophileHUGS at lycos.com
Sun Jan 11 03:45:20 PST 2009


Bill Baxter:

> The first time I tried to use it my thought was to do
>   typedef Exception MyException;
> To create a different exception type.  That doesn't work so I kinda
> just said, eh whatever, this typedef stuff doesn't work yet.

You are right, typedef was invented before classes and OOP, so what you say doesn't work :-)
But I think typedef may be modified to work as you want too, that is to define a subtype (so the runtime typeinfo of MyException too has to be different!). I/we can ask Walter what he thinks about this.


> Now I can't accidentally assign a vertex handle to a face handle.
> That could be useful.

Right. But so far I don't see problems in extending the semantics of typedef to work with OOP too. Maybe other people here can spot a problem. I presume Walter doesn't read this newsgroup, so I can post a summary in the main D group too, later.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list