March 21, 2015
On 3/20/15 1:31 PM, Walter Bright wrote:
> On 3/20/2015 3:59 AM, Paulo Pinto wrote:
>> On Friday, 20 March 2015 at 10:50:44 UTC, Walter Bright wrote:
>>> Since 'line' is never referred to again after constructed, even a simple
>>> optimizer could elide it.
>>>
>>> It would be easy to test - accumulate the lines in an array, and
>>> check the times.
>>
>> Which the default Python implementation doesn't have, hence my comment.
>
> After all these years, the default Python implementation doesn't do
> fairly basic optimizations? I find that a bit hard to believe.

It's in all likelihood the truth. -- Andrei
March 21, 2015
On 3/14/2015 2:18 AM, Russel Winder via Digitalmars-d wrote:
> coding of error

Sounds like the title of my next book!
March 21, 2015
On 3/20/2015 5:36 PM, Andrei Alexandrescu wrote:
>> Nitpick 2: http://www.unicode.org/versions/Unicode7.0.0/ch05.pdf
>> (chapter 5.8) splitLines is still incomplete, missing to break on
>> U+0085, U+000B, U+000C. Would a PR for this be accepted?
>
> Prolly. Walter?

Sure.

March 21, 2015
On 3/20/2015 2:04 PM, Paulo Pinto wrote:
> The side effect is not keeping the string, rather generating it.
>
> for var in exp:
>     do_something()
>
> if exp represents a iteratable or a generator, even if var is thrown away the
> loop needs to be preserved to keep the semantics of calling next() on the
> instance object that executes the for..in loop.
>
> Put other way, does DMD throw away foreach loops even if the compiler cannot
> prove if  opApply () or popFront() generate side effects, assuming the variable
> isn't being used?

D has pure functions, and if those pure functions return an unneeded string, the call can be discarded.

BTW, it still is faster than splitLines simply because the line string is not stored. The GC can collect it and reuse the memory. Not so for splitLines, which must hold it all, meaning it'll be using memory that is not in the cache.

March 21, 2015
On 3/20/2015 5:23 PM, Andrei Alexandrescu wrote:
> Yah, and uses reference counting for management. -- Andrei

Ref counting won't improve splitLines, because it must keep them all.


March 21, 2015
On 3/20/2015 1:40 PM, weaselcat wrote:
> On Friday, 20 March 2015 at 20:34:36 UTC, Walter Bright wrote:
>> On 3/20/2015 8:25 AM, weaselcat wrote:
>>> All of the content on rosettacode appears to be licensed under GNU FDL, I
>>> believe it would just have to be released under the GNU FDL or a similar
>>> copyleft license that fulfills the GNU FDL.
>>
>> http://www.gnu.org/licenses/fdl-1.2.html
>>
>> Sigh, looks like we can't use it.
>
> all content on the dlang wiki is under the same license already?

Phobos is under Boost.
March 21, 2015
On 3/20/15 5:56 PM, Walter Bright wrote:
> On 3/20/2015 5:23 PM, Andrei Alexandrescu wrote:
>> Yah, and uses reference counting for management. -- Andrei
>
> Ref counting won't improve splitLines, because it must keep them all.

Yah, all solution based on "let's keep all lines so we count them at the end" are suboptimal. -- Andrei

March 21, 2015
On Saturday, 21 March 2015 at 01:31:21 UTC, Andrei Alexandrescu wrote:
> On 3/20/15 5:56 PM, Walter Bright wrote:
>> On 3/20/2015 5:23 PM, Andrei Alexandrescu wrote:
>>> Yah, and uses reference counting for management. -- Andrei
>>
>> Ref counting won't improve splitLines, because it must keep them all.
>
> Yah, all solution based on "let's keep all lines so we count them at the end" are suboptimal. -- Andrei

What about `.count("\n")` ?
March 21, 2015
> Well then write that answer.

Not true, right now.

March 21, 2015
On Friday, 20 March 2015 at 20:34:36 UTC, Walter Bright wrote:
> On 3/20/2015 8:25 AM, weaselcat wrote:
>> All of the content on rosettacode appears to be licensed under GNU FDL, I
>> believe it would just have to be released under the GNU FDL or a similar
>> copyleft license that fulfills the GNU FDL.
>
> http://www.gnu.org/licenses/fdl-1.2.html
>
> Sigh, looks like we can't use it.

Most of the content was written by bearophile, no?  He licensed it to rosettacode, but is this an exclusive license - has he actually given his sole rights to use his work them?  If not, you can use his work if he agrees.  And I would guess if one asks rosettacode nicely they might give rights to relicense all D examples (ie especially the ones bearophile didn't write) under boost for the dlang web site.  And even if not, it's still worth having them in a subdirectory under a different licence.