Do you know why std.array.Appender defines a "put" method instead of
overloading the "~=" operator?
Bye and thank you,
bearophile
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
Luckily you can always use alias this and overload opCatAssign. 'alias
this' is a great tool for customizing APIs. :)
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
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
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
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
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.
>
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
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
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
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
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
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
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
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)'
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
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
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 ~ "+")
something like: auto content = file.byLine.map!("start " ~ a=>a ~
" end");
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.
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
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!
23 matches
Mail list logo