Re: Trivial (but not bikeshed please) question of style…

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 28 10:44:35 PDT 2014


On 10/28/14 1:09 PM, "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> On Tuesday, 28 October 2014 at 16:02:03 UTC, Steven Schveighoffer wrote:
>> I don't think recipient.send(mail) is that unintuitive. It's how I
>> would visualize it from a contact application for instance.
>
> sender.send(mail) ?
>
> Consistency about direction is important when you choose names and
> syntax. I think in general that message passing "obj.method()" should be
> used when the function is either mutating the object or is an activity
> that the object has a sense of ownership on.
>

But parent is not the actual object, it's a *mailbox* of that object, or 
a reference. In essence, you are saying "use this recipient record to 
send a message to it's target"

> UFCS breaks this distinction, e.g.:
>
> arr.sort()  // inline mutating sort
>
> vs.
>
> sort(arr)  // functional pure sort

If you are saying we should expect sort(arr) to return a *copy* of the 
array that is sorted, I don't think that's a fair assessment of D user 
expectations. D is not a functional language. Even D pure function can 
mutate data.

-Steve


More information about the Digitalmars-d mailing list