opDollar

Bill Baxter wbaxter at gmail.com
Thu Sep 11 19:23:05 PDT 2008


On Fri, Sep 12, 2008 at 11:10 AM, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> "Bill Baxter" wrote
>> On Fri, Sep 12, 2008 at 2:28 AM, Steven Schveighoffer
>>> For example, if you wanted to 'slice' an AA, you would use 2 keys for the
>>> slice 'indexes', what if the keys are strings?
>>
>> I'd say opSize, ala STL.  They got it right.  Should .size for arrays
>> too, not .length.  "Size" is a word that generalizes pretty well,
>> "length" is not.
>
> size doesn't work for slices that don't use sequential integers as index.
> i.e. imagine a sorted map (such as tree map) slice:
>
> TreeMap!(char[], char[]) tm;
>
> // create a slice of the treemap
>
> auto slice = tm["one".."two"];
>
> Replace the second with 'length' or 'size', and it looks weird:
>
> auto slice = tm["one"..length]
> auto slice = tm["one"..size]
>
> I much prefer 'end' or 'last'.  It reads natural.  From the "one" element to
> the end.

Ok, so you want to change the meaning of $ altogether from being a
number to something container dependent?

I guess that may generalize better...  But then shouldn't it evaluate
to an iterator?  Argh! :-)

--bb


More information about the Digitalmars-d-announce mailing list