Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 22, 2005 Not possible to just implement an interface? | ||||
---|---|---|---|---|
| ||||
Looking at the syntax for defining a class, it seems that there's no way to have a class simply implement an interface...
Is that right? Or do you just put the interface declaration in place of the superclass declaration if there is no superclass?
--
-PIB
--
"C++ also supports the notion of *friends*: cooperative classes that
are permitted to see each other's private parts." - Grady Booch
|
January 22, 2005 Re: Not possible to just implement an interface? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Bonser | In article <css9lq$1ek8$1@digitaldaemon.com>, Paul Bonser says... > >Looking at the syntax for defining a class, it seems that there's no way >to have a class simply implement an interface... >Is that right? Or do you just put the interface declaration in place of >the superclass declaration if there is no superclass? > The documentation can be slightly misleading if one only looks at that syntax diagram, I'll agree. Yes you can write a class that only implements an interface. If no superclass is given in a class decleration, then DMD auto-magically makes it a child of std.object.Object and moves along. -- Chris Sauls |
January 22, 2005 Re: Not possible to just implement an interface? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Bonser | "Paul Bonser" <misterpib@gmail.com> wrote in message news:css9lq$1ek8$1@digitaldaemon.com... > > Looking at the syntax for defining a class, it seems that there's no way > to have a class simply implement an interface... > Is that right? No. > Or do you just put the interface declaration in place of the superclass declaration if there is no superclass? Yes. (If no superclass is specified, it is implicitly set to "Object" anyway.) |
January 22, 2005 Re: Not possible to just implement an interface? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote: > "Paul Bonser" <misterpib@gmail.com> wrote in message > news:css9lq$1ek8$1@digitaldaemon.com... > >>Looking at the syntax for defining a class, it seems that there's no way >>to have a class simply implement an interface... >>Is that right? > > > No. > > >>Or do you just put the interface declaration in place of >>the superclass declaration if there is no superclass? > > > Yes. (If no superclass is specified, it is implicitly set to "Object" > anyway.) > > Okay, that's what I was assuming. So I may be asking all sorts of questions that are really picky like this because I am working on my own implementation of D right now (keeping the details to myself for now, hope to drop it as a pleasant surprise sometime soon). In fact, I have another question. In the enums section of the docs, the enum declaration is as follows: EnumDeclaration: enum Identifier EnumBody enum EnumBody enum identifier : EnumBaseType EnumBody enum EnumBaseType : EnumBody Why is the colon there after EnumBaseType in the last one? It seems like it's not neccesary, or am I missing the reasoning behind having it there? Also, Identifier is not capitalized in the second to last line, but I'm pretty sure that's just a typo. -- -PIB -- "C++ also supports the notion of *friends*: cooperative classes that are permitted to see each other's private parts." - Grady Booch |
January 22, 2005 Re: Not possible to just implement an interface? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Bonser | In article <cssigl$1o5c$1@digitaldaemon.com>, Paul Bonser says... >In the enums section of the docs, the enum declaration is as follows: >EnumDeclaration: > enum Identifier EnumBody > enum EnumBody > enum identifier : EnumBaseType EnumBody > enum EnumBaseType : EnumBody > >Why is the colon there after EnumBaseType in the last one? It seems like it's not neccesary, or am I missing the reasoning behind having it there? Also, Identifier is not capitalized in the second to last line, but I'm pretty sure that's just a typo. > I think the colon is a typo as well. Having used that particular syntax a bit, I believe the line should be # # enum : EnumBaseType EnumBody # With the colon in the same place it would be were there an identifier. Example: # # enum : ubyte { FlagA = 0x01, FlagB = 0x02, FlagC = 0x04 }; # -- Chris Sauls |
January 22, 2005 Re: Not possible to just implement an interface? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Sauls | That's right. I'll fix it. Thanks! |
Copyright © 1999-2021 by the D Language Foundation