Re: Facing problems with Class Properties

2010-12-13 Thread Steven Schveighoffer
On Fri, 10 Dec 2010 20:22:52 -0500, d coder wrote: Another thing, is(T : U) simply means T is implicitly castable to U. Due to a compiler bug, Bar[] is implicitly castable to BaseClass[]. Steve I realize that I am using this compiler bug as a feature. It would be kind of you to suggest m

Re: Facing problems with Class Properties

2010-12-10 Thread spir
On Sat, 11 Dec 2010 06:11:43 +0530 d coder wrote: > > if(false) { > >    for (size_t j = 0; j < f.length...) > >    ... > > } > > > > Semantically this code is wrong as you can't take the length of f which is > > class Bar. The static if forces the compiler to not generate this code as > > it i

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
d coder Wrote: > > Ah.. Now I think I understand. > > > > This new code I have written will all be run at compile time. So in > > this case, the foreach statement inside the constructor would be > > reduced to a bunch of writeln statements at compile time and those > > writeln would be executed at

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> Ah.. Now I think I understand. > > This new code I have written will all be run at compile time. So in > this case, the foreach statement inside the constructor would be > reduced to a bunch of writeln statements at compile time and those > writeln would be executed at the run time. This will not

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> Another thing, is(T : U) simply means T is implicitly castable to U.  Due to > a compiler bug, Bar[] is implicitly castable to BaseClass[]. > Steve I realize that I am using this compiler bug as a feature. It would be kind of you to suggest me a code that would not exploit this bug. I was think

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> What you are saying makes sense to me. The problem is that the > following code works perfectly. I have just commented out some part > and replaced it with some debug statements. Ah.. Now I think I understand. This new code I have written will all be run at compile time. So in this case, the fo

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> Is there a reason you can't directly reference the members?  After all, you > are writing the class. > Thanks Steve for your inputs. Actually this is part of a bigger code that I am trying to create. Though I am pretty new to D. What I have posted is a reduced code that illustrated the issue I

Re: Facing problems with Class Properties

2010-12-10 Thread d coder
> if(false) { >    for (size_t j = 0; j < f.length...) >    ... > } > > Semantically this code is wrong as you can't take the length of f which is > class Bar. The static if forces the compiler to not generate this code as it > is known to be false. > Thanks Jesse What you are saying makes sens

Re: Facing problems with Class Properties

2010-12-10 Thread Steven Schveighoffer
On Fri, 10 Dec 2010 15:08:34 -0500, Jesse Phillips wrote: Jesse Phillips Wrote: typeof() and is() are compile time constructs. Change your if statements to static if. Just realized what the issue is. You are creating code as foreach becomes a static foreach when iterating a tupleof. (

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
Jesse Phillips Wrote: > typeof() and is() are compile time constructs. Change your if statements to > static if. Just realized what the issue is. You are creating code as foreach becomes a static foreach when iterating a tupleof. (Yes steven it does work) This you are building code which looks

Re: Facing problems with Class Properties

2010-12-10 Thread Jesse Phillips
d coder Wrote: > The issue is that when I try to compile the program, I get the error > bug.d(10): Error: no property 'length' for type 'test.Bar' > > I am explicitly checking the field type, and I am making sure that the field > is an array type, before looking for its length. So I am not sure w

Re: Facing problems with Class Properties

2010-12-10 Thread Steven Schveighoffer
On Fri, 10 Dec 2010 11:35:50 -0500, d coder wrote: Greetings All I am trying to compile the following D2 code. The code giving compilation issues is the "this()" function of the class Foo. The constructor basically tries to initialize all the data members of the class, of type BaseClass an

Facing problems with Class Properties

2010-12-10 Thread d coder
Greetings All I am trying to compile the following D2 code. The code giving compilation issues is the "this()" function of the class Foo. The constructor basically tries to initialize all the data members of the class, of type BaseClass and of type BaseClass array. I am using class property tuple