April 21, 2009
Lars T. Kyllingstad 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
> 
> This is looking very nice! I want to switch from D1 to D2, but...
> 
> I don't want to sound greedy or anything, and I know others have asked for this before, but is making a 64-bit Linux version of DMD a lot of work?

I would kill for a 64-bit Linux DMD. I think it could take a lot of ways of coding to a whole new level. Sean and I have also been discussing how to integrate memory-mapped files with the garbage collector. In a 64-bit environment this makes for an awesome programming model.


Andrei
April 21, 2009
Max Samukha wrote:
> On Mon, 20 Apr 2009 09:57:55 +0200, Max Samukha
> <samukha@voliacable.com.removethis> wrote:
> 
>> On Mon, 20 Apr 2009 00:09:09 -0700, 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
>> Wicked awesome!
>>
>> file:///C:/dmd/html/d/phobos/std_range.html#cons
> http://www.digitalmars.com/d/2.0/phobos/std_range.html#cons
> 
>> Looks like bug 2676 was fixed in 2.027

Thanks. I uncommented the unittest, updated the doc, and checked in.

Andrei
April 21, 2009
Andrei Alexandrescu wrote:
> Lars T. Kyllingstad 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
>>
>> This is looking very nice! I want to switch from D1 to D2, but...
>>
>> I don't want to sound greedy or anything, and I know others have asked for this before, but is making a 64-bit Linux version of DMD a lot of work?
> 
> I would kill for a 64-bit Linux DMD. [...]

Who does one have to kill to get a 64-bit compiler around here? :)

But seriously, now that the language itself is stabilising, I would consider this a major priority for further development of DMD. 64 bits is the (immediate) future.

-Lars
April 21, 2009
Lutger wrote:
> Daniel Keep wrote:
> 
> ...
>>> -Lars
>> The best bet for 64-bit D executables at this point is probably LDC;
>> dunno what the current state is, though.
>>
>>   -- Daniel
> 
> if you grep the dmd backend sources for x86_64, you'll get some results. Don't know what that means though, the source looks like magic to me!
> 
> 
They're just part of the standard OBJ file format. Nothing to do with code generation. Much more fun is:
$ cd src/dmd
$ grep "goto " * -R
April 21, 2009
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

Missing from the changelog:

From 2.208:
2804 Impure nested functions should be legal inside pure functions

From 2.209:
std.math:
Intrinsics std.math.yl2x and yl2xp1 added. Improves performance of std.math.log() and similar functions (and they are now pure nothrow).

(Yes, I know, not very exciting compared to Andrei's new Phobos <g>).
April 21, 2009
Don wrote:

> Lutger wrote:
>> Daniel Keep wrote:
>> 
>> ...
>>>> -Lars
>>> The best bet for 64-bit D executables at this point is probably LDC; dunno what the current state is, though.
>>>
>>>   -- Daniel
>> 
>> if you grep the dmd backend sources for x86_64, you'll get some results. Don't know what that means though, the source looks like magic to me!
>> 
>> 
> They're just part of the standard OBJ file format. Nothing to do with
> code generation. Much more fun is:
> $ cd src/dmd
> $ grep "goto " * -R

 you forgot " | less" there, what the hell...this code can't be human.


April 21, 2009
Georg Wrede, el 21 de abril a las 09:25 me escribiste:
> What's sad, http://en.wikipedia.org/wiki/Standard_Template_Library
> really sucks at introducing the STL on a conceptual level. Even worse, that is
> actually the only thing it *should* do. Everyting else is optional.

You should improve it then =)

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
April 21, 2009
Don:
>  From 2.208:
> 2804 Impure nested functions should be legal inside pure functions

Very good. Now that little example works:

import std.c.stdio: printf;
import std.conv: to;

pure int double_sqr(int x) {
    int y, z;
    void do_sqr() { y *= y; }
    y = x;
    do_sqr();
    z += y;
    y = x;
    do_sqr();
    z += y;
    return z;
}

void main(string[] args) {
    int x = args.length == 2 ? to!(int)(args[1]) : 10;
    int y = double_sqr(x) + double_sqr(x);
    printf("4 * x * x = %d\n", y);
}

The outout is correct:
4 * x * x = 400


"Cleaned up" ASM produced by DMD V.2.029, -O -release -inline:

double_sqr:
        push    EAX
        mov ECX,EAX
        mov [ESP],0
        mov [ESP],ECX
        imul    EAX,[ESP]
        mov EDX,EAX
        mov [ESP],EAX
        mov EAX,ECX
        mov [ESP],ECX
        imul    EAX,[ESP]
        add EDX,EAX
        mov [ESP],EAX
        mov EAX,EDX
        pop ECX
        ret

double_sqr.do_sqr:
        mov ECX,[EAX]
        imul    ECX,[EAX]
        mov [EAX],ECX
        ret

main:
L0:     sub ESP,014h
        cmp dword ptr 018h[ESP],2
        jne L21
        mov EDX,01Ch[ESP]
        mov EAX,018h[ESP]
        mov EAX,8[EDX]
        mov EDX,0Ch[EDX]
        push    EDX
        push    EAX
        call    near ptr parseString
        jmp short   L26
L21:        mov EAX,0Ah
L26:        call    near ptr double_sqr
        add EAX,EAX
        mov ECX,offset FLAT:_DATA
        push    EAX
        push    ECX
        call    near ptr printf

As you can see there's only one call to double_sqr in the main program, so the pure semantics is working here.

You can also see do_sqr is inlined into double_sqr. But the asm code inside double_sqr looks very hairy and long, and double_sqr itself isn't inlined in the main.

Bye,
bearophile
April 21, 2009
Andrei Alexandrescu, el 21 de abril a las 07:38 me escribiste:
> Lars T. Kyllingstad 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
> >This is looking very nice! I want to switch from D1 to D2, but...
> >I don't want to sound greedy or anything, and I know others have asked for this
> >before, but is making a 64-bit Linux version of DMD a lot of work?
> 
> I would kill for a 64-bit Linux DMD. I think it could take a lot of ways of coding to a whole new level. Sean and I have also been discussing how to integrate memory-mapped files with the garbage collector. In a 64-bit environment this makes for an awesome programming model.

Can you elaborate on that?

Thanks.

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
April 21, 2009
I have tried the following code:

import std.c.stdio: printf;
import std.conv: to;

nothrow pure int double_sqr(int x) { // line 4
    int y, z;
    nothrow void do_sqr() { y *= y; }
    y = x;
    do_sqr();
    z += y;
    y = x;
    do_sqr();
    z += y;
    return z;
}

void main(string[] args) {
    int x = args.length == 2 ? to!(int)(args[1]) : 10;
    int y = double_sqr(x) + double_sqr(x);
    printf("4 * x * x = %d\n", y);
}

The compiler spits the following error:

pure_impure_test.d(4): Error: function pure_impure_test.double_sqr 'double_sqr' is nothrow yet may throw

but I don't understand why. What are the things inside it that can throw an exception?

Bye,
bearophile