4 ms·
> There's a thing where if you declare a type A, and then a derived type B, methods on A have to be declared before type B gets declared... Yes, that sounds ve
by david-given 11y ago
> There's a thing where if you declare a type A, and then a derived type B, methods on A have to be declared before type B gets declared...
Yes, that sounds very familiar.
> The specific error message is: you declared a package, which is basically a header in C parlance.
Oh, FFS. That snippet is not, in fact, pointing at the piece of code I was actually asking about --- ideone changed it when I wasn't looking. The one you saw is unfinished and broken.
This one is the one I was meaning: http://ideone.com/skZRIb http://ideone.com/skZRIb
The .Foo selector isn't found; changing it to Foo(object) reports that apparently Foo isn't a dispatching method on MyClass1... which makes no sense, because this is the same code as you had. My suspicion is that there's something magic about declaring classes in packages?
- msbarnett 11y ago> which makes no sense, because this is the same code as you had. My suspicion is that there's something magic about declaring classes in packages? Yeah. Dispatching methods on a type consist of the type's "primitive operations". The Ada 95 Rationale spells it out: "Just as in Ada 83, derived types inherit the operations which "belong" to the parent type - these are called primitive operations in Ada 95. User-written subprograms are classed as primitive operations if they are declared in the same package specification as the type and have the type as parameter or result." It seems like a wart that you're not in an "anonymous" package in situations like your example, but I also guess it probably doesn't come up much in "real" programs.