Jump to page: 1 28  
Page
Thread overview
Good name for f.byLine.map!(x => x.idup)?
Mar 16, 2014
Jakob Ovrum
Mar 16, 2014
sclytrack
Mar 16, 2014
Jakob Ovrum
Mar 16, 2014
Jakob Ovrum
Mar 16, 2014
bearophile
Mar 16, 2014
Ary Borenszweig
Mar 16, 2014
Jakob Ovrum
Mar 16, 2014
w0rp
Mar 16, 2014
bearophile
Mar 16, 2014
Jakob Ovrum
Mar 16, 2014
bearophile
Mar 16, 2014
HeiHon
Mar 16, 2014
bearophile
Mar 17, 2014
Marco Leise
May 21, 2014
Nick Treleaven
May 21, 2014
bearophile
Mar 17, 2014
HeiHon
Mar 16, 2014
Meta
Mar 16, 2014
Adam D. Ruppe
Mar 17, 2014
Marco Leise
Mar 17, 2014
H. S. Teoh
Mar 17, 2014
Nick Treleaven
Mar 16, 2014
Vladimir Panteleev
Mar 16, 2014
Jakob Ovrum
Mar 16, 2014
David Eagen
Mar 16, 2014
Vladimir Panteleev
Mar 16, 2014
bearophile
Mar 16, 2014
ponce
Mar 16, 2014
monarch_dodra
Mar 16, 2014
Timon Gehr
Mar 16, 2014
monarch_dodra
Mar 16, 2014
bearophile
Mar 16, 2014
w0rp
Mar 16, 2014
Dmitry Olshansky
Mar 17, 2014
bearophile
Mar 18, 2014
Regan Heath
Mar 17, 2014
Etienne Cimon
Mar 17, 2014
Etienne
Mar 17, 2014
Joseph Cassman
Mar 17, 2014
safety0ff
Mar 17, 2014
Mason McGill
Mar 17, 2014
Etienne
Mar 17, 2014
H. S. Teoh
Mar 17, 2014
John Stahara
Mar 18, 2014
Etienne Cimon
Mar 18, 2014
Regan Heath
Mar 18, 2014
Dicebot
Mar 18, 2014
Regan Heath
Mar 18, 2014
Dicebot
Mar 19, 2014
Regan Heath
Mar 19, 2014
Marco Leise
Mar 19, 2014
Danny Arends
Mar 19, 2014
Peter Alexander
Mar 19, 2014
Meta
Mar 20, 2014
monarch_dodra
May 21, 2014
Chris
May 21, 2014
bearophile
May 21, 2014
Chris
March 16, 2014
A classic idiom for reading lines and keeping them is f.byLine.map!(x => x.idup) to get strings instead of the buffer etc.

The current behavior trips new users on occasion, and the idiom solving it is very frequent. So what the heck - let's put that in a function, expose and document it nicely, and call it a day.

A good name would help a lot. Let's paint that bikeshed!


Andrei
March 16, 2014
On Sunday, 16 March 2014 at 16:58:36 UTC, Andrei Alexandrescu wrote:
> A classic idiom for reading lines and keeping them is f.byLine.map!(x => x.idup) to get strings instead of the buffer etc.
>
> The current behavior trips new users on occasion, and the idiom solving it is very frequent. So what the heck - let's put that in a function, expose and document it nicely, and call it a day.
>
> A good name would help a lot. Let's paint that bikeshed!
>
>
> Andrei

Maybe `byUniqueLine`.

We might also consider a higher order range (say, `byUnique`, in the same vein) that GC-clones elements in some generic fashion, then showing `f.byLine().byUnique()` front and centre in `byLine`'s documentation.

Just a couple of half-assed ideas to get the ball rolling.
March 16, 2014
Andrei Alexandrescu:

> A classic idiom for reading lines and keeping them is f.byLine.map!(x => x.idup) to get strings instead of the buffer etc.

This is essentially this issue, I will reopen it if you want:
https://d.puremagic.com/issues/show_bug.cgi?id=4474


> The current behavior trips new users on occasion,

In D the default behaviors should be "not tripping". And the optimized behavour should be on explicit request.

So I think byLine should dup on default, and it should not dup on request. As I explained in Issue 4474.

Perhaps this breaking change (I asked in Issue 4474) in byLine can't happen now.


> and the idiom solving it is very frequent. So what the heck - let's put that in a function, expose and document it nicely, and call it a day.
>
> A good name would help a lot. Let's paint that bikeshed!

A good function name for the copying version is:

"byDupLines"


An alternative solution is the opposite of that I was suggesting in Issue 4474:

byLine => not dup

byLine!true => copies every line with dup

Bye,
bearophile.
March 16, 2014
On 3/16/14, 10:28 AM, Jakob Ovrum wrote:
> On Sunday, 16 March 2014 at 16:58:36 UTC, Andrei Alexandrescu wrote:
>> A classic idiom for reading lines and keeping them is f.byLine.map!(x
>> => x.idup) to get strings instead of the buffer etc.
>>
>> The current behavior trips new users on occasion, and the idiom
>> solving it is very frequent. So what the heck - let's put that in a
>> function, expose and document it nicely, and call it a day.
>>
>> A good name would help a lot. Let's paint that bikeshed!
>>
>>
>> Andrei
>
> Maybe `byUniqueLine`.

No, looks like uniq.

Andrei


March 16, 2014
On Sunday, 16 March 2014 at 17:28:46 UTC, Jakob Ovrum wrote:
> On Sunday, 16 March 2014 at 16:58:36 UTC, Andrei Alexandrescu wrote:
>> A classic idiom for reading lines and keeping them is f.byLine.map!(x => x.idup) to get strings instead of the buffer etc.
>>
>> The current behavior trips new users on occasion, and the idiom solving it is very frequent. So what the heck - let's put that in a function, expose and document it nicely, and call it a day.
>>
>> A good name would help a lot. Let's paint that bikeshed!
>>
>>
>> Andrei
>
> Maybe `byUniqueLine`.
>
> We might also consider a higher order range (say, `byUnique`, in the same vein) that GC-clones elements in some generic fashion, then showing `f.byLine().byUnique()` front and centre in `byLine`'s documentation.
>
> Just a couple of half-assed ideas to get the ball rolling.


  f.byLineIdup();



March 16, 2014
On 3/16/14, 10:49 AM, bearophile wrote:
> So I think byLine should dup on default, and it should not dup on
> request.

That will not happen.

Andrei

March 16, 2014
On 3/16/14, 10:49 AM, bearophile wrote:
> A good function name for the copying version is:
>
> "byDupLines"

It introduces the notion of "dup" to newbies. I'd rather go with a natural name.

Andrei

March 16, 2014
On Sunday, 16 March 2014 at 17:50:41 UTC, sclytrack wrote:
>   f.byLineIdup();

If we can't find a descriptive name, what exactly are we buying over the status quo? Seems like the definition of a trivia function.

March 16, 2014
On 3/16/14, 10:52 AM, Jakob Ovrum wrote:
> On Sunday, 16 March 2014 at 17:50:41 UTC, sclytrack wrote:
>>   f.byLineIdup();
>
> If we can't find a descriptive name, what exactly are we buying over the
> status quo? Seems like the definition of a trivia function.

A function to send people to, instead of explaining an idiom.

Andrei


March 16, 2014
On 3/16/14, 10:52 AM, Jakob Ovrum wrote:
> Seems like the definition of a trivia function.

Trivial + frequent = good

see assert, enforce, ~, and many others.

Andrei


« First   ‹ Prev
1 2 3 4 5 6 7 8