Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 18, 2006 C-style function pointer syntax supported? | ||||
---|---|---|---|---|
| ||||
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 Re: C-style function pointer syntax supported? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | 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 Re: C-style function pointer syntax supported? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | "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 Re: C-style function pointer syntax supported? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | 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)()
|
Copyright © 1999-2021 by the D Language Foundation