Library Typedefs are fundamentally broken
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 22 11:44:54 PDT 2014
On Monday, 22 September 2014 at 17:21:50 UTC, Andrei Alexandrescu
wrote:
> I find the requirement for the cookie perfect.
There is one thing I like about it and wish was available
elsewhere: two modules can define the same type for
interoperability without needing to import each other.
My simpledisplay.d and image.d modules both used to be
standalone. Both defined struct Color {}. Identical layout. When
I added optional integration, these two structs clashed.
The solution was to introduce module color, which held that
struct. But now both modules require that import. Works fine but
I think it would have been great if I could have kept the two
separate definitions and just told the compiler it's ok, these
two types are indeed identically compatible despite coming from
independent modules.
kinda like pragma(mangle) but for types and preferably less hacky.
Another potential use of this concept would be separate interface
and implementation files.
But that's all pretty different than the Typedef cookie. I'm just
saying it because the concept of matching types in different
modules IS something that I've wanted in the past.
More information about the Digitalmars-d
mailing list