D-

Daniel Murphy yebblies at nospamgmail.com
Mon Feb 13 07:31:19 PST 2012


"Iain Buclaw" <ibuclaw at ubuntu.com> wrote in message 
news:mailman.287.1329145247.20196.digitalmars-d at puremagic.com...
>
> O_O

=) Which bit's making you pull that face?  Is it the fact I think it might 
be a good idea or the fact I think it wouldn't be that hard?

It currently can translate:


import core.stdc.stdio;

__gshared int global = 3;

struct S
{
    int a;
    void fun()
    {
        printf("member a: %d\n", a);
    }
}

int main()
{
    uint x;
    foreach(i; 0..20)
    {
        x += i;
    }

    printf("%d\n", x);

    S y = S(7);
    y.a += 5;
    y.fun();
    return 0;
}

into



typedef struct __d_5testx1S __d_5testx1S;

__d_int _D5testx6globali;
struct __d_5testx1S
{
__d_int _D5testx1S1ai;
};
__d_int _Dmain();
__d_void _D5testx1S3funMFZv(__d_5testx1S* _D5testx1S3funMFZv4thisS5testx1S);

__d_int _D5testx6globali = 3;
__d_int _Dmain()
{
__d_uint _D5testx4mainFZi1xk = 0u;
for (__d_int _D5testx4mainFZi1ii = 0, _D5testx4mainFZi8__limit3i = 20;
(_D5testx4mainFZi1ii < _D5testx4mainFZi8__limit3i); (_D5testx4mainFZi1ii += 
1))
(_D5testx4mainFZi1xk += ((__d_uint)_D5testx4mainFZi1ii));
printf("%d\x0a", _D5testx4mainFZi1xk);
__d_5testx1S _D5testx4mainFZi1yS5testx1S = {7};
((_D5testx4mainFZi1yS5testx1S)._D5testx1S1ai += 5);
_D5testx1S3funMFZv(&_D5testx4mainFZi1yS5testx1S);
return 0;
}
__d_void _D5testx1S3funMFZv(__d_5testx1S* _D5testx1S3funMFZv4thisS5testx1S)
{
&*_D5testx1S3funMFZv4thisS5testx1S || __d_assert_msg(__d_array("null this", 
9), __d_array("testx.d", 7), 9);;
printf("member a: %d\x0a", 
(*_D5testx1S3funMFZv4thisS5testx1S)._D5testx1S1ai);
}


Looking at that, it seems I'd forgotten just how ugly C really is. 




More information about the Digitalmars-d mailing list