std.array.array seems to return flatten copy of input

Steven Schveighoffer schveiguy at yahoo.com
Fri Apr 4 13:42:32 PDT 2014


On Fri, 04 Apr 2014 16:35:57 -0400, Olivier Grant  
<against.the at evil.bots.com> wrote:

> That is one responsive D community :) Thank you to all three of you for  
> these quick answers.
>
> I was really scratching my head on that one. This shows that UFCS can be  
> quite dangerous. Is there any way to hide Splicer.array to the outside  
> world? It just seems that it would be very easy to break client code by  
> updating your implementation if you end up using a name that is already  
> used elsewhere and accessed using UFCS.

I advise to call it _array to prevent such issues.

Note, you can make the field private, but that is a module-level  
directive. In order for it to apply, main would have to be in a separate  
module.

In that case, the code would simply fail to compile. As a rule, members  
ALWAYS have precedence over UFCS functions.

-Steve


More information about the Digitalmars-d-learn mailing list