April 20, 2009
On Mon, Apr 20, 2009 at 2:47 PM, Saaa <empty@needmail.com> wrote:
> Using D1 feels especially retarded today :(
>

Why retarded ?
April 20, 2009
bearophile wrote:
> In D1 I have written a very hairy (but not too much long) apply() function, that given a function and some arguments, returns the result of the function applied to them. (apply() is a basic higher-order thing common in most functional languages).
> 
> So now I'm playing with this new toy of D2, not using it in a serious way yet, and I have written:
> 
> import std.stdio: writeln;
> auto apply(alias f, TyArgs...)(TyArgs args) {
>     return f(args);
> }
> void main() {
>     writeln(  apply!( (x, y) { return x * y; } )(3, 4)  );
> }
> 
> But when I compile it the compile spits out at compile-time:
> Assertion failure: '0' on line 935 in file 'glue.c'
> 
> Bye,
> bearophile

Your code should work as expected. (Also, right off the bat, any assertion failure in the compiler is a bug.) Could you submit to bugzilla?

Andrei
April 20, 2009
== Quote from Walter Bright (newshound1@digitalmars.com)'s article
> This is a major revision to Phobos, including Andrei's revolutionary new
> range support.
> http://www.digitalmars.com/d/2.0/changelog.html
> http://ftp.digitalmars.com/dmd.2.029.zip

Two small issues I've just run into that might warrant a quick update:

Line 908 in random.d calls the deprecated rand_seed() for the old school random number generators from the static constructor.  This means that std.random just plain can't be used out of the box.

Also, when using std.string, I get the following linker errors on the Win32 build:


Symbol Undefined _D3std6string6striprFAyaZAya
Symbol Undefined _D3std6string6striplFAyaZAya

April 20, 2009
== Quote from dsimcha (dsimcha@yahoo.com)'s article
> == Quote from Walter Bright (newshound1@digitalmars.com)'s article
> > This is a major revision to Phobos, including Andrei's revolutionary new
> > range support.
> > http://www.digitalmars.com/d/2.0/changelog.html
> > http://ftp.digitalmars.com/dmd.2.029.zip
> Two small issues I've just run into that might warrant a quick update:
> Line 908 in random.d calls the deprecated rand_seed() for the old school random
> number generators from the static constructor.  This means that std.random just
> plain can't be used out of the box.
> Also, when using std.string, I get the following linker errors on the Win32 build:
> Symbol Undefined _D3std6string6striprFAyaZAya
> Symbol Undefined _D3std6string6striplFAyaZAya

Never mind on the linker error.  That was caused by me forgetting to recompile parts of my code.  The random thing looks legit, though.
April 20, 2009
dsimcha wrote:
> == Quote from dsimcha (dsimcha@yahoo.com)'s article
>> == Quote from Walter Bright (newshound1@digitalmars.com)'s article
>>> This is a major revision to Phobos, including Andrei's revolutionary new
>>> range support.
>>> http://www.digitalmars.com/d/2.0/changelog.html
>>> http://ftp.digitalmars.com/dmd.2.029.zip
>> Two small issues I've just run into that might warrant a quick update:
>> Line 908 in random.d calls the deprecated rand_seed() for the old school random
>> number generators from the static constructor.  This means that std.random just
>> plain can't be used out of the box.
>> Also, when using std.string, I get the following linker errors on the Win32 build:
>> Symbol Undefined _D3std6string6striprFAyaZAya
>> Symbol Undefined _D3std6string6striplFAyaZAya
> 
> Never mind on the linker error.  That was caused by me forgetting to recompile
> parts of my code.  The random thing looks legit, though.

Ok, I've undeprecated rand_seed, sigh. I was hoping I'd eliminate rand() entirely from this release, but Walter pointed out it would break too much code. So I left rand() and rand_seed() as deprecated. Now I only left rand() deprecated so at least the static constructor works.


Andrei
April 20, 2009
I like very much the direction D2 is going now.  Language refactoring and enhancements driven by the goal of more elegant implementation of standard libraries.  This approach seems very practical and promising.  Thank you very much and keep it up!

-Craig 

April 20, 2009
Craig Black Wrote:

> I like very much the direction D2 is going now.  Language refactoring and enhancements driven by the goal of more elegant implementation of standard libraries.  This approach seems very practical and promising.  Thank you very much and keep it up!
> 
> -Craig

holy guacashit this works.

import std.algorithm;
import std.range;
import std.stdio;

void main()
{
    string[] a = [ "shit", "poop" ];
    string[] b = [ "dump", "shite" ];
    sort!((a, b) { return a > b; })(chain(a, b));
    writeln(a, " ", b);
}

i'll be shat on. couple shitty problems tho. auto don't work shit for a and b. complains about fixed size strings'n'shit. then writeln(chain(a, b)) shites ChainImpl!(immutable(char)[][],immutable(char)[][]) to stdout. tat's liable to scare da shit outta a beginner.

April 20, 2009
Walter Bright wrote:

In std.array, the example for back() is the same as for front().


The example for put() seems to be correct (and put() behaves accordingly), however, the asserted results are not what the reader would expect.

If we are verbose enough to explain the dot notation here, then it would be prudent to elaborate a little as to the point of put(), and possibly the example (or the explanation) could include a use case.

April 20, 2009
bearophile wrote:
> I didn't even know that lambda delegates in D2 can now infer the type
> of their input argument, so you can use (x, y) instead of (int x, int
> y). Can you tell me when this was changed? :-)

That change *is* the template function literals, and they are only valid as template arguments.
April 20, 2009
superdan wrote:
> Craig Black Wrote:
> 
>> I like very much the direction D2 is going now.  Language refactoring and enhancements driven by the goal of more elegant implementation of standard libraries.  This approach seems very practical and promising.  Thank you very much and keep it up!
>>
>> -Craig
> 
> holy guacashit this works.
> 
> import std.algorithm;
> import std.range;
> import std.stdio;
> 
> void main()
> {
>     string[] a = [ "shit", "poop" ];
>     string[] b = [ "dump", "shite" ];
>     sort!((a, b) { return a > b; })(chain(a, b));
>     writeln(a, " ", b);
> }
> 
> i'll be shat on. couple shitty problems tho. auto don't work shit for a and b. complains about fixed size strings'n'shit. then writeln(chain(a, b)) shites ChainImpl!(immutable(char)[][],immutable(char)[][]) to stdout. tat's liable to scare da shit outta a beginner.
> 

Poop is funny! :)