January 21, 2012
On 2012-01-20 17:58:28 +0000, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> said:

> I tallied the votes.
> 
> Function: Mail Mantis, bearophile, Jacob Carlborg, Olivier Pisano, Ary Manzana, torhu.
> 
> Property: Nick Sabalausky, Simen Kjaeraas.
> 
> I wasn't able to discern a clear vote from the others. Please correct the list.

Votes ?!?

I think byKey and byValue are oddly named, property or not. Since you asked, I think they should be properties. But I don't care really. What I care about is consistency.

Voting on a case by case basis is just nonsensical. What's needed are guidelines and rationales covering how to name things and by extension what should and shouldn't be a property. If something needs to be put to vote, it should be those guidelines.

I attempted a while ago to write some guidelines on the wiki, feel free to use them if they make sense to you.
<http://prowiki.org/wiki4d/wiki.cgi?DProgrammingGuidelines>

-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/

January 21, 2012
On 1/20/12 7:31 PM, Michel Fortin wrote:
> On 2012-01-20 17:58:28 +0000, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> said:
>
>> I tallied the votes.
>>
>> Function: Mail Mantis, bearophile, Jacob Carlborg, Olivier Pisano, Ary
>> Manzana, torhu.
>>
>> Property: Nick Sabalausky, Simen Kjaeraas.
>>
>> I wasn't able to discern a clear vote from the others. Please correct
>> the list.
>
> Votes ?!?
>
> I think byKey and byValue are oddly named, property or not.

Give them better names and convince others. Please don't choose "keys" and "values".

> Since you
> asked, I think they should be properties. But I don't care really. What
> I care about is consistency.

Mindless consistency would probably be unnerving too.

> Voting on a case by case basis is just nonsensical. What's needed are
> guidelines and rationales covering how to name things and by extension
> what should and shouldn't be a property. If something needs to be put to
> vote, it should be those guidelines.
>
> I attempted a while ago to write some guidelines on the wiki, feel free
> to use them if they make sense to you.
> <http://prowiki.org/wiki4d/wiki.cgi?DProgrammingGuidelines>

A good outcome of this vote might have been the distillation of some simple guidelines, as opposed to enforcing some arbitrary consistency. Apparently the participants in this thread are divided regarding general rules as well as their applicability to this particular case.


Andrei
January 21, 2012
On 2012-01-21 01:43:17 +0000, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> said:

> On 1/20/12 7:31 PM, Michel Fortin wrote:
>> On 2012-01-20 17:58:28 +0000, Andrei Alexandrescu
>> <SeeWebsiteForEmail@erdani.org> said:
>> 
>>> I tallied the votes.
>>> 
>>> Function: Mail Mantis, bearophile, Jacob Carlborg, Olivier Pisano, Ary
>>> Manzana, torhu.
>>> 
>>> Property: Nick Sabalausky, Simen Kjaeraas.
>>> 
>>> I wasn't able to discern a clear vote from the others. Please correct
>>> the list.
>> 
>> Votes ?!?
>> 
>> I think byKey and byValue are oddly named, property or not.
> 
> Give them better names and convince others. Please don't choose "keys" and "values".

Well, if the best ones are already taken, I'd say "allKeys" and "allValues" would be the next best ones. And they are obviously properties.


>> Since you
>> asked, I think they should be properties. But I don't care really. What
>> I care about is consistency.
> 
> Mindless consistency would probably be unnerving too.

Guidelines are guides, not absolutes. If you have a good reason it is perfectly fine to not follow the guideline, and you can amend the document if it happens too often. But you need guidelines as a baseline, and a good reason when you derogate.


>> Voting on a case by case basis is just nonsensical. What's needed are
>> guidelines and rationales covering how to name things and by extension
>> what should and shouldn't be a property. If something needs to be put to
>> vote, it should be those guidelines.
>> 
>> I attempted a while ago to write some guidelines on the wiki, feel free
>> to use them if they make sense to you.
>> <http://prowiki.org/wiki4d/wiki.cgi?DProgrammingGuidelines>
> 
> A good outcome of this vote might have been the distillation of some simple guidelines, as opposed to enforcing some arbitrary consistency. Apparently the participants in this thread are divided regarding general rules as well as their applicability to this particular case.

It'd be more useful if the discussion involved several examples of various types. You can't make a guideline from only one case, especially a litigious case. You must start by establishing a consensus by listing more clear-cut cases and then you can extend from that consensual position.


-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/

January 21, 2012
On 20/01/2012 17:58, Andrei Alexandrescu wrote:
> On 1/17/12 12:48 AM, Andrei Alexandrescu wrote:
>> I hate I must ask this:
>>
>> int[string] aa;
>> foreach (k; aa.byKey) { ... }
>>
>> or
>>
>> int[string] aa;
>> foreach (k; aa.byKey()) { ... }
>>
>>
>>
>> Thanks,
>>
>> Andrei "I told you" Alexandrescu
>
> I tallied the votes.
>
> Function: Mail Mantis, bearophile, Jacob Carlborg, Olivier Pisano, Ary
> Manzana, torhu.
>
> Property: Nick Sabalausky, Simen Kjaeraas.
>
> I wasn't able to discern a clear vote from the others. Please correct
> the list.
>
>
> Thanks,
>
> Andrei

I vote property.

While the names do not fall in line with the properties-are-nouns pattern, I do see the compound aa.byKey as a noun (especially when aa is something more meaningful, and preferably plural). So I think the names should stay as they are.

A...
January 21, 2012
Andrei Alexandrescu wrote:

> On 1/20/12 7:31 PM, Michel Fortin wrote:
>> On 2012-01-20 17:58:28 +0000, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> said:
>>
>>> I tallied the votes.
>>>
>>> Function: Mail Mantis, bearophile, Jacob Carlborg, Olivier Pisano, Ary Manzana, torhu.
>>>
>>> Property: Nick Sabalausky, Simen Kjaeraas.
>>>
>>> I wasn't able to discern a clear vote from the others. Please correct the list.
>>
>> Votes ?!?
>>
>> I think byKey and byValue are oddly named, property or not.
> 
> Give them better names and convince others. Please don't choose "keys" and "values".

keyRange and valueRange?
> 
>> Since you
>> asked, I think they should be properties. But I don't care really. What
>> I care about is consistency.
> 
> Mindless consistency would probably be unnerving too.
> 
>> Voting on a case by case basis is just nonsensical. What's needed are guidelines and rationales covering how to name things and by extension what should and shouldn't be a property. If something needs to be put to vote, it should be those guidelines.
>>
>> I attempted a while ago to write some guidelines on the wiki, feel free to use them if they make sense to you. <http://prowiki.org/wiki4d/wiki.cgi?DProgrammingGuidelines>
> 
> A good outcome of this vote might have been the distillation of some simple guidelines, as opposed to enforcing some arbitrary consistency. Apparently the participants in this thread are divided regarding general rules as well as their applicability to this particular case.
> 
> 
> Andrei

January 21, 2012
On 21/01/12 1:43 AM, Andrei Alexandrescu wrote:
> Apparently the participants in this thread are divided regarding general
> rules as well as their applicability to this particular case.

And this is exactly the problem. There are no general rules because everyone disagrees with what exactly a property is.
January 21, 2012
On 21.01.2012 02:43, Andrei Alexandrescu wrote:
>
> A good outcome of this vote might have been the distillation of some
> simple guidelines, as opposed to enforcing some arbitrary consistency.
> Apparently the participants in this thread are divided regarding general
> rules as well as their applicability to this particular case.

I think that the people here have two different views of what a property is:

1) Just way to hook up some code to what looks and (mostly) behaves like field access.
2) A property of some object, in a wider sense.

Examples of 1) are:  Creating a read-only field, or delaying calculating a value until first use and then caching it for future use.  An example of 2) would be saying that the set of keys of an AA is a property of that AA.

As I see it, the main difference between 1) and 2) is that with the latter you are giving field access (dot) syntax a new logical meaning that it didn't use to have.  Which why I'm weary of things like aa.byKey.  What is the gain, not having to type parentheses?  That's not a lot.
January 22, 2012
El 20/01/2012 18:58, Andrei Alexandrescu escribió:
> On 1/17/12 12:48 AM, Andrei Alexandrescu wrote:
>> I hate I must ask this:
>>
>> int[string] aa;
>> foreach (k; aa.byKey) { ... }
>>
>> or
>>
>> int[string] aa;
>> foreach (k; aa.byKey()) { ... }
>>

I vote properties.

The general rule to me the is a function represents an *action* and usually has a verb in its name while a property is logically something of an object and its name is basically a noun, but nothing is said about whether that thing is stored (a field). A function *does* something, a property *is* something. I'm using "is" in a special way maybe because property values might not actually exist and be created/computed on the fly.

"circle.area" is the area of a circle. Whether its value is stored or computed on the fly does not change that.

aa.byKey is a range of keys, so, property.

Even "a.dup" *is* "a duplicate of a" so it's OK as a property even if it is not a "part" of a. Emphasis on the action of creating that duplicate is removed.

BTW, someone said that properties bring something more to remember (is it a.b or a.b()?) but I think they actually reduce doubts:

How would I change the radius of a circle in another language? circle.setRadius(2), circle.SetRadius(2), circle.set_radius(2), circle.radius_set(2)? With properties "circle.radius=2;" easier to remember.

My two cents.
January 22, 2012
El 21/01/2012 3:05, Michel Fortin escribió:
>>> I think byKey and byValue are oddly named, property or not.
>>
>> Give them better names and convince others. Don't choose "keys"
>> and "values".
>
> Well, if the best ones are already taken, I'd say "allKeys" and
> "allValues" would be the next best ones. And they are obviously
> properties.
>

Agree with "allKeys" and "allValues" as the next best.

IMO, the name of a property should be a a *noun phrase* (a noun possibly with modifiers, complements, adjectives...) because it represents a thing. And if the property represens a collection of things (an array, a list, a range,...) that noun should be *plural* (giving the idea that it can be enumerable). "allKeys" follows this guideline (plural noun with a complement).

byKey is what, an adverb phrase, an adjective phrase? It can't name a range which is a thing.

January 22, 2012
On Sunday, January 22, 2012 12:57:14 Alvaro wrote:
> byKey is what, an adverb phrase, an adjective phrase?

Prepositional phrase actually.

- Jonathan M Davis