compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Tobias Pankrath
Hi everyone, I'm taking a look at D again and asked myself, if it is possible to write a template mixin or something similiar that automatically serializes an object to json. For example: class MyClass { string memberA; int memberB; MyClass memberC; mixin ToJson!MyClass; } sho

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Robert Clipsham
On 21/07/2011 08:57, Tobias Pankrath wrote: Hi everyone, I'm taking a look at D again and asked myself, if it is possible to write a template mixin or something similiar that automatically serializes an object to json. For example: class MyClass { string memberA; int memberB; My

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Robert Clipsham
On 21/07/2011 08:57, Tobias Pankrath wrote: Hi everyone, I'm taking a look at D again and asked myself, if it is possible to write a template mixin or something similiar that automatically serializes an object to json. For example: class MyClass { string memberA; int memberB; My

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Jacob Carlborg
On 2011-07-21 09:57, Tobias Pankrath wrote: Hi everyone, I'm taking a look at D again and asked myself, if it is possible to write a template mixin or something similiar that automatically serializes an object to json. For example: class MyClass { string memberA; int memberB; My

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Tobias Pankrath
> > Have a look at Orange: http://www.dsource.org/projects/orange > I'm in a middle of a complete rewrite but you can use a previous version > (if it still works) or look at the code. > Thank you for pointing me there. Looks very interesting. I took a quick look at the code and got some question

Re: Infer purity of functions too?

2011-07-21 Thread Mafi
Am 21.07.2011 02:01, schrieb bearophile: Jonathan M Davis: I believe that there is some level of purity inference with delegates, but I don't know what the situation with that is exactly. I didn't know/remember this, but it seems you are right, delegates too seem to receive purity inference.

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Adam Ruppe
For another implementation, find the functions toJson and toJsonValue in my web.d http://arsdnet.net/dcode/web.d Bascially: foreach(member; item.tupleof) { static if(is(typeof(member) == something) json it else static if repeat for supported type families }

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Steven Schveighoffer
On Wed, 20 Jul 2011 15:57:44 -0400, Jonathan M Davis wrote: On Wednesday 20 July 2011 21:54:19 Andrej Mitrovic wrote: import std.stdio; void main() { writeln("test"); test(); writeln(); writeln("test"); test(); } struct Foo { int state; this (int i) {

Re: compile time introspection and code generation - automatically serialize to json

2011-07-21 Thread Jacob Carlborg
On 2011-07-21 13:09, Tobias Pankrath wrote: Have a look at Orange: http://www.dsource.org/projects/orange I'm in a middle of a complete rewrite but you can use a previous version (if it still works) or look at the code. Thank you for pointing me there. Looks very interesting. I took a quick lo

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Jonathan M Davis
On Thursday 21 July 2011 11:52:58 Steven Schveighoffer wrote: > On Wed, 20 Jul 2011 15:57:44 -0400, Jonathan M Davis > > wrote: > > On Wednesday 20 July 2011 21:54:19 Andrej Mitrovic wrote: > >> import std.stdio; > >> > >> void main() > >> { > >> > >> writeln("test"); > >> test(); > >>

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Steven Schveighoffer
On Thu, 21 Jul 2011 12:39:27 -0400, Jonathan M Davis wrote: However, I don't think that any destructors are called on thread destruction... That doesn't sound good. I may be wrong, a simple test should suffice. -Steve

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Andrej Mitrovic
On 7/21/11, Steven Schveighoffer wrote: > On Wed, 20 Jul 2011 15:57:44 -0400, Jonathan M Davis > wrote: > >> On Wednesday 20 July 2011 21:54:19 Andrej Mitrovic wrote: >>> import std.stdio; >>> >>> void main() >>> { >>> writeln("test"); >>> test(); >>> writeln(); >>> writeln("test"

Small problem with multi-line strings

2011-07-21 Thread bearophile
Multi-line strings are handy, but I have a small problem. This is an example, it has a problem, there is an unwanted newline at the beginning: writeln(" - First item: 150 - Second item: 200 - Third item: 105"); To avoid it you can write this, but both break the alignment in the source code,

Re: Small problem with multi-line strings

2011-07-21 Thread Nick Sabalausky
"bearophile" wrote in message news:j0ac3m$29hj$1...@digitalmars.com... > Multi-line strings are handy, but I have a small problem. > > This is an example, it has a problem, there is an unwanted newline at the > beginning: > > writeln(" > - First item: 150 > - Second item: 200 > - Third item: 1

Re: Small problem with multi-line strings

2011-07-21 Thread Andrej Mitrovic
writeln(q"EOS - First item: 150 - Second item: 200 - Third item: 105 EOS"); You can replace EOS with whatever you want.

Re: Small problem with multi-line strings

2011-07-21 Thread bearophile
Andrej Mitrovic: > writeln(q"EOS > - First item: 150 > - Second item: 200 > - Third item: 105 > EOS"); > > You can replace EOS with whatever you want. It seems to add a newline at the end :-( Bye, bearophile

Re: Small problem with multi-line strings

2011-07-21 Thread Andrej Mitrovic
This is the best I can do: writeln( `- First item: 150 - Second item: 200 - Third item: 105`); Hope OCD doesn't kick in! :p

How to get stack trace on Windows?

2011-07-21 Thread Nick Sabalausky
I'm not getting any of the function names on the stack traces. I tried everything I found in here: http://www.digitalmars.com/d/archives/digitalmars/D/Windows_Stack_Traces_Function_Names_136887.html - I installed the "Debugging Tools for Windows" to update my dbghelp.dll - I'm already compiling

Re: Small problem with multi-line strings

2011-07-21 Thread Diego Canuhé
if you can, use write instead of writeln write(q"EOS - First item: 150 - Second item: 200 - Third item: 105 EOS");

Re: Small problem with multi-line strings

2011-07-21 Thread Andrej Mitrovic
Followed by stdout.flush(); to be sure.

Re: Small problem with multi-line strings

2011-07-21 Thread Diego Canuhé
got one extra line, I meant write(q"EOS - First item: 150 - Second item: 200 - Third item: 105 EOS");

does the x64 compiler for linux make x64 executables?

2011-07-21 Thread McAnany, Charles E
Hi, all. So I see that there is an Ubuntu dmd that has "x86_64" as the "CPU" column. Before I install Ubuntu to great disappointment, does this mean that I get a 64 bit executable, or does it just mean that the compiler itself is a 64 bit application? Thanks, Charles.

Re: does the x64 compiler for linux make x64 executables?

2011-07-21 Thread Jonathan M Davis
On Friday 22 July 2011 04:45:59 McAnany, Charles E wrote: > Hi, all. > So I see that there is an Ubuntu dmd that has "x86_64" as the "CPU" column. > Before I install Ubuntu to great disappointment, does this mean that I get > a 64 bit executable, or does it just mean that the compiler itself is a 6

Re: does the x64 compiler for linux make x64 executables?

2011-07-21 Thread Nick Sabalausky
"McAnany, Charles E" wrote in message news:mailman.1844.1311309969.14074.digitalmars-d-le...@puremagic.com... >Hi, all. >So I see that there is an Ubuntu dmd that has "x86_64" as the "CPU" >column. Before I install Ubuntu to great disappointment, does this mean >that >I get a 64 bit executable,

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Diego Canuhé
Hi, I'm not really an experienced programmer so I might be missing something but... in http://d-programming-language.org/attribute.html static is described as follows: "The static attribute applies to functions and data. It means that the declaration does not apply to a particular instance of an

Need OMF MySQL lib that actually f^*&^ works...

2011-07-21 Thread Nick Sabalausky
Anyone have a known-working Windows OMF library for MySQL? Static or dynamic, I don't care. I've tried fucking everything and I can't get the dang thing to work. Static was a total no-go. With dynamic, using implib I got it to link, but calling any of it resulted in an Access Violation. Using c

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Jonathan M Davis
On Friday 22 July 2011 03:12:00 Diego Canuhé wrote: > Hi, > I'm not really an experienced programmer so I might be missing something > but... > > in > http://d-programming-language.org/attribute.html > static is described as follows: > > "The static attribute applies to functions and data. It mea

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Jacob Carlborg
On 2011-07-22 08:12, Diego Canuhé wrote: Hi, I'm not really an experienced programmer so I might be missing something but... in http://d-programming-language.org/attribute.html static is described as follows: "The static attribute applies to functions and data. It means that the declaration doe

Re: Why is a static struct's dtor called at the exit of a function?

2011-07-21 Thread Diego Canuhé
thanks ;)