Struct "inheritance"
Vidar Wahlberg
canidae at exent.net
Sun Feb 5 02:58:40 PST 2012
Sending this again, got an error the first time and it appears like it
was not sent.
On 2012-02-04 21:48, Simen Kjærås wrote:
> I see. There's a hint in the error message: "function expected [...],
> not module". Struct is the name of a module, so the compiler thinks
> you want to access something inside it. If you want 'Struct' to refer
> to the type, you must use selective import[1]:
>
> import Struct : Struct;
I see, thanks, that does solve the problem. It is slightly confusing
that you don't get this kind of error for "Foo" in "Bar.d", though
(compiler seems to understand that I mean the class "Foo" rather than
the module "Foo" in this code: "_foo = new Foo(Struct(1))").
Also, is this really ambiguous? Are there any cases where you can have a
module name followed by a parentheses, i.e. "<module>("?
> I cannot seem to recreate this error message. Which version of the
> compiler are you using?
I'm using gdc-4.6 (Debian 4.6.2-4).
Using the Struct from above I can easily recreate the error:
struct Struct {
int baz;
bool opEquals(const Struct s) const {
return baz == s.baz;
}
}
More information about the Digitalmars-d-learn
mailing list