Trivial (but not bikeshed please) question of style…

via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 28 10:09:39 PDT 2014


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.


UFCS breaks this distinction, e.g.:

arr.sort()  // inline mutating sort

vs.

sort(arr)  // functional pure sort


Chaining would be better done using a pipelining syntax:

stringarr -> sort -> reverse -> join!", " -> file.write;

gen_pairs() -> (k,v) => (k,v,v*v) -> takestriplet -> auto result;


More information about the Digitalmars-d mailing list