Regarding std.array.Appender

2012-02-29 Thread bearophile
Do you know why std.array.Appender defines a "put" method instead of overloading the "~=" operator? Bye and thank you, bearophile

Re: Regarding std.array.Appender

2012-02-29 Thread Jonathan M Davis
On Wednesday, February 29, 2012 20:25:35 bearophile wrote: > Do you know why std.array.Appender defines a "put" method instead of > overloading the "~=" operator? put is a function on output ranges, and Appender is an output range. - Jonathan M Davis

Re: Regarding std.array.Appender

2012-02-29 Thread Andrej Mitrovic
Luckily you can always use alias this and overload opCatAssign. 'alias this' is a great tool for customizing APIs. :)

Re: Regarding std.array.Appender

2012-02-29 Thread Jonathan M Davis
On Wednesday, February 29, 2012 20:53:04 Jonathan M Davis wrote: > On Wednesday, February 29, 2012 20:25:35 bearophile wrote: > > Do you know why std.array.Appender defines a "put" method instead of > > overloading the "~=" operator? > > put is a function on output ranges, and Appender is an outpu

Re: Regarding std.array.Appender

2012-02-29 Thread bearophile
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 ap

Re: Regarding std.array.Appender

2012-02-29 Thread Adam D. Ruppe
On Thursday, 1 March 2012 at 02:23:55 UTC, bearophile wrote: But for me it's weird that Appender doesn't use the D operator to _append_. [...] I suggest to give it both "put" method and "~=" operator. I agree entirely. Another annoyance is if you have a function that works on regular arrays

Re: Regarding std.array.Appender

2012-02-29 Thread Jonathan M Davis
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

Re: Regarding std.array.Appender

2012-02-29 Thread Jonathan M Davis
On Thursday, March 01, 2012 03:29:06 Adam D. Ruppe wrote: > On Thursday, 1 March 2012 at 02:23:55 UTC, bearophile wrote: > > But for me it's weird that Appender doesn't use the D operator > > to _append_. [...] I suggest to give it both "put" method and > > "~=" operator. > > I agree entirely. >

Re: Regarding std.array.Appender

2012-02-29 Thread Adam D. Ruppe
On Thursday, 1 March 2012 at 02:44:35 UTC, Jonathan M Davis wrote: True, but it can't do all of the other operations that array can do either. Yeah, but the one operation it replaces, ~=, can be done on an array. If you're trying to convert array code to Appender for speed, most likely you're

Re: Regarding std.array.Appender

2012-02-29 Thread James Miller
On 1 March 2012 15:49, Adam D. Ruppe wrote: > On Thursday, 1 March 2012 at 02:44:35 UTC, Jonathan M Davis wrote: >> >> True, but it can't do all of the other operations that array can do >> either. > > > Yeah, but the one operation it replaces, ~=, can be done > on an array. > > If you're trying t

Re: Regarding std.array.Appender

2012-02-29 Thread Ali Çehreli
On 02/29/2012 08:28 PM, James Miller wrote: > I understand that Appenders aren't arrays, and should not be used as > such, but you /can/ use an array as an Appender. Yes you can but whatever you put() into the array is immediately popFront()'ed from the array. ;) You must use a temporary surrog

Re: Regarding std.array.Appender

2012-03-01 Thread Timon Gehr
On 03/01/2012 03:40 AM, Jonathan M Davis wrote: 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 ver

Re: Regarding std.array.Appender

2012-03-01 Thread Sönke Ludwig
Am 01.03.2012 03:40, schrieb Jonathan M Davis: 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

Re: Regarding std.array.Appender

2012-03-05 Thread Steven Schveighoffer
On Wed, 29 Feb 2012 20:25:35 -0500, bearophile wrote: Do you know why std.array.Appender defines a "put" method instead of overloading the "~=" operator? It should (in addition to put). I see you have already filed an enhancement. http://d.puremagic.com/issues/show_bug.cgi?id=4287 -S

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Monday, 5 March 2012 at 15:35:59 UTC, Steven Schveighoffer wrote: On Wed, 29 Feb 2012 20:25:35 -0500, bearophile wrote: Do you know why std.array.Appender defines a "put" method instead of overloading the "~=" operator? It should (in addition to put). I see you have already filed an en

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)'

Re: Regarding std.array.Appender

2015-10-13 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:21:54 UTC, Suliman wrote: I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)' I suspect you don't have it imported. import std.algorithm; or import std.algorithm : m

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:34:02 UTC, John Colvin wrote: On Tuesday, 13 October 2015 at 13:21:54 UTC, Suliman wrote: I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)' I suspect you don't have

Re: Regarding std.array.Appender

2015-10-13 Thread anonymous via Digitalmars-d-learn
On Tuesday 13 October 2015 15:42, Suliman wrote: > map!(a=> a~=" +") work fine, but how to add before > at same time? Use ~ instead of ~=, like so: map!(a => "+" ~ a ~ "+")

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
something like: auto content = file.byLine.map!("start " ~ a=>a ~ " end");

Re: Regarding std.array.Appender

2015-10-13 Thread anonymous via Digitalmars-d-learn
On Tuesday 13 October 2015 15:47, Suliman wrote: > something like: auto content = file.byLine.map!("start " ~ a=>a ~ > " end"); That's not how it works at all. Maybe stick to the examples of whatever resource you're learning from, for now.

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:55:07 UTC, anonymous wrote: On Tuesday 13 October 2015 15:47, Suliman wrote: something like: auto content = file.byLine.map!("start " ~ a=>a ~ " end"); That's not how it works at all. Maybe stick to the examples of whatever resource you're learning from, for

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:51:50 UTC, anonymous wrote: On Tuesday 13 October 2015 15:42, Suliman wrote: map!(a=> a~=" +") work fine, but how to add before at same time? Use ~ instead of ~=, like so: map!(a => "+" ~ a ~ "+") Thanks!