www.digitalmars.com         C & C++   DMDScript  

D - function references

reply "Dario" <supdar yahoo.com> writes:
Hi,
I discovered D only 3 days ago and I liked it very much.
So I downloaded the compiler and tried to write some code.

Anyway the sintax for function pointers similar to the C's one:

import c.stdio;

void function(int a, float b)
{
    printf("%i %f" \n, a, b);
}

int main(char[][] args)
{
    void (* ptr)(int, float); // bleah!
    ptr = & function;
    ptr(1, 2.0);
    return 0;
}

This looks very complicated and should be changed.
According to me, the following is better:

int main(char[][] args)
{
    void(int, float) ref = function;
    ref(1, 2.0);
    return 0;
}

This helps very much the understanding of the code, I think.
Also multiple function references could be written in just a line:

void(int, float) a, b, c;

Thanks for your attention.
    Dario
May 09 2002
parent "Pavel Minayev" <evilone omen.ru> writes:
"Dario" <supdar yahoo.com> wrote in message
news:abdq9k$4c3$1 digitaldaemon.com...

 void(int, float) a, b, c;
It was suggested by several people already (including me). But Walter says, it's not so important to touch, for now... =) But at least delegates follow this syntax: void delegate(int, float) a, b, c;
May 09 2002