DMD 0.177 release [Length in slice expressions]

Pragma ericanderton at yahoo.removeme.com
Fri Dec 22 08:15:49 PST 2006


Andrei Alexandrescu (See Website For Email) wrote:
> 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.

Understood.  I just figured I'd throw that out there in case it had any 
merit in the current discussion.

> 
> 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.

Ah, I understand then.  The way you explained the grammar changes, it 
looked to me as though there was still an issue.

-- 
- EricAnderton at yahoo



More information about the Digitalmars-d-announce mailing list