array of elements of various subclasses

2010-11-07 Thread spir
Hello, Say I have some subclasses of Pattern. When I try to write Pattern[] patterns = [x,y,z]; I get an error because, apparently, D types the array according to the class of z (Choice is here the type of z): DeeMatch.d(473): Error: cannot implicitly convert expression (x) of type Dee

Re: array of elements of various subclasses

2010-11-07 Thread spir
On Sun, 7 Nov 2010 16:17:38 +0100 spir wrote: And I'd like to know, as a possible workaround, if there is a way to save a variadic arg list: class C { ??? xs; this(X xs...) { this.xs = xs; } } Denis -- -- -- -- -- -- -- vit ess

Re: array of elements of various subclasses

2010-11-07 Thread Jesse Phillips
spir Wrote: > Hello, > > > Say I have some subclasses of Pattern. When I try to write > Pattern[] patterns = [x,y,z]; > I get an error because, apparently, D types the array according to the class > of z (Choice is here the type of z): > > DeeMatch.d(473): Error: cannot implicitly conver

Re: array of elements of various subclasses

2010-11-07 Thread Jesse Phillips
spir Wrote: > On Sun, 7 Nov 2010 16:17:38 +0100 > spir wrote: > > And I'd like to know, as a possible workaround, if there is a way to save a > variadic arg list: > class C { > ??? xs; > this(X xs...) { > this.xs = xs; > } > } > > Denis >

Re: array of elements of various subclasses

2010-11-07 Thread Dmitry Olshansky
On 07.11.2010 18:49, spir wrote: On Sun, 7 Nov 2010 16:17:38 +0100 spir wrote: And I'd like to know, as a possible workaround, if there is a way to save a variadic arg list: class C { ??? xs; this(X xs...) { this.xs = xs; } }

Re: array of elements of various subclasses

2010-11-07 Thread spir
On Sun, 07 Nov 2010 20:29:40 +0300 Dmitry Olshansky wrote: > On 07.11.2010 18:49, spir wrote: > > On Sun, 7 Nov 2010 16:17:38 +0100 > > spir wrote: > > > > And I'd like to know, as a possible workaround, if there is a way to save a > > variadic arg list: > > class C { > > ??? xs; >

Re: array of elements of various subclasses

2010-11-07 Thread spir
On Sun, 07 Nov 2010 11:24:37 -0500 Jesse Phillips wrote: > > And I'd like to know, as a possible workaround, if there is a way to save a > > variadic arg list: > > class C { > > ??? xs; > > this(X xs...) { > > this.xs = xs; > > } > > } > > > > Denis >

Re: array of elements of various subclasses

2010-11-07 Thread Jesse Phillips
spir Wrote: > No, in fact a variadic param list is not an array -- this is according to > TDPL an iternal type of the language. Trying to assign it to an X[] var > throws: > DeeMatch.d(371): Error: cannot implicitly convert expression (patterns) of > type DeeMatch.Pattern to Pattern[] > Well, a

Re: array of elements of various subclasses

2010-11-07 Thread spir
On Sun, 07 Nov 2010 14:08:17 -0500 Jesse Phillips wrote: > spir Wrote: > > > No, in fact a variadic param list is not an array -- this is according to > > TDPL an iternal type of the language. Trying to assign it to an X[] var > > throws: > > DeeMatch.d(371): Error: cannot implicitly convert e

Re: array of elements of various subclasses

2010-11-07 Thread Don
spir wrote: Hello, Say I have some subclasses of Pattern. When I try to write Pattern[] patterns = [x,y,z]; I get an error because, apparently, D types the array according to the class of z (Choice is here the type of z): DeeMatch.d(473): Error: cannot implicitly convert expression (x

Re: array of elements of various subclasses

2010-11-07 Thread Stewart Gordon
On 07/11/2010 15:49, spir wrote: And I'd like to know, as a possible workaround, if there is a way to save a variadic arg list: class C { ??? xs; this(X xs...) { this.xs = xs; } } What exactly are you trying to do here? If y