Re: Determine if template argument is an array

2009-05-21 Thread Christopher Wright
Fractal wrote: Hello Any body can explan me how to determine if a template argument is an array? Thanks Have a look at std.traits or tango.core.Traits. The appropriate way to check is via the templates they define, since it's clearer. Looking at the source will tell you how to replicate the

Re: Theory question

2009-05-21 Thread BCS
Reply to Frits, BCS wrote: Are there any cases where the following cases both compile but are not identical? A a; B b; a = b; a.Foo(); and A a; B b; a = b; b.Foo(); struct A { int i; void Foo() { i = 42; } } alias A B; The first case will set a.i to 42, the second will set b.i. I w

Re: Determine if template argument is an array

2009-05-21 Thread Fractal
Fractal Wrote: > Hello > > Any body can explan me how to determine if a template argument is an array? ...And also if is an associative array > Thanks

Determine if template argument is an array

2009-05-21 Thread Fractal
Hello Any body can explan me how to determine if a template argument is an array? Thanks

Re: Theory question

2009-05-21 Thread Frits van Bommel
BCS wrote: Are there any cases where the following cases both compile but are not identical? A a; B b; a = b; a.Foo(); and A a; B b; a = b; b.Foo(); struct A { int i; void Foo() { i = 42; } } alias A B; The first case will set a.i to 42, the second will set b.i. And with op

Theory question

2009-05-21 Thread BCS
Are there any cases where the following cases both compile but are not identical? A a; B b; a = b; a.Foo(); and A a; B b; a = b; b.Foo(); The reason I ask is I'm wondering if making the type (and value) of an assignment expression the right hand side rather than the left hand side wou

Re: Class allocation from tuple

2009-05-21 Thread Robert Fraser
bearophile wrote: I have a tuple of classes (D1 language), I'd like to instantiate one of them directly with new, but it seems I can't: template Tuple(T...) { alias T Tuple; } class Foo { static void foo(){} } class Bar {} alias Tuple!(Foo, Bar) ClassTuple; void main() { alias ClassTuple[

Re: Class allocation from tuple

2009-05-21 Thread Jarrett Billingsley
On Thu, May 21, 2009 at 11:13 AM, bearophile wrote: > Jarrett Billingsley: > >> When it tries to parse >> the type following 'new', it interprets the brackets as meaning an >> array type,< > > I agree. But not even this works: > new (ClassTuple[0]); > > Bye, > bearophile Have you tried reading th

Re: Class allocation from tuple

2009-05-21 Thread bearophile
Jarrett Billingsley: > When it tries to parse > the type following 'new', it interprets the brackets as meaning an > array type,< I agree. But not even this works: new (ClassTuple[0]); Bye, bearophile

Re: Class allocation from tuple

2009-05-21 Thread Jarrett Billingsley
On Thu, May 21, 2009 at 10:31 AM, bearophile wrote: > I have a tuple of classes (D1 language), I'd like to instantiate one of them > directly with new, but it seems I can't: > > template Tuple(T...) { alias T Tuple; } > > class Foo { static void foo(){} } > class Bar {} > alias Tuple!(Foo, Bar) C

Re: DMD Modifications

2009-05-21 Thread Spacen Jasset
Daniel Keep wrote: white_man wrote: Does it possible to modify DMD and publish it in that form. Of course with full information about authors. Does it legal? It depends. If you ONLY modify the front-end (front-end files are identified as being licensed under GPL [1]), then you can distribute

Class allocation from tuple

2009-05-21 Thread bearophile
I have a tuple of classes (D1 language), I'd like to instantiate one of them directly with new, but it seems I can't: template Tuple(T...) { alias T Tuple; } class Foo { static void foo(){} } class Bar {} alias Tuple!(Foo, Bar) ClassTuple; void main() { alias ClassTuple[0] Foo0; new Foo

Re: any html parser with d binding

2009-05-21 Thread Christopher Wright
BCS wrote: Hello reimi, i have 2 question here: 1) can anyone suggest good html parser with d binding? IIRC ANTLR can generate D The last supported version was 2.7.something. It depends on phobos, possibly a rather old version of it (I don't know).

Re: DMD Modifications

2009-05-21 Thread Daniel Keep
white_man wrote: > Does it possible to modify DMD and publish it in that form. Of course with > full information about authors. Does it legal? It depends. If you ONLY modify the front-end (front-end files are identified as being licensed under GPL [1]), then you can distribute the modified fro

DMD Modifications

2009-05-21 Thread white_man
Does it possible to modify DMD and publish it in that form. Of course with full information about authors. Does it legal?

Re: going beyond your bounds

2009-05-21 Thread Derek Parnell
On Thu, 21 May 2009 05:58:04 -0400, MLT wrote: >> Because new elements are pre-initialized in D. >> >> Just by increasing the length, you 'create' a new element (from the 'b' >> point of view) so D initializes it. > > (We were talking about something like > int a[] = [1,2,3,4,5] ; > b = a ; > a

Re: going beyond your bounds

2009-05-21 Thread MLT
> Because new elements are pre-initialized in D. > > Just by increasing the length, you 'create' a new element (from the 'b' > point of view) so D initializes it. (We were talking about something like int a[] = [1,2,3,4,5] ; b = a ; a ~= 6 ; b.length = b.length+1;) Hmmm... yes, that has some l

Re: going beyond your bounds

2009-05-21 Thread Derek Parnell
On Thu, 21 May 2009 05:37:59 -0400, MLT wrote: > Derek Parnell Wrote: > >> >> So remember, assigning one array to another is just creating an alias to >> the original array. You end up with two arrays pointing to the same data >> buffer. > > Yes. My question relates to what happens when you go

Re: going beyond your bounds

2009-05-21 Thread MLT
Derek Parnell Wrote: > > So remember, assigning one array to another is just creating an alias to > the original array. You end up with two arrays pointing to the same data > buffer. Yes. My question relates to what happens when you go beyond the bounds originally assigned. Why does an extensio

Re: going beyond your bounds

2009-05-21 Thread Derek Parnell
On Thu, 21 May 2009 04:51:16 -0400, MLT wrote: > After a discussion on digitalmars.D I played with arrays a bit. Look at the > following code: > int[] a = [1,2,3,4,5,6,7,8,9] ; > int[] b = a ; > a ~= 10 ; > b ~= 11 ; > b[0] =

going beyond your bounds

2009-05-21 Thread MLT
After a discussion on digitalmars.D I played with arrays a bit. Look at the following code: int[] a = [1,2,3,4,5,6,7,8,9] ; int[] b = a ; a ~= 10 ; b ~= 11 ; b[0] = 12 ; Stdout(b).newline ;

Re: any html parser with d binding

2009-05-21 Thread Frank Benoit
Robert Fraser schrieb: > reimi gibbons wrote: >> 2) how reliable is bcd to create binding for c libraries? > > C? Very reliable (unless it uses weird compiler directives). C++ is a > bit trickier. Last time I used BCD, it had no support for bitfields and generated struct definition that do not ma