digitalmars.D - Not possible to just implement an interface?
- Paul Bonser (9/9) Jan 21 2005 Looking at the syntax for defining a class, it seems that there's no way...
- Chris Sauls (6/10) Jan 21 2005 The documentation can be slightly misleading if one only looks at that s...
- Walter (5/10) Jan 21 2005 No.
- Paul Bonser (22/41) Jan 21 2005 Okay, that's what I was assuming.
- Chris Sauls (11/21) Jan 21 2005 I think the colon is a typo as well. Having used that particular syntax...
- Walter (1/1) Jan 21 2005 That's right. I'll fix it. Thanks!
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
Jan 21 2005
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
Jan 21 2005
"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.)
Jan 21 2005
Walter wrote:"Paul Bonser" <misterpib gmail.com> wrote in message news:css9lq$1ek8$1 digitaldaemon.com...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 BoochLooking 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.)
Jan 21 2005
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 With the colon in the same place it would be were there an identifier. Example: -- Chris Sauls
Jan 21 2005