March 16, 2014
On 03/16/2014 08:27 PM, monarch_dodra wrote:
>>
>> f.byLine.map!idup
>
> Indeed, I've been wanting to write this before. IMO, not being able to
> write it is a serious inconsistency.

What is it inconsistent with?
March 16, 2014
On 16/03/14 17:58, 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!

byLineCopy ... ?
March 16, 2014
On Sunday, 16 March 2014 at 20:27:35 UTC, Timon Gehr wrote:
> On 03/16/2014 08:27 PM, monarch_dodra wrote:
>>>
>>> f.byLine.map!idup
>>
>> Indeed, I've been wanting to write this before. IMO, not being able to
>> write it is a serious inconsistency.
>
> What is it inconsistent with?

Nevermind. I thought you could write "map!dup" like you can with most other *functions*, but "dup" is a member property function. In particular, things like "length"/"reserve" or whatnot are actually free functions that take an argument, but not dup.

So UFCS tends to blur the line between both, and what can be used where.
March 16, 2014
On 16/03/14 21:45, Joseph Rushton Wakeling wrote:
> byLineCopy ... ?

Sorry, didn't get far enough through the thread to see other people had already suggested this one.

March 16, 2014
Joseph Rushton Wakeling:

> Sorry, didn't get far enough through the thread to see other people had already suggested this one.

Suggesting it again is useful, because it means more people find that name sufficiently intuitive. So perhaps "byLineCopy" could be the winner name.

Bye,
bearophile
March 16, 2014
On Sunday, 16 March 2014 at 21:16:24 UTC, bearophile wrote:
> Joseph Rushton Wakeling:
>
>> Sorry, didn't get far enough through the thread to see other people had already suggested this one.
>
> Suggesting it again is useful, because it means more people find that name sufficiently intuitive. So perhaps "byLineCopy" could be the winner name.
>
> Bye,
> bearophile

byLineCopy seems good to me. It *may* be an idea to change the name of byLine very slowly via a long deprecation process so newcomers to the language don't start accidentally grabbing the shorter more obvious choice and run into problems when they are surprised by the semantics. byLineRef or some kind of thing. Just ignore me if that's a bad suggestion. I just kind of have this symmetry where if I have something named say "doFooSafely" I don't call the unsafe one "doFoo," I call it "doFooDangerously" or something obvious. Not that byLine is particularly "unsafe."

I considered calling a method named "disableGC" in DQt "createMemoryLeaks," but I decided that was pushing it a little too far. (It's a weird thing, but you actually need to use it some times. At least it's @system.)
March 16, 2014
16-Mar-2014 20:58, 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.

f.lines?



-- 
Dmitry Olshansky
March 17, 2014
On 2014-03-16 12:58, 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

string[] split(File f, char[] sep = "\n"[, size_t max = 0]);

auto ln = f.split("\n", 15); // returns a gc allocated array of 15 lines
March 17, 2014
Am Sun, 16 Mar 2014 18:31:59 +0000
schrieb "bearophile" <bearophileHUGS@lycos.com>:

> HeiHon:
> 
> >> byLineCopy or
> >> byLineCopied
> >> sounds natural for me (native german).
> 
> byLineCopy sounds good.
> 
> Bye,
> bearophile

+1. Same reasoning as HeiHon gave.

-- 
Marco

March 17, 2014
Am Sun, 16 Mar 2014 18:03:09 +0000
schrieb "Adam D. Ruppe" <destructionator@gmail.com>:

> If byLine returned a scope item, then it wouldn't be allowed to escape and throw a nice compile error pointing people in the right direction.... scope rox so much i want it so badly.

Yes, pointers to working buffers are a frequent use case for "borrowed pointers".

-- 
Marco