Is alias equality inconsistent?

Jonathan M Davis jmdavisProg at gmx.com
Fri May 13 17:10:36 PDT 2011


> > On 5/13/11 5:00 PM, Timon Gehr wrote:
> >> Fixed-size arrays are somewhat special, there 'is' actually compares ptr
> >> and length. I think that is very practical and makes sense because it
> >> allows meaningful 'is' between fixed- and dynamic-size arrays. I guess
> >> for value types it is there for completeness and maybe to enable easier
> >> generic programming. We do not lose anything by having it.
> > 
> > I think 'is' for static arrays could go either way. If they're to be
> > seen as an equivalent of structs, is should yield true. If they're to be
> > seen as a close relative of dynamic arrays, is should yield false.
> > 
> > Probably it would be best to disable it :o).
> > 
> > 
> > Andrei
> 
> I think determining the return value should rely on other things than the
> ref-ness of the arguments. Maybe you want to clarify.
> 
> When you are disabling stuff, also disable templates and all builtin types.
> Using the mixin/asm statements they can be implemented entirely in library
> code.
> 
> I will then start patching my compiler. I am serious about that one. =)
> 
> When did it stop being useful? I thought D should be a practical language
> that gets you stuff done, not a religion.
> 
> Now it seems to me that you want to disable 'is' for static arrays just
> because there would be another (less useful) way to define it?
> 
> Or is the ':o)' an indication that you were just joking? It would be a
> relief.

The only value of is and static arrays that I can think of is if you can use 
them to verify whether a dynamic array refers to a particular static array. 
Other than that, what value do they add? If you're checking for equality, then 
use ==. That one use case may make it useful to allow for is in comparing 
static and dynamic arrays, but other than that, I don't really see what is 
gives you when comparing static arrays.

- Jonathan M Davis


More information about the Digitalmars-d mailing list