Regarding std.array.Appender

Jonathan M Davis jmdavisProg at gmx.com
Wed Feb 29 18:40:15 PST 2012


On Wednesday, February 29, 2012 21:23:54 bearophile wrote:
> Jonathan M Davis:
> > > put is a function on output ranges, and Appender is an output range.
> > 
> > Also, given that it doesn't define ~ (and it wouldn't really make sense
> > for it to), it would be very weird IMHO to define ~=.
> 
> I don't understand why that's weird.
> In Java you can't overload an append operator, so using a method is right.
> But for me it's weird that Appender doesn't use the D operator to _append_.
> I sometimes use "add" instead of "put" by mistake, forgetting the right
> method name, because I find it quite unnatural. If Appender needs a put,
> then I suggest to give it both "put" method and "~=" operator.

Would you define += without defining +? Or *= without defining *? It strikes me 
as a misuse of operator overloading if you have an opOpAssign without its 
corresponding opBinary.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list