April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Mon, 20 Apr 2009 18:12:16 +0900, Walter Bright <newshound1@digitalmars.com> 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... > > void foo(alias f)() > { > f(3, 4); > } > > foo!((x,y){return x * y;))(); void foo(alias f)() { writefln(f(3, 4)); } foo!((x,y){ return x * y; })(); This code doesn't work(compile error). But, following code works. void bar(alias f)() { writefln(f("bar")); } bar!((str) { return str; })(); Is this a bug? -- tama <repeatedly@gmail.com> http://profile.livedoor.com/repeatedly/ $B%a%s%P!<Jg=8Cf(B http://tpf.techtalk.jp/ |
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to tama | tama:
> void foo(alias f)()
> {
> writefln(f(3, 4));
> }
> foo!((x,y){ return x * y; })();
>
> This code doesn't work(compile error).
To me the following works:
import std.stdio: writeln;
void foo(alias f)() {
writeln(f(3, 4));
}
void main() {
foo!((x,y){ return x * y; })();
}
Bye,
bearophile
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | bearophile wrote: > tama: >> void foo(alias f)() >> { >> writefln(f(3, 4)); >> } >> foo!((x,y){ return x * y; })(); >> >> This code doesn't work(compile error). > > To me the following works: > > import std.stdio: writeln; > void foo(alias f)() { > writeln(f(3, 4)); > } > void main() { > foo!((x,y){ return x * y; })(); > } I see. I tested following code. writefln(3 * 4); This code doesn't work in the first place:-< Sorry, it didn't matter. -- tama <repeatedly@gmail.com> http://profile.livedoor.com/repeatedly/ $B%a%s%P!<Jg=8Cf(B http://tpf.techtalk.jp/ |
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to tama | On Mon, 20 Apr 2009 14:58:38 +0400, tama <repeatedly@gmail.com> wrote:
> bearophile wrote:
>> tama:
>>> void foo(alias f)()
>>> {
>>> writefln(f(3, 4));
>>> }
>>> foo!((x,y){ return x * y; })();
>>>
>>> This code doesn't work(compile error).
>>
>> To me the following works:
>>
>> import std.stdio: writeln;
>> void foo(alias f)() {
>> writeln(f(3, 4));
>> }
>> void main() {
>> foo!((x,y){ return x * y; })();
>> }
> I see.
>
> I tested following code.
>
> writefln(3 * 4);
>
> This code doesn't work in the first place:-<
> Sorry, it didn't matter.
>
writefln now expects a string as a first argument.
Use writeln() if you need no formattings, it is both faster and safer.
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Koroskin | Denis Koroskin wrote: > writefln now expects a string as a first argument. > Use writeln() if you need no formattings, it is both faster and safer. To one's shame, I didn't know detailed writef/writefln spec. I checked D2 changelog and founded it at version 2.006 and 2.029. Thanks! -- tama <repeatedly@gmail.com> http://profile.livedoor.com/repeatedly/ $B%a%s%P!<Jg=8Cf(B http://tpf.techtalk.jp/ |
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Using D1 feels especially retarded today :(
> 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 | 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
The documentation for completeSort in std.algorithm says:
Performs O(n * log(n)) (best case)
to O(n * log(n)) (worst-case) evaluations of swap.
I wonder what it should be.
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Georg Wrede | Georg Wrede wrote:
> 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
>
> The documentation for completeSort in std.algorithm says:
>
> Performs O(n * log(n)) (best case)
> to O(n * log(n)) (worst-case) evaluations of swap.
>
> I wonder what it should be.
Sorry, what was I thinking? I think (without being sure) that the
complexity of completeSort is O(rhs.length * log(t)) in the
best case, and O(t * log(t)) in the worst case, where t = lhs.length +
rhs.length.
Andrei
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Saaa | Saaa wrote:
> Using D1 feels especially retarded today :(
Don't cry now. :-)
Soon you'll be using D2 for work, and cry when you see the D3 change log...
|
April 20, 2009 Re: dmd 2.029 release | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu wrote:
> Georg Wrede wrote:
>> 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
>>
>> The documentation for completeSort in std.algorithm says:
>>
>> Performs O(n * log(n)) (best case)
>> to O(n * log(n)) (worst-case) evaluations of swap.
>>
>> I wonder what it should be.
>
> Sorry, what was I thinking? I think (without being sure) that the
> complexity of completeSort is O(rhs.length * log(t)) in the
> best case, and O(t * log(t)) in the worst case, where t = lhs.length +
> rhs.length.
I revise that. Best case, there's temporary memory to allocate and then the complexity is that of sorting rhs plus merge lhs and rhs using extra memory. That is O(lhs.length + rhs.length * log(rhs.length)).
Worst case, there's no temporary memory available so we need to sort the whole thing. That means O((lhs.length + rhs.length) * log(rhs.length + rhs.length)).
I committed the fixed module.
Andrei
|
Copyright © 1999-2021 by the D Language Foundation