Generic const - a non-functional view

Jason House jason.james.house at gmail.com
Wed Jun 25 08:55:10 PDT 2008


Steven Schveighoffer Wrote:

> "Jason House" wrote
> > A lot of times, when I think about tail const/mixed const/mutable/..., I
> > start thinking about arrays.
> > AKA:
> >  T[] vs. array!(T)
> >  const(T)[] vs. array!(const(T)) vs. const!(element)(array!(T))

I probably should have stated that arrays have special status in D.  As built in containers, they have support for for tail const while other objects don't have that luxury.  I implicitly measure the quality of a const proposal by how it can implement an alternate to arrays without the syntactic sugar arrays provide.


> or const!(element)(T)[]
> 
> or
> 
> alias const!(element) eleconst;
> 
> eleconst(T)[]

What's the difference between const!(element)(T)[] and const(T)[]?  I believe this is more a misunderstanding of what I was driving at.  Consider this template:

class array(T){
  typedef element T elem;
  elem contents[];
}

Maybe I got the syntax wrong, but the basic idea is that T and element are really the same kind of thing.  array!(const T) and const!(element)(array!(T)) are different types.  Should they be?  I don't think so.  There's still something buried in a tail const scheme that still needs to get fleshed out, somehow...



More information about the Digitalmars-d mailing list