January 24, 2012 Re: byKey and byValue: properties or methods? | ||||
|---|---|---|---|---|
| ||||
> >> byKey is what, an adverb phrase, an adjective
> phrase? It can't name a
> >> range which is a thing.
> >
> > It has the implied verb "enumerate", "span". "Span
> hashtable by key".
>
> Actually, it's for each (x) in (y) by key:
>
> foreach(i; aa.byKey);
>
> The verb is not implied, nor should it be:
Perhaps I'm out of line, and I haven't looked much at the class/struct specifically in question (Actually I have no clue which one your talking about), but I would wonder one thing. Would it be read/write or just read-only? If it's read-only, I would think there would be no harm in having it as a property.
A second thought, is would there be any benefit having it as a method, specifically passing the address as a function rather than just getting the return value (From what I can tell that's unlikely).
I'll vote property.
| ||||
January 24, 2012 Re: byKey and byValue: properties or methods? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Era Scarecrow | On Tue, 24 Jan 2012 16:43:33 -0500, Era Scarecrow <rtcvb32@yahoo.com> wrote: >> >> byKey is what, an adverb phrase, an adjective >> phrase? It can't name a >> >> range which is a thing. >> > >> > It has the implied verb "enumerate", "span". "Span >> hashtable by key". >> >> Actually, it's for each (x) in (y) by key: >> >> foreach(i; aa.byKey); >> >> The verb is not implied, nor should it be: > > Perhaps I'm out of line, and I haven't looked much at the class/struct specifically in question (Actually I have no clue which one your talking about), The builtin associative arrays of D. i.e.: int[string] aa; > but I would wonder one thing. Would it be read/write or just read-only? If it's read-only, I would think there would be no harm in having it as a property. If key, it must be read only, since keys must be immutable. If value, it could potentially be read/write. > A second thought, is would there be any benefit having it as a method, specifically passing the address as a function rather than just getting the return value (From what I can tell that's unlikely). properties are methods. There should be a way to pass a delegate to a property function, not allowing this would be unnecessarily limiting. Some sort of __traits directive comes to mind... -Steve | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply