need clarification: will typedef, C struct initialization, etc.

Lionello Lunesu lio at lunesu.remove.com
Thu Jun 3 07:42:58 PDT 2010


On 3-6-2010 14:58, Lars T. Kyllingstad wrote:
> On Thu, 03 Jun 2010 00:02:03 +0200, Simen kjaeraas wrote:
> 
>> On Wed, 02 Jun 2010 23:12:38 +0200, Adam Ruppe
>> <destructionator at gmail.com> wrote:
>>
>>> On 6/2/10, Simen kjaeraas <simen.kjaras at gmail.com> wrote: *snip*
>>>
>>> I haven't tried your code, but it looks similar to my own code, which
>>> had this problem:
>>>
>>> alias Typedef!Int Handle;
>>> alias Typedef!Int OtherHandle;
>>>
>>> void foo(Handle h) { }
>>>
>>> OtherHandle b;
>>>
>>> foo(b); // compiles, but shouldn't. Problem is that Handle and
>>> OtherHandle are both alias of the same underlying thing, so the
>>> compiler considers them the same thing! With the old typedef, I'm
>>> pretty sure it would (correctly IMO) complain here.
>>
>> My code sidesteps that by including instantiation line and file, making
>> each instantiation unique (as long as you don't do multiple typedefs on
>> one line).
> 
> Cool trick! :)
> 
> -Lars

Cool trick indeed, but why do we need a trick for something so basic!?

A few years from now we'll wonder why compiling moderately sized D
projects takes a long time.

When you can do something, it doesn't mean that you should.

L.


More information about the Digitalmars-d mailing list