[Issue 6857] Precondition contract checks should be statically bound.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 3 18:48:51 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6857
--- Comment #24 from Walter Bright <bugzilla at digitalmars.com> 2012-05-03 18:50:03 PDT ---
(In reply to comment #23)
> (In reply to comment #22)
> >> If you mean whether a given call is legal, then you could by the
> >> same argument insist that called method names must be resolved in
> >> the context of the virtual type.
> >
> > And they are. It's what the vtbl[] is for.
>
> ???
>
> class A {}
>
> class B : A {
> void foo() {}
> }
>
> void main() {
> A a = new B;
> a.foo();
> }
>
> You're claiming that this code is legal, and the penultimate line resolves to
> B's foo method???
No, I'm not. This thread is about overriding, not introducing, functions.
> I'm surprised that the classic OOP spec covers the behaviour of contracts at
> all. But maybe I just need to read up on it.
Betrand Meyer's Object Oriented Programming. You can get it on amazon for
$5.99. It's the definitive classic on the topic.
The behavior with contracts is just another aspect of the contravariance and
covariance of derived objects.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list