[Issue 6857] Precondition contract checks should be statically bound.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 3 17:48:22 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=6857


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID


--- Comment #22 from Walter Bright <bugzilla at digitalmars.com> 2012-05-03 17:49:32 PDT ---
Please stop reopening this.

> 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.

> (b) is going to continue to be exempt from this requirement.

You cannot widen the requirements of a function without providing an override
of it. A.foo() cannot be called with the widened requirements of B.foo() -
B.foo() gets called. That's why it can be overridden. IT WORKS CORRECTLY. The
virtualness of the contracts is directly connected to the virtualness of the
function calls.

As for the design decision on this, the decision was (and is) to implement
classic OOP. It is theoretically sound. This is well trod and (I thought) well
understood territory. As Andrei pointed out, it is not open for debate what OOP
is.

I realize I am not very good at explaining this. I seriously recommend reading
Meyer's book Object Oriented Programming. It's only $5.99.

If we try and implement alternate and incorrection notions of OOP, D will be
considered a lightweight language run by amateurs.

It is entirely possible that:

1. I have seriously misunderstood OOP (I have made more than my share of such
mistakes before).

2. The OOP community has got it all wrong.

As evidence for (1), is there any OOP language that does it these other ways?
Spec# does not, as Andrei researched and pointed out. For (2), you've got a
high bar to overcome, and certainly have an opportunity for a groundbreaking
academic paper.

-- 
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