March 19, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Am Tue, 18 Mar 2014 09:49:32 -0700 schrieb Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org>: > On 3/18/14, 6:49 AM, Steven Schveighoffer wrote: > > byStringLines > > First one I like. > > Andrei Also consider the consistency. The function does byLine() + a copy, right? Not something entirely different. byLine byLine[Copy/Dup/...] would also show up in order on lists like Phobos documentation or IDE completion lists, so it cannot be missed. Which is important, because the obvious choice has the unexpected buffer reuse. Consistency, consistency, consistency. That's how Java got big. How PHP made it, I don't know. -- Marco |
March 19, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marco Leise | On Wednesday, 19 March 2014 at 13:44:35 UTC, Marco Leise wrote:
> Am Tue, 18 Mar 2014 09:49:32 -0700
> schrieb Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org>:
>
>> On 3/18/14, 6:49 AM, Steven Schveighoffer wrote:
>> > byStringLines
>>
>> First one I like.
>>
>> Andrei
asString(s)
byString(s)
my 2 cents
|
March 19, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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.
f.readLines
|
March 19, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | On Wednesday, 19 March 2014 at 22:30:55 UTC, Peter Alexander 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.
>
> f.readLines
What about a simpler f.iter() or f.lineIter()?
|
March 20, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On 3/19/14, 4:53 PM, Meta wrote:
> On Wednesday, 19 March 2014 at 22:30:55 UTC, Peter Alexander 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.
>>
>> f.readLines
>
> What about a simpler f.iter() or f.lineIter()?
Ideally it would be a variation of byLine. -- Andrei
|
March 20, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Thursday, 20 March 2014 at 01:38:38 UTC, Andrei Alexandrescu wrote:
> On 3/19/14, 4:53 PM, Meta wrote:
>> On Wednesday, 19 March 2014 at 22:30:55 UTC, Peter Alexander 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.
>>>
>>> f.readLines
>>
>> What about a simpler f.iter() or f.lineIter()?
>
> Ideally it would be a variation of byLine. -- Andrei
What about simply templatizing (*) it?
byLine() => implicit char[]
byLine!string() => dupes
This has the double advantage that:
* Does not introduce a new symbol
* Can be customized for wchar/dchar
In particular, the wchar thing could be of interest to those that are reading a file they now is UTF16/UCS2.
(*) Technically, it's already a template, but the parameters are inferred. We could make it so that we can use explicitly defined parameters. In particular, so that the output type is specified before the terminator type. AFAIK, the transition can be made seemlessly with no breakage.
|
May 21, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marco Leise | On 17/03/2014 03:58, Marco Leise wrote: > 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. Implemented and reviewed by monarchdodra. Ready to merge (but more feedback would help): https://github.com/D-Programming-Language/phobos/pull/2077 |
May 21, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Treleaven | Nick Treleaven: > Implemented and reviewed by monarchdodra. Ready to merge (but more feedback would help): > https://github.com/D-Programming-Language/phobos/pull/2077 Good. Reopened: https://issues.dlang.org/show_bug.cgi?id=4474 Bye, bearophile |
May 21, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Thursday, 20 March 2014 at 01:38:38 UTC, Andrei Alexandrescu wrote:
> On 3/19/14, 4:53 PM, Meta wrote:
>> On Wednesday, 19 March 2014 at 22:30:55 UTC, Peter Alexander 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.
>>>
>>> f.readLines
>>
>> What about a simpler f.iter() or f.lineIter()?
>
> Ideally it would be a variation of byLine. -- Andrei
byLineAsString
In my own APIs I usually use "AsString" in the signature to make it clear what you'll get, if an entity can take many forms (an array of strings, user defined types). In other cases toString().
byLineToString
?
|
May 21, 2014 Re: Good name for f.byLine.map!(x => x.idup)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | Chris:
> byLineAsString
>
> In my own APIs I usually use "AsString" in the signature to make it clear what you'll get, if an entity can take many forms (an array of strings, user defined types). In other cases toString().
>
> byLineToString
>
> ?
The accepted name was byLineCopy :-)
Bye,
bearophile
|
Copyright © 1999-2021 by the D Language Foundation