opDollar
Bill Baxter
wbaxter at gmail.com
Thu Sep 11 18:42:44 PDT 2008
On Fri, Sep 12, 2008 at 2:28 AM, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> "Tomas Lindquist Olsen" wrote
>> Stewart Gordon wrote:
>>> "Bill Baxter" <wbaxter at gmail.com> wrote in message
>>> news:mailman.89.1220922329.19733.digitalmars-d-announce at puremagic.com...
>>>> On Tue, Sep 9, 2008 at 9:37 AM, Andrei Alexandrescu
>>>> <SeeWebsiteForEmail at erdani.org> wrote:
>>>>> Denis Koroskin wrote:
>>>>>> 4) We need some way of supporting dollar notation in user containers.
>>>>>> The
>>>>>> hack of using __dollar is bad (although it works).
>>>
>>> Agreed.
>>>
>>>>> It doesn't work for multiple dimensions. There should be an
>>>>> opDollar(uint
>>>>> dim) that gives the library information on which argument count it
>>>>> occured
>>>>> in. Consider:
>>> <snip>
>>>
>>> opDollar is the wrong choice of name. The op* methods are - as a rule -
>>> named after the semantic function of the operator, rather than what the
>>> operator looks like. For example, opMul not opAsterisk, opIndex not
>>> opSquareBrackets. Consequently, opStar is already inconsistently named;
>>> I think one such is enough. As for what the function to overload $
>>> should be called ... how about opEnd?
>>>
>>> Where did this conversation begin? I can't seem to find any messages up
>>> the thread from the one I'm replying to now.
>>>
>>> Stewart.
>>>
>>
>> Since $ is used as a shortcut for for array.length, I'd say opLength is a
>> better choice. Maybe I missed some of the discussion ...
>
> I'd agree with opEnd. opLength is only a valid construct for arrays, where
> the slice indexes are based on how far into the container the element is.
>
> 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.
Also don't forget about opStar! It shoudn't be called that either.
opDeref is what it really wants to be. :-)
[/dream mode off]
--bb
More information about the Digitalmars-d-announce
mailing list