auto ref

bearophile bearophileHUGS at lycos.com
Thu Dec 17 11:41:34 PST 2009


dsimcha:

>The only solution I see would be to completely get rid of separate compilation.<

"All problems in computer science can be solved by another level of indirection;"
-- David Wheeler
But that also slows code down a little :-)

--------------------

Bill Baxter:

Static interfaces are an easy idea, it was discussed some weeks ago, and probably it's not too much hard to implement in the language. I like them enough, but they don't add that much to the template constraints already present, so it's mostly a duplication of syntax and semantics. So I am not sure they are a good idea.


>static interface VConst(T) {
   constnessOf(T) is in [const, immutable, !const];
}
VConst!(Bar) doSomething(VConst!(Bar) b, int y) {...}

static interface MaybeRef(T) {
   refnessOf(T) is in [ref, !ref];
}
MaybeRef!(Bar) doSomethingElse(MaybeRef!(Bar) b, int y) { ... }<

Walter has just added traits to perform this, so I think this is already doable, with __trait/meta. and template constraints.
The opIn_r defined for arrays is something that D2 must eventually have, there's no doubt about this.

But "is in", followed by an array of those modifiers is currently impossible (you may create a tuple of templates, where each template tests for constness, etc). Maybe in future you can create an array of annotations:
[@const, @immutable, @notConst]

Bye,
bearophile



More information about the Digitalmars-d mailing list