Transience of .front in input vs. forward ranges

Tommi tommitissari at hotmail.com
Mon Nov 12 21:15:50 PST 2012


On Monday, 12 November 2012 at 08:37:20 UTC, Tommi wrote:
> This whole mess makes me wish that D was designed so that all 
> types had value semantics (by convention, since it's probably 
> not possible to enforce by the language).

"..so that all types had value semantics". That's a bit too 
harsh. Rather there would need to two kinds of types:

1) struct:  own their data, value semantics
2) referer: don't own their data, reference semantics

Dynamic arrays would fall into the first category; owns their 
data, have value semantics.

Slices of dynamic arrays would be a separate type, falling into 
the second category; don't own the data, reference semantics.

Range could be of either kind of type.

You'd need two kinds of pointers too: the kind that owns its 
data, and the kind that references data that someone else owns.

And you'd be able to differentiate between these two kinds of 
types at compile-time.

Disclaimer: I promise not to spam this thread with this idea any 
further.


More information about the Digitalmars-d mailing list