Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 20, 2009 dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
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 |
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Mon, 20 Apr 2009 09:09:09 +0200, Walter Bright <newshound1@digitalmars.com> wrote:
>
> 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
Butbutbut... I've just barely managed to install 2.028 yet.
Great work! Can't wait to try out the new ranges.
--
Simen
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Hello Walter,
> 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
Cool template function literals sounds interesting
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS | BCS Wrote:
> Cool template function literals sounds interesting
May I have one example of them?
I am looking in the docs, but I am not finding anything...
Bye,
bearophile
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile wrote:
> BCS Wrote:
>> Cool template function literals sounds interesting
>
> May I have one example of them?
> I am looking in the docs, but I am not finding anything...
void foo(alias f)()
{
f(3, 4);
}
foo!((x,y){return x * y;))();
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile wrote: > BCS Wrote: >> Cool template function literals sounds interesting > > May I have one example of them? > I am looking in the docs, but I am not finding anything... > > Bye, > bearophile If I had to guess, I'd say it was something like this: > alias (T)(T a, T b) { return (a+b)/2.0; } average; Haven't had a chance to TRY that yet, mind you. :P -- Daniel |
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Keep |
Daniel Keep wrote:
>
> bearophile wrote:
>> BCS Wrote:
>>> Cool template function literals sounds interesting
>> May I have one example of them?
>> I am looking in the docs, but I am not finding anything...
>>
>> Bye,
>> bearophile
>
> If I had to guess, I'd say it was something like this:
>
>> alias (T)(T a, T b) { return (a+b)/2.0; } average;
>
> Haven't had a chance to TRY that yet, mind you. :P
>
> -- Daniel
(Sees Walter's post)
Guess not. :P
-- Daniel
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
>
> 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
Ooohhh, just half way through the change log, and already breathless!!!
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright:
> void foo(alias f)()
> {
> f(3, 4);
> }
> foo!((x,y){return x * y;))();
I have tried:
import std.stdio: writeln;
void foo(alias f)() {
f(3, 4);
}
void main() {
foo!( (x, y) { writeln(x * y); } )();
}
And it works, printing 12 :-) Very cute.
This is able to simplify some of the code of (D1) dlibs :-)
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? :-)
Bye,
bearophile
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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 |
Copyright © 1999-2021 by the D Language Foundation