Re: Translation of C function pointer.

2010-09-17 Thread Kagamin
BCS Wrote: The trick is that function pointers are best read from the inside out. -- All C declarations are read from inside out, postfixes take precedence, that's why you have to use braces to give pointer higher precedence. One of the earlier books by Stroustroup gives a nice monster of

Re: Translation of C function pointer.

2010-09-17 Thread Jonathan M Davis
On Thursday 16 September 2010 23:50:16 Kagamin wrote: BCS Wrote: The trick is that function pointers are best read from the inside out. All C declarations are read from inside out, postfixes take precedence, that's why you have to use braces to give pointer higher precedence. One of the

Re: Translation of C function pointer.

2010-09-17 Thread Simen kjaeraas
On Fri, 17 Sep 2010 10:12:34 +0200, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday 16 September 2010 23:50:16 Kagamin wrote: BCS Wrote: The trick is that function pointers are best read from the inside out. All C declarations are read from inside out, postfixes take precedence,

Re: Translation of C function pointer.

2010-09-17 Thread Ali Çehreli
Jonathan M Davis wrote: On Thursday 16 September 2010 23:50:16 Kagamin wrote: BCS Wrote: The trick is that function pointers are best read from the inside out. All C declarations are read from inside out, postfixes take precedence, that's why you have to use braces to give pointer higher

Re: Translation of C function pointer.

2010-09-17 Thread Jesse Phillips
Jonathan M Davis Wrote: On Friday, September 17, 2010 10:43:12 Ali Çehreli wrote: int[4] is an array of 4 ints; like Simen, let's call it U. Now U[3] is an array of 3 Us; i.e. 3 int[4]s I read that from left to right, not inside out. No, no. You read it outwards from the variable

Re: Translation of C function pointer.

2010-09-17 Thread Simen kjaeraas
Jonathan M Davis jmdavisp...@gmx.com wrote: I've always been confused by C in this regard. It seems to logical to me that T[3] works the same whether T is U[4] or U. You're going to have to elaborate on that. I'm not quite sure what you're talking about. And the syntax int[4][3] isn't legal C

Re: Translation of C function pointer.

2010-09-17 Thread Jonathan M Davis
On Friday, September 17, 2010 17:07:15 Simen kjaeraas wrote: Jonathan M Davis jmdavisp...@gmx.com wrote: I've always been confused by C in this regard. It seems to logical to me that T[3] works the same whether T is U[4] or U. You're going to have to elaborate on that. I'm not quite sure

Re: Translation of C function pointer.

2010-09-16 Thread BCS
Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs: void function() function(sqlite3_vfs*, void*, const const(char*) zSymbol) D, now with C type un-garbleing!

Re: Translation of C function pointer.

2010-09-16 Thread Steven Schveighoffer
On Thu, 16 Sep 2010 10:06:24 -0400, BCS n...@anon.com wrote: Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs: void function() function(sqlite3_vfs*, void*,

Re: Translation of C function pointer.

2010-09-16 Thread Stewart Gordon
On 16/09/2010 15:06, BCS wrote: Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs: void function() function(sqlite3_vfs*, void*, const const(char*) zSymbol) D,

Re: Translation of C function pointer.

2010-09-16 Thread BCS
Hello Steven, On Thu, 16 Sep 2010 10:06:24 -0400, BCS n...@anon.com wrote: Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs: void function()

Re: Translation of C function pointer.

2010-09-16 Thread Stewart Gordon
On 16/09/2010 15:37, Steven Schveighoffer wrote: On Thu, 16 Sep 2010 10:06:24 -0400, BCS n...@anon.com wrote: Hello Steven, // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/); pragma(msg, typeof(xDlSym).stringof); outputs:

Translation of C function pointer.

2010-09-15 Thread Yao G.
Hello gentlemen: I'm trying to translate the newest SQLite C header to D, and I stumbled unto this gem: void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); What's that? A function pointer that takes another function pointer as its name? I'm stuck at this and I don't know how

Re: Translation of C function pointer.

2010-09-15 Thread Steven Schveighoffer
On Wed, 15 Sep 2010 17:05:24 -0400, Yao G. yao.go...@spam.gmail.com wrote: Hello gentlemen: I'm trying to translate the newest SQLite C header to D, and I stumbled unto this gem: void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); What's that? A function pointer that takes

Re: Translation of C function pointer.

2010-09-15 Thread Steven Schveighoffer
On Wed, 15 Sep 2010 17:15:12 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Wed, 15 Sep 2010 17:05:24 -0400, Yao G. yao.go...@spam.gmail.com wrote: Hello gentlemen: I'm trying to translate the newest SQLite C header to D, and I stumbled unto this gem: void

Re: Translation of C function pointer.

2010-09-15 Thread Yao G.
On Wed, 15 Sep 2010 16:15:12 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: D supports C-style function pointers. See here: typedef char sqlite3_vfs; // note you can't use void as a parameter type in D void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/);