Thread overview
C-style function pointer syntax supported?
Jan 18, 2006
Sean Kelly
Jan 18, 2006
John Reimer
Jan 18, 2006
Ameer Armaly
Jan 19, 2006
Don Clugston
January 18, 2006
I just noticed this last night:

alias void (*t1)();
alias void function() t2;

void fn() {}

void main()
{
    t1 f = &fn;
    t2 g = &fn;
}

This compiles just fine.  Is the C syntax supported to ease porting or is it an artifact of a bygone day?  Should the syntax be deprecated?


Sean
January 18, 2006
Sean Kelly wrote:
> I just noticed this last night:
> 
> alias void (*t1)();
> alias void function() t2;
> 
> void fn() {}
> 
> void main()
> {
>     t1 f = &fn;
>     t2 g = &fn;
> }
> 
> This compiles just fine.  Is the C syntax supported to ease porting or is it an artifact of a bygone day?  Should the syntax be deprecated?
> 
> 
> Sean


I know the C syntax has been supported for awhile in D.  It certainly makes header conversion much easier.  Yet, I prefer the clarity of the D style; when I port C code to D, I almost always convert the function pointers to the D style as well.

-JJR
January 18, 2006
"Sean Kelly" <sean@f4.ca> wrote in message news:dqltqq$125l$1@digitaldaemon.com...
>I just noticed this last night:
>
> alias void (*t1)();
> alias void function() t2;
>
> void fn() {}
>
> void main()
> {
>     t1 f = &fn;
>     t2 g = &fn;
> }
>
> This compiles just fine.  Is the C syntax supported to ease porting or is it an artifact of a bygone day?  Should the syntax be deprecated?
>
I would support depricating it, since the D syntax is much more explicit and clear.
>
> Sean


January 19, 2006
Sean Kelly wrote:
> I just noticed this last night:
> 
> alias void (*t1)();
> alias void function() t2;
> 
> void fn() {}
> 
> void main()
> {
>     t1 f = &fn;
>     t2 g = &fn;
> }
> 
> This compiles just fine.  Is the C syntax supported to ease porting or is it an artifact of a bygone day?  Should the syntax be deprecated?
> 
> 
> Sean

At the very least, the D syntax should be the one used in error messages. It's a bit silly that an error message involving t2 will describe it as

void (*t2)()