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 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: Translation of C function pointer.

2010-09-17 Thread Simen kjaeraas
Jonathan M Davis 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 anyway. It just d

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 t

Re: Translation of C function pointer.

2010-09-17 Thread Jonathan M Davis
On Friday, September 17, 2010 10:43:12 Ali Çehreli wrote: > 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, pos

Re: Translation of C function pointer.

2010-09-17 Thread Jonathan M Davis
On Friday, September 17, 2010 05:00:55 Simen kjaeraas wrote: > On Fri, 17 Sep 2010 10:12:34 +0200, 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 d

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 h

Re: Translation of C function pointer.

2010-09-17 Thread Simen kjaeraas
On Fri, 17 Sep 2010 10:12:34 +0200, 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 t

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

Re: Translation of C function pointer.

2010-09-16 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 a

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 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 BCS
Hello Steven, On Thu, 16 Sep 2010 10:06:24 -0400, 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*, c

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 Steven Schveighoffer
On Thu, 16 Sep 2010 10:06:24 -0400, 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

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-15 Thread Yao G.
On Wed, 15 Sep 2010 16:15:12 -0500, Steven Schveighoffer 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*/); pragma(msg, typeof(xDlSym).str

Re: Translation of C function pointer.

2010-09-15 Thread Steven Schveighoffer
On Wed, 15 Sep 2010 17:05:24 -0400, Yao G. 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 another function pointer

Re: Translation of C function pointer.

2010-09-15 Thread Steven Schveighoffer
On Wed, 15 Sep 2010 17:15:12 -0400, Steven Schveighoffer wrote: On Wed, 15 Sep 2010 17:05:24 -0400, Yao G. 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);