Re: Type qualifiers - inout error

2011-06-17 Thread Jonathan M Davis
On 2011-06-16 16:01, Claudiu Verdes wrote: Hi, I'm new to D and trying to follow Alexandrescu's TDPL code examples I came across an error on the code below: class A { inout(int) val() inout { return _val; // error - see below } private int _val; }; The compiler (dmd v2.052)

Re: Type qualifiers - inout error

2011-06-17 Thread Steven Schveighoffer
On Thu, 16 Jun 2011 22:12:49 -0400, bearophile bearophileh...@lycos.com wrote: Claudiu Verdes: What am I doing wrong? TDPL has a very similar example... I think this TDPL example is not good. And generally inout is not fully implemented in D yet. Yes, a better example would be:

Re: Strange behavior when concatenating array

2011-06-17 Thread Steven Schveighoffer
On Fri, 17 Jun 2011 00:05:56 -0400, Jose Armando Garcia jsan...@gmail.com wrote: It looks like the rt is not calling the postblit constructor when concatenating arrays. For example, the following code: import std.stdio; struct Test { this(this) { writeln(copy done); } void

Re: Strange behavior when concatenating array

2011-06-17 Thread Steven Schveighoffer
On Fri, 17 Jun 2011 06:42:51 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: On Fri, 17 Jun 2011 00:05:56 -0400, Jose Armando Garcia jsan...@gmail.com wrote: It looks like the rt is not calling the postblit constructor when concatenating arrays. For example, the following code:

Re: smarter reflection issue

2011-06-17 Thread Jesse Phillips
Lloyd Dupont Wrote: Hi Jesse, this won't work! It's my fault in not explaining my problem well though... I forget to mention something... I'm using property syntax and try to call the method Say I have = private int _foo; @property public int Foo() { return _foo; } @property

Re: Strange behavior when concatenating array

2011-06-17 Thread Timon Gehr
Steven Schveighoffer wrote: https://github.com/D-Programming-Language/druntime/pull/29 See if that helps. On my system, your code now results in your expected output. -Steve If the compiler optimizes well enough the output given could be valid (it might construct the struct directly where

Init const fixed-sixed array in ctor

2011-06-17 Thread bearophile
This is a known bug, right? struct Foo { const char cc; const char[1] array; this(char c) { cc = c; // OK array[0] = c; // Error: this.array[0] isn't mutable } } void main() {} Bye, bearophile

Re: sort!(a b)( arr ); - opCmp

2011-06-17 Thread David Nadlinger
On 6/18/11 1:40 AM, Joel Christensen wrote: How do you override int opCmp( Object obj )? What can I do with obj? You can do pretty much whatever you want with it – obviously, you should not modify obj, because comparison is not generally expected to modify its arguments, but at the moment,

Re: Init const fixed-sixed array in ctor

2011-06-17 Thread Jonathan M Davis
On 2011-06-17 17:09, bearophile wrote: This is a known bug, right? struct Foo { const char cc; const char[1] array; this(char c) { cc = c; // OK array[0] = c; // Error: this.array[0] isn't mutable } } void main() {} You probably have to set the

Re: Init const fixed-sixed array in ctor

2011-06-17 Thread bearophile
Jonathan M Davis: Sure, it's a special case where setting that one element sets the whole array, but making that work would be special casing for such an array and complicate the compiler for little benefit. Don't worry, I have defined the array of length one just because I like to minimize

Re: sort!(a b)( arr ); - opCmp

2011-06-17 Thread Joel Christensen
Yeah, it works now. Thanks David :-) I have actually used type o = cast(type)variable; But had forgotten about it. Though the super part of what you said is more subtle.

Re: Strange behavior when concatenating array

2011-06-17 Thread Steven Schveighoffer
On Fri, 17 Jun 2011 18:52:05 -0400, Timon Gehr timon.g...@gmx.ch wrote: Steven Schveighoffer wrote: https://github.com/D-Programming-Language/druntime/pull/29 See if that helps. On my system, your code now results in your expected output. -Steve If the compiler optimizes well enough the

Re: Init const fixed-sixed array in ctor

2011-06-17 Thread Jonathan M Davis
On 2011-06-17 18:18, bearophile wrote: Jonathan M Davis: Sure, it's a special case where setting that one element sets the whole array, but making that work would be special casing for such an array and complicate the compiler for little benefit. Don't worry, I have defined the array

Re: smarter reflection issue

2011-06-17 Thread Lloyd Dupont
It helped! it's working now! :) Thanks! Jesse Phillips wrote in message news:itgg6i$2tf3$1...@digitalmars.com... Lloyd Dupont Wrote: Hi Jesse, this won't work! It's my fault in not explaining my problem well though... I forget to mention something... I'm using property syntax and try to

dummy question : runtime type testing...

2011-06-17 Thread Lloyd Dupont
given A a = class A {} class B : A {} how could I test, at runtime, if a is just a A or is a B? also, give a type T and a TypeInfo variable, how can I know if a variable of type T is attributable to a variable of type described by TypeInfo? i.e. how could I implement the method

Re: dummy question : runtime type testing...

2011-06-17 Thread Jonathan M Davis
On 2011-06-17 19:58, Lloyd Dupont wrote: given A a = class A {} class B : A {} how could I test, at runtime, if a is just a A or is a B? Cast it. The result will be null if the cast fails. if(cast(B)a) //it's a B else //it's an A but not a B - Jonathan M Davis

Re: dummy question : runtime type testing...

2011-06-17 Thread Lloyd Dupont
ho... easy hey! but how about the other 2 test I'd like be able to run? bool isTypeOf(T)(TypeInfo ti) { return T is ti } bool isTypeOf(TypeInfo ti1, TypeInfo ti2) { return ti1 is ti2 } Jonathan M Davis wrote in message news:mailman.988.1308367581.14074.digitalmars-d-le...@puremagic.com...

Re: dummy question : runtime type testing...

2011-06-17 Thread Jonathan M Davis
On 2011-06-17 20:28, Lloyd Dupont wrote: ho... easy hey! but how about the other 2 test I'd like be able to run? bool isTypeOf(T)(TypeInfo ti) { return T is ti } bool isTypeOf(TypeInfo ti1, TypeInfo ti2) { return ti1 is ti2 } I'm afraid that I don't know much about TypeInfo. In my