Required Reading: "How Non-Member Functions Improve Encapsulation"

codephantom me at noyb.com
Tue Oct 31 02:30:33 UTC 2017


On Tuesday, 31 October 2017 at 02:10:26 UTC, Steven Schveighoffer 
wrote:
>
> Except... then you can't use generic code with UFCS.
>
> For example, arrays couldn't be ranges, because you can't just 
> do arr.front, you'd have to do arr.\front.
>
> -Steve

Mmm... it sounds complex ;-)

to make it worse, I can apparently call func() with the 
parenthesis:

obj.func;

now, is func an attribute of obj?
is it a method of obj?
is it a free function?

these syntactic abstractions are leaky...we need to encapsulate 
intent too ;-)



More information about the Digitalmars-d mailing list