Re: static code generation

2012-12-15 Thread r_m_r
On 12/16/2012 12:08 PM, anonymous wrote: Foo.s1alpha and Bar.s1alpha are the same type. In my version they are not. OK. Fair Enough :-)

Re: static code generation

2012-12-15 Thread anonymous
On Saturday, 15 December 2012 at 16:32:27 UTC, r_m_r wrote: On 12/15/2012 08:57 PM, anonymous wrote: Note that here s1alpha and s2alpha are distinct types. what about this: http://dpaste.dzfl.pl/95f7a74d Consider struct Foo {mixin (genStruct!("s1"));} struct Bar {mixin (genStruct!("s1"));}

Re: Cross Compiler Lniux to Win32

2012-12-15 Thread Nekroze
On Saturday, 15 December 2012 at 19:46:11 UTC, Johannes Pfau wrote: Am Sat, 15 Dec 2012 14:56:47 +0100 schrieb "Nekroze" : On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote: > On 12/15/2012 06:35 PM, Nekroze wrote: >> So straight up, is DMD capable of cross compiling on linux >> targe

Re: static code generation

2012-12-15 Thread r_m_r
On 12/16/2012 06:36 AM, r_m_r wrote: this is the closest I can get: http://dpaste.dzfl.pl/9d11d060 Cleaned up a bit: http://dpaste.dzfl.pl/d9f001db regards, r_m_r

Re: static code generation

2012-12-15 Thread r_m_r
On 12/16/2012 05:30 AM, js.mdnq wrote: and mixin the UserStruct.S with the MasterStruct_A this is the closest I can get: http://dpaste.dzfl.pl/9d11d060 regards, r_m_r

Re: static code generation

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 23:04:37 UTC, r_m_r wrote: On 12/16/2012 04:00 AM, js.mdnq wrote: Now, the next step is to be able to "insert" code into the struct! ;) how about this: http://dpaste.dzfl.pl/8161d00a regards, r_m_r No, it's backwards! ;) Or, sort of what one wants to do is:

Re: static code generation

2012-12-15 Thread r_m_r
On 12/16/2012 04:00 AM, js.mdnq wrote: Now, the next step is to be able to "insert" code into the struct! ;) how about this: http://dpaste.dzfl.pl/8161d00a regards, r_m_r

Re: alias type reduction

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 22:21:21 UTC, Philippe Sigaud wrote: If you don't mind, could you see if your solutions work on the following code: http://dpaste.dzfl.pl/64025e0a What you're doing here is a bit different (AFAICT). _A is a template, not a 'real' class. So, it has no classinf

Re: static code generation

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 19:09:25 UTC, r_m_r wrote: On 12/10/2012 01:24 AM, js.mdnq wrote: which will fail or not be what I want, since I want to generate the structs s1 and s1. how about this: http://dpaste.dzfl.pl/c0325def regards, r_m_r Cool, That looks like a step in the right

Re: Why are const strings used in templates for compile time found in exe

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 13:16:17 UTC, anonymous wrote: On Saturday, 15 December 2012 at 13:08:01 UTC, js.mdnq wrote: The following code http://dpaste.dzfl.pl/64025e0a when compiled, has all the static and const char[] strings used only for compile time inside the executable. How t

Re: alias type reduction

2012-12-15 Thread Philippe Sigaud
> If you don't mind, could you see if your solutions work on the following > code: > > http://dpaste.dzfl.pl/64025e0a > > What you're doing here is a bit different (AFAICT). _A is a template, not a 'real' class. So, it has no classinfo. The only real type here is the template instantiation you call

Re: std.math.approxEqual, 'maxRelDiff' parameter?

2012-12-15 Thread ref2401
now i got it, thanks.

Re: Get class type parameters at compile time

2012-12-15 Thread Philippe Sigaud
> > Oops ;/ How do I get the number of type arguments if I don't know them > yet? I know this sort of seems wrong but somehow, to know how to alias the > class I need to know it's number of arguments. (I don't think it makes too > much sense with the type system but not sure how to solve the follow

Re: std.math.approxEqual, 'maxRelDiff' parameter?

2012-12-15 Thread Ali Çehreli
On 12/15/2012 11:01 AM, ref2401 wrote: What does means 'maxRelDiff' parameter? I looked at the source code of this method and I still didn't get it. return fabs((lhs - rhs) / rhs) <= maxRelDiff || maxAbsDiff != 0 && fabs(lhs - rhs) <= maxAbsDiff; In what cases can I use this parameter? If you

Re: std.math.approxEqual, 'maxRelDiff' parameter?

2012-12-15 Thread ref2401
Maybe you want to use std.math.feqrel instead. that's not what i was asking about

Re: Cross Compiler Lniux to Win32

2012-12-15 Thread Johannes Pfau
Am Sat, 15 Dec 2012 14:56:47 +0100 schrieb "Nekroze" : > On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote: > > On 12/15/2012 06:35 PM, Nekroze wrote: > >> So straight up, is DMD capable of cross compiling on linux > >> targeting > >> windows? I have never used the alternative D compiler

Re: std.math.approxEqual, 'maxRelDiff' parameter?

2012-12-15 Thread bearophile
ref2401: What does means 'maxRelDiff' parameter? I looked at the source code of this method and I still didn't get it. return fabs((lhs - rhs) / rhs) <= maxRelDiff || maxAbsDiff != 0 && fabs(lhs - rhs) <= maxAbsDiff; In what cases can I use this parameter? Maybe you want to use std.math.fe

Re: static code generation

2012-12-15 Thread r_m_r
On 12/10/2012 01:24 AM, js.mdnq wrote: which will fail or not be what I want, since I want to generate the structs s1 and s1. how about this: http://dpaste.dzfl.pl/c0325def regards, r_m_r

std.math.approxEqual, 'maxRelDiff' parameter?

2012-12-15 Thread ref2401
What does means 'maxRelDiff' parameter? I looked at the source code of this method and I still didn't get it. return fabs((lhs - rhs) / rhs) <= maxRelDiff || maxAbsDiff != 0 && fabs(lhs - rhs) <= maxAbsDiff; In what cases can I use this parameter?

Re: opDispatch bug?

2012-12-15 Thread Zhenya
On Saturday, 15 December 2012 at 18:09:00 UTC, Ali Çehreli wrote: On 12/15/2012 10:07 AM, Ali Çehreli wrote: > Otherwise any type would go to opDispatch. Wow. I made a typo in typo. :) That should be: Otherwise any _typo_ would go to opDispatch. Ali It's pretty reasonable,thank you.

Re: opDispatch bug?

2012-12-15 Thread Ali Çehreli
On 12/15/2012 10:07 AM, Ali Çehreli wrote: > Otherwise any type would go to opDispatch. Wow. I made a typo in typo. :) That should be: Otherwise any _typo_ would go to opDispatch. Ali

Re: opDispatch bug?

2012-12-15 Thread Ali Çehreli
On 12/15/2012 10:01 AM, Zhenya wrote: Hi! Is it a bug? class Foo { int m_bar; char m_gun; @property auto ref opDispatch(string s)() { return mixin("m_"~s); } this(int i,char c) { bar = i;//Error: undefined identifier bar, did you mean variable m_bar? this.bar = i; Because when it is s

opDispatch bug?

2012-12-15 Thread Zhenya
Hi! Is it a bug? class Foo { int m_bar; char m_gun; @property auto ref opDispatch(string s)() { return mixin("m_"~s); } this(int i,char c) { bar = i;//Error: undefined identifier bar, did you mean variable m_bar?

Re: static code generation

2012-12-15 Thread r_m_r
On 12/15/2012 08:57 PM, anonymous wrote: Note that here s1alpha and s2alpha are distinct types. what about this: http://dpaste.dzfl.pl/95f7a74d regards, r_m_r

Re: static code generation

2012-12-15 Thread anonymous
On Saturday, 15 December 2012 at 15:15:21 UTC, r_m_r wrote: On 12/10/2012 01:43 AM, anonymous wrote: Maybe it helps if you see it in action: http://dpaste.dzfl.pl/5d4cb742 Note that here s1alpha and s2alpha are distinct types. Here's a slightly modified version: http://dpaste.dzfl.pl/f2bd142

Re: static code generation

2012-12-15 Thread r_m_r
On 12/10/2012 01:43 AM, anonymous wrote: Maybe it helps if you see it in action: http://dpaste.dzfl.pl/5d4cb742 Here's a slightly modified version: http://dpaste.dzfl.pl/f2bd1428 regards, r_m_r

Re: Cross Compiler Lniux to Win32

2012-12-15 Thread David
Am 15.12.2012 14:56, schrieb Nekroze: > On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote: >> On 12/15/2012 06:35 PM, Nekroze wrote: >>> So straight up, is DMD capable of cross compiling on linux targeting >>> windows? I have never used the alternative D compilers (GDC, LDC etc) >>> but ar

Re: Cross Compiler Lniux to Win32

2012-12-15 Thread Nekroze
On Saturday, 15 December 2012 at 13:42:11 UTC, r_m_r wrote: On 12/15/2012 06:35 PM, Nekroze wrote: So straight up, is DMD capable of cross compiling on linux targeting windows? I have never used the alternative D compilers (GDC, LDC etc) but are they capable of this perhaps? You can try: htt

Re: Cross Compiler Lniux to Win32

2012-12-15 Thread r_m_r
On 12/15/2012 06:35 PM, Nekroze wrote: So straight up, is DMD capable of cross compiling on linux targeting windows? I have never used the alternative D compilers (GDC, LDC etc) but are they capable of this perhaps? You can try: http://gdcproject.org/wiki/Cross%20Compiler check this thread for

Re: Cross Compiler Lniux to Win32

2012-12-15 Thread Nekroze
On Saturday, 15 December 2012 at 13:05:32 UTC, Nekroze wrote: I have been thinking about starting a project recently to using llvm to make a little toy compiler however I quite dislike mingw and such on windows so was going to build a gcc cross compiler and try to make it so I can code and comp

Re: Why are const strings used in templates for compile time found in exe

2012-12-15 Thread anonymous
On Saturday, 15 December 2012 at 13:08:01 UTC, js.mdnq wrote: The following code http://dpaste.dzfl.pl/64025e0a when compiled, has all the static and const char[] strings used only for compile time inside the executable. How to prevent this? specifically I'm talking about static const cha

Cross Compiler Lniux to Win32

2012-12-15 Thread Nekroze
I have been thinking about starting a project recently to using llvm to make a little toy compiler however I quite dislike mingw and such on windows so was going to build a gcc cross compiler and try to make it so I can code and compile my win32 compiler (the compiler will be an exe and the cod

Re: Compile time string manipulation

2012-12-15 Thread js.mdnq
On Saturday, 15 December 2012 at 12:33:13 UTC, bearophile wrote: js.mdnq: static if (std.string.indexOf(S, ")") < -1) ... else ... This always returns false regardless if S contains a 7 or not. If it doesn't find the substring it returns -1, so that's always false. So use: S.indexOf("

Re: Compile time string manipulation

2012-12-15 Thread bearophile
js.mdnq: static if (std.string.indexOf(S, ")") < -1) ... else ... This always returns false regardless if S contains a 7 or not. If it doesn't find the substring it returns -1, so that's always false. So use: S.indexOf(")") < 0 Bye, bearophile

Re: Extensions to types loaded from a C library

2012-12-15 Thread Jacob Carlborg
On 2012-12-15 07:26, Jeremy DeHaan wrote: Thus it appears that any extensions made to the types defined in a C library is not safe! Even one as trivial as a constructor. I didn't show the code or output(it was with some different tests), but I also got some run time errors when using the version

Re: contracts in interfaces

2012-12-15 Thread Yann
Thanks for your reply! I'll investigate further and report a bug if necessary.

Compile time string manipulation

2012-12-15 Thread js.mdnq
How do we manipulate strings at compile time when using static ifs? static if (std.string.indexOf(S, ")") < -1) ... else ... This always returns false regardless if S contains a 7 or not. from http://dpaste.dzfl.pl/64025e0a mixin(StructNestType!("B", "b1")); but I would like to modi