DMD 0.177 release [Length in slice expressions]
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Fri Dec 22 02:13:31 PST 2006
Pragma wrote:
> b[0 .. $.length];
> a[0 .. $.getIndexOf(';')];
>
> So in essence, every use of '$' would be a 'nullary' operator - an alias
> if you will.
This isn't going to be agreeable to most since the purpose of $ in the
first place was to save typing.
> I'd imagine that extending things in this manner would simplify things
> grammatically while allowing for a wider category of uses. However, it
> doesn't solve the issue that you brought up, and that I've quoted above.
>
> c[$-1];
>
> It looks like it should be an implicit cast of the '$' to a size_t
> (length), via it's use in an expression. Any thoughts on this?
I'd rather have $ defined everywhere to mean length, which is useful
outside [] as well.
Andrei
P.S. Maybe there's a misunderstanding? The grammar I sent does not have
a problem w.r.t. unary vs. nullary; it's just a tad more complicated to
avoid ambiguity.
More information about the Digitalmars-d-announce
mailing list