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);

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: Formating decimal numbers with commas (1,000.00)

2010-09-15 Thread Steven Schveighoffer
On Tue, 14 Sep 2010 20:12:53 -0400, Stewart Gordon wrote: On 14/09/2010 21:00, jicman wrote: Greetings. I have been trying, for more than an hour, to get information on how to format a number (2342.23) to $2,342.23. Just wondering, where have you been searching for this information? I

Re: Compile time range checking/asserts

2010-09-15 Thread bearophile
> - Doesn't act transparently as a int subclass; > - Syntax-wise it's longer to define; > - The invariant is not enforced in all situations. And the compiler in most situations doesn't "run" the invariant at compile time (unless you define an enum). Well, a test shows that it doesn't work (dmd 2

Re: Compile time range checking/asserts

2010-09-15 Thread bearophile
Borden Rhodes: > int gear {1...6} = 1; I think Walter said that Ranged Types are a "failed feature" of Pascal/Ada lineage, but I don't agree and I think they are useful to increase code safety, a possible syntax from yours: typedef int { 1 ... 6 } Gear; Using a struct with "alias this" and a s

Re: Formating decimal numbers with commas (1,000.00)

2010-09-15 Thread bearophile
jicman: > Way over my head. :-) Thanks, though. It's not that complex. Try to comment out most of the code and add some prints. IsType is a recursive template missing in Phobos2 too, it returns true if the first type is any of the following ones, you may remove it if you aren't able to write