struct mixins

div0 div0 at users.sourceforge.net
Tue Nov 17 11:02:01 PST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bill Baxter wrote:
> On Mon, Nov 16, 2009 at 11:32 AM, div0 <div0 at users.sourceforge.net> wrote:

<snip>

>>>
>> vote++
>>
>> I was going to suggest it when I finished my spirit port, but I was
>> too lazy to in the end.
>>
>> It would be very handy as currently the only way support multiple
>> policies is to use member vars which are basically pointers to empty
>> classes, so it looks rather more ugly than it needs to be.
>>
>> Mixin should really go hog wild I think and let you mixin anything anywhere.
> 
> 
> I have wanted this kind of thing before too.   I can't recall the
> exact reason, but it had something to do with traits structs.  I hit
> it when I was porting OpenMesh to D.
> 
> There's some base set of traits provided by the library as a struct
> that you may want to add too in user code.
> 
> But I think "alias this" would probably serve that need just fine.
> What use cases are served by the mixin that 'alias this' does not?
> It looks like this was an attempt to explain, but I don't understand:
> "See how a struct mixin could add an implicit/explicit cast to the
> mixed in structs."
> 
> I guess mixin struct could allow a kind of static multiple
> inheritance.  But if that's desirable, then probably alias this should
> just be extended to enable that.  Seems like the two are so similar
> that whatever alias this lacks in features could just be added rather
> than introducing a new construct.
> 
> --bb

Well at the moment you only get one alias this. I suppose you could
allow multiple alias this, but then what happens with multiple symbols
with the same name? At least with mixins you can disambiguate.

Still using member vars worked for me; there's more important stuff to
be doing at the moment.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLAvMpT9LetA9XoXwRAuIZAKCyRCfzrXGEPJeH7n1zC/UcrHvsKACdFX8F
qp4lpEqHtf0ruF0XSHVQUXM=
=2zvO
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list