Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 28, 2005 BUG? Template problems - template1.d | ||||
---|---|---|---|---|
| ||||
Attachments: | Compiling the attached code gives these errors: template1.d(3): template instance List!(int) List is not a template declaration, it is a interface template1.d(3): List!(int) is used as a type template1.d(16): template instance template1.List!(int) error instantiating Shouldn't this code compile? ----Attachment contents supplied below for reference---- interface List(E) { List!(E) sublist(int off, int len); } class Vector(E) : List!(E) { List!(E) sublist(int off, int len) { return null; } } int main() { List!(int) lst=new Vector!(int); return 0; } |
March 09, 2005 Re: BUG? Template problems - template1.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to D. Trebbien | Does anyone know if this is really a bug? In article <cvtoh8$16l3$1@digitaldaemon.com>, D. Trebbien says... > >Compiling the attached code gives these errors: > >template1.d(3): template instance List!(int) List is not a template declaration, >it is a interface >template1.d(3): List!(int) is used as a type >template1.d(16): template instance template1.List!(int) error instantiating > >Shouldn't this code compile? > >----Attachment contents supplied below for reference---- > >interface List(E) >{ >List!(E) sublist(int off, int len); >} > >class Vector(E) : List!(E) >{ >List!(E) sublist(int off, int len) >{ >return null; >} >} > >int main() >{ >List!(int) lst=new Vector!(int); > >return 0; >} > > >begin 0644 template1.d >M:6YT97)F86-E($QI<W0H12D-"GL-"B`@($QI<W0A*$4I('-U8FQI<W0H:6YT >M(&]F9BP@:6YT(&QE;BD[#0I]#0H-"F-L87-S(%9E8W1O<BA%*2`Z($QI<W0A >M*$4I#0I[#0H@("!,:7-T(2A%*2!S=6)L:7-T*&EN="!O9F8L(&EN="!L96XI >M#0H@("![#0H@("`@("!R971U<FX@;G5L;#L-"B`@('T-"GT-"@T*:6YT(&UA >M:6XH*0T*>PT*("`@3&ES="$H:6YT*2!L<W0];F5W(%9E8W1O<B$H:6YT*3L- >2"@T*("`@<F5T=7)N(#`[#0I] >` >end |
March 09, 2005 Re: BUG? Template problems - template1.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to D. Trebbien | I dont think it's a bug. My understanding of the spec:
InterfaceDeclaration:
interface Identifier InterfaceBody
interface Identifier : SuperInterfaces InterfaceBody
SuperInterfaces
Identifier
Identifier , SuperInterfaces
InterfaceBody:
{ DeclDefs }
indicates that: "interface List(E)" isn't legal.
That said, how else can you achieve what you're after?
If you can't then this might be something we should consider adding to the spec.
Regan
On Wed, 9 Mar 2005 18:34:14 +0000 (UTC), D. Trebbien <D._member@pathlink.com> wrote:
> Does anyone know if this is really a bug?
>
> In article <cvtoh8$16l3$1@digitaldaemon.com>, D. Trebbien says...
>>
>> Compiling the attached code gives these errors:
>>
>> template1.d(3): template instance List!(int) List is not a template declaration,
>> it is a interface
>> template1.d(3): List!(int) is used as a type
>> template1.d(16): template instance template1.List!(int) error instantiating
>>
>> Shouldn't this code compile?
>>
>> ----Attachment contents supplied below for reference----
>>
>> interface List(E)
>> {
>> List!(E) sublist(int off, int len);
>> }
>>
>> class Vector(E) : List!(E)
>> {
>> List!(E) sublist(int off, int len)
>> {
>> return null;
>> }
>> }
>>
>> int main()
>> {
>> List!(int) lst=new Vector!(int);
>>
>> return 0;
>> }
>>
>>
>> begin 0644 template1.d
>> M:6YT97)F86-E($QI<W0H12D-"GL-"B`@($QI<W0A*$4I('-U8FQI<W0H:6YT
>> M(&]F9BP@:6YT(&QE;BD[#0I]#0H-"F-L87-S(%9E8W1O<BA%*2`Z($QI<W0A
>> M*$4I#0I[#0H@("!,:7-T(2A%*2!S=6)L:7-T*&EN="!O9F8L(&EN="!L96XI
>> M#0H@("![#0H@("`@("!R971U<FX@;G5L;#L-"B`@('T-"GT-"@T*:6YT(&UA
>> M:6XH*0T*>PT*("`@3&ES="$H:6YT*2!L<W0];F5W(%9E8W1O<B$H:6YT*3L-
>> 2"@T*("`@<F5T=7)N(#`[#0I]
>> `
>> end
>
>
|
March 10, 2005 Re: BUG? Template problems - template1.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath Attachments: | There wasn't anything specifically in the spec that would seem to allow this, but if you comment out the line: List!(E) sublist(int off, int len); the code compiles and links without errors (new code attached). What I wanted to do was create a class library in D for those who are familiar with Java. The List interface is implemented by several different classes (including the Vector class). E is a generic type. Basically, a List is a list of values of the given type E. The Vector class implements a resizable List. One of the functions of a List is to extract a subset of the List (a sublist), given a starting index and length. The sublist is, of course, another List. When I compiled this code with an earlier version of the D compiler, the compiler mentioned "illegal forward reference," if that helps. In article <opsnd5kfbk23k2f5@nrage.netwin.co.nz>, Regan Heath says... > >I dont think it's a bug. My understanding of the spec: > >InterfaceDeclaration: > interface Identifier InterfaceBody > interface Identifier : SuperInterfaces InterfaceBody > >SuperInterfaces > Identifier > Identifier , SuperInterfaces > >InterfaceBody: > { DeclDefs } > >indicates that: "interface List(E)" isn't legal. > >That said, how else can you achieve what you're after? > >If you can't then this might be something we should consider adding to the spec. > >Regan > >On Wed, 9 Mar 2005 18:34:14 +0000 (UTC), D. Trebbien <D._member@pathlink.com> wrote: >> Does anyone know if this is really a bug? >> >> In article <cvtoh8$16l3$1@digitaldaemon.com>, D. Trebbien says... >>> >>> Compiling the attached code gives these errors: >>> >>> template1.d(3): template instance List!(int) List is not a template >>> declaration, >>> it is a interface >>> template1.d(3): List!(int) is used as a type >>> template1.d(16): template instance template1.List!(int) error >>> instantiating >>> >>> Shouldn't this code compile? >>> >>> ----Attachment contents supplied below for reference---- >>> >>> interface List(E) >>> { >>> List!(E) sublist(int off, int len); >>> } >>> >>> class Vector(E) : List!(E) >>> { >>> List!(E) sublist(int off, int len) >>> { >>> return null; >>> } >>> } >>> >>> int main() >>> { >>> List!(int) lst=new Vector!(int); >>> >>> return 0; >>> } >>> >>> >>> begin 0644 template1.d >>> M:6YT97)F86-E($QI<W0H12D-"GL-"B`@($QI<W0A*$4I('-U8FQI<W0H:6YT >>> M(&]F9BP@:6YT(&QE;BD[#0I]#0H-"F-L87-S(%9E8W1O<BA%*2`Z($QI<W0A >>> M*$4I#0I[#0H@("!,:7-T(2A%*2!S=6)L:7-T*&EN="!O9F8L(&EN="!L96XI >>> M#0H@("![#0H@("`@("!R971U<FX@;G5L;#L-"B`@('T-"GT-"@T*:6YT(&UA >>> M:6XH*0T*>PT*("`@3&ES="$H:6YT*2!L<W0];F5W(%9E8W1O<B$H:6YT*3L- >>> 2"@T*("`@<F5T=7)N(#`[#0I] >>> ` >>> end >> >> > |
March 10, 2005 Re: BUG? Template problems - template1.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to D. Trebbien | On Thu, 10 Mar 2005 03:35:23 +0000 (UTC), D. Trebbien <D._member@pathlink.com> wrote: > There wasn't anything specifically in the spec that would seem to allow this, > but if you comment out the line: > List!(E) sublist(int off, int len); > the code compiles and links without errors (new code attached). I'd say this is a bug. :) According to the spec. > What I wanted to do was create a class library in D for those who are familiar > with Java. The List interface is implemented by several different classes > (including the Vector class). E is a generic type. Basically, a List is a list > of values of the given type E. The Vector class implements a resizable List. > > One of the functions of a List is to extract a subset of the List (a sublist), > given a starting index and length. The sublist is, of course, another List. > > When I compiled this code with an earlier version of the D compiler, the > compiler mentioned "illegal forward reference," if that helps. Why not just use D's inbuilt array type? Regan > In article <opsnd5kfbk23k2f5@nrage.netwin.co.nz>, Regan Heath says... >> >> I dont think it's a bug. My understanding of the spec: >> >> InterfaceDeclaration: >> interface Identifier InterfaceBody >> interface Identifier : SuperInterfaces InterfaceBody >> >> SuperInterfaces >> Identifier >> Identifier , SuperInterfaces >> >> InterfaceBody: >> { DeclDefs } >> >> indicates that: "interface List(E)" isn't legal. >> >> That said, how else can you achieve what you're after? >> >> If you can't then this might be something we should consider adding to the >> spec. >> >> Regan >> >> On Wed, 9 Mar 2005 18:34:14 +0000 (UTC), D. Trebbien >> <D._member@pathlink.com> wrote: >>> Does anyone know if this is really a bug? >>> >>> In article <cvtoh8$16l3$1@digitaldaemon.com>, D. Trebbien says... >>>> >>>> Compiling the attached code gives these errors: >>>> >>>> template1.d(3): template instance List!(int) List is not a template >>>> declaration, >>>> it is a interface >>>> template1.d(3): List!(int) is used as a type >>>> template1.d(16): template instance template1.List!(int) error >>>> instantiating >>>> >>>> Shouldn't this code compile? >>>> >>>> ----Attachment contents supplied below for reference---- >>>> >>>> interface List(E) >>>> { >>>> List!(E) sublist(int off, int len); >>>> } >>>> >>>> class Vector(E) : List!(E) >>>> { >>>> List!(E) sublist(int off, int len) >>>> { >>>> return null; >>>> } >>>> } >>>> >>>> int main() >>>> { >>>> List!(int) lst=new Vector!(int); >>>> >>>> return 0; >>>> } >>>> >>>> >>>> begin 0644 template1.d >>>> M:6YT97)F86-E($QI<W0H12D-"GL-"B`@($QI<W0A*$4I('-U8FQI<W0H:6YT >>>> M(&]F9BP@:6YT(&QE;BD[#0I]#0H-"F-L87-S(%9E8W1O<BA%*2`Z($QI<W0A >>>> M*$4I#0I[#0H@("!,:7-T(2A%*2!S=6)L:7-T*&EN="!O9F8L(&EN="!L96XI >>>> M#0H@("![#0H@("`@("!R971U<FX@;G5L;#L-"B`@('T-"GT-"@T*:6YT(&UA >>>> M:6XH*0T*>PT*("`@3&ES="$H:6YT*2!L<W0];F5W(%9E8W1O<B$H:6YT*3L- >>>> 2"@T*("`@<F5T=7)N(#`[#0I] >>>> ` >>>> end >>> >>> >> > > |
March 10, 2005 Re: BUG? Template problems - template1.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | I could just use the array type, but that is not the point. This is somewhat an exercise for testing D. Maybe interfaces cannot be templates (and that is something that should be added to the spec). In article <opsneknodb23k2f5@nrage.netwin.co.nz>, Regan Heath says... > >On Thu, 10 Mar 2005 03:35:23 +0000 (UTC), D. Trebbien <D._member@pathlink.com> wrote: >> There wasn't anything specifically in the spec that would seem to allow >> this, >> but if you comment out the line: >> List!(E) sublist(int off, int len); >> the code compiles and links without errors (new code attached). > >I'd say this is a bug. :) >According to the spec. > >> What I wanted to do was create a class library in D for those who are >> familiar >> with Java. The List interface is implemented by several different classes >> (including the Vector class). E is a generic type. Basically, a List is >> a list >> of values of the given type E. The Vector class implements a resizable >> List. >> >> One of the functions of a List is to extract a subset of the List (a >> sublist), >> given a starting index and length. The sublist is, of course, another >> List. >> >> When I compiled this code with an earlier version of the D compiler, the compiler mentioned "illegal forward reference," if that helps. > >Why not just use D's inbuilt array type? > >Regan > > >> In article <opsnd5kfbk23k2f5@nrage.netwin.co.nz>, Regan Heath says... >>> >>> I dont think it's a bug. My understanding of the spec: >>> >>> InterfaceDeclaration: >>> interface Identifier InterfaceBody >>> interface Identifier : SuperInterfaces InterfaceBody >>> >>> SuperInterfaces >>> Identifier >>> Identifier , SuperInterfaces >>> >>> InterfaceBody: >>> { DeclDefs } >>> >>> indicates that: "interface List(E)" isn't legal. >>> >>> That said, how else can you achieve what you're after? >>> >>> If you can't then this might be something we should consider adding to >>> the >>> spec. >>> >>> Regan >>> >>> On Wed, 9 Mar 2005 18:34:14 +0000 (UTC), D. Trebbien >>> <D._member@pathlink.com> wrote: >>>> Does anyone know if this is really a bug? >>>> >>>> In article <cvtoh8$16l3$1@digitaldaemon.com>, D. Trebbien says... >>>>> >>>>> Compiling the attached code gives these errors: >>>>> >>>>> template1.d(3): template instance List!(int) List is not a template >>>>> declaration, >>>>> it is a interface >>>>> template1.d(3): List!(int) is used as a type >>>>> template1.d(16): template instance template1.List!(int) error >>>>> instantiating >>>>> >>>>> Shouldn't this code compile? >>>>> >>>>> ----Attachment contents supplied below for reference---- >>>>> >>>>> interface List(E) >>>>> { >>>>> List!(E) sublist(int off, int len); >>>>> } >>>>> >>>>> class Vector(E) : List!(E) >>>>> { >>>>> List!(E) sublist(int off, int len) >>>>> { >>>>> return null; >>>>> } >>>>> } >>>>> >>>>> int main() >>>>> { >>>>> List!(int) lst=new Vector!(int); >>>>> >>>>> return 0; >>>>> } >>>>> >>>>> >>>>> begin 0644 template1.d >>>>> M:6YT97)F86-E($QI<W0H12D-"GL-"B`@($QI<W0A*$4I('-U8FQI<W0H:6YT >>>>> M(&]F9BP@:6YT(&QE;BD[#0I]#0H-"F-L87-S(%9E8W1O<BA%*2`Z($QI<W0A >>>>> M*$4I#0I[#0H@("!,:7-T(2A%*2!S=6)L:7-T*&EN="!O9F8L(&EN="!L96XI >>>>> M#0H@("![#0H@("`@("!R971U<FX@;G5L;#L-"B`@('T-"GT-"@T*:6YT(&UA >>>>> M:6XH*0T*>PT*("`@3&ES="$H:6YT*2!L<W0];F5W(%9E8W1O<B$H:6YT*3L- >>>>> 2"@T*("`@<F5T=7)N(#`[#0I] >>>>> ` >>>>> end >>>> >>>> >>> >> >> > |
Copyright © 1999-2021 by the D Language Foundation