byKey and byValue: properties or methods?

Peter Alexander peter.alexander.au at gmail.com
Fri Jan 20 01:29:12 PST 2012


On 20/01/12 12:57 AM, Steven Schveighoffer wrote:
> On Thu, 19 Jan 2012 18:41:44 -0500, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> On 1/19/12 4:43 PM, Steven Schveighoffer wrote:
>>> On Thu, 19 Jan 2012 14:06:00 -0500, torhu <no at spam.invalid> wrote:
>>>> If the type of byKeys is Range, I would expect to be able to treat it
>>>> like one. Not like one, then another, then another, then another... ad
>>>> infinitum.
>>>
>>> I don't know what you mean. You can treat it like one.
>>>
>>> -Steve
>>
>> It's the rvalue aspect. byKey does not hold a range inside the
>> hashtable (as a member variable would do). Each use of byKey gives you
>> a range that you get to iterate from the beginning.
>
> The point of a property is to allow for read-only access on something
> that is logically a property but can only be implemented via a function.
> byKeys is such a property. There is no way to specify a field that
> behaves the same. This doesn't make properties invalid or useless.

Can you define what "is logically a property means"? (I assume you meant 
"field" there)

That means different things to different people. For example, in my 
mind, something that is logically a field would have an address. From 
what I can see, byKeys is logically a function (not a field) in every 
way (because it *is* a function).


More information about the Digitalmars-d mailing list