|Java static binding for parameters and covariance/contravariance email@example.com (Lujop) (2004-11-19)|
|Re: Java static binding for parameters and covariance/contravariance firstname.lastname@example.org (Eric Bodden) (2004-11-20)|
|Re: Java static binding for parameters and covariance/contravariance email@example.com (2004-11-20)|
|Re: Java static binding for parameters and covariance/contravariance firstname.lastname@example.org (Dmitry A. Kazakov) (2004-11-20)|
|Re: Java static binding for parameters and covariance/contravariance email@example.com (Lujop) (2004-11-26)|
|Re: Java static binding for parameters and covariance/contravariance firstname.lastname@example.org (2004-11-26)|
|Re: Java static binding for parameters and covariance/contravariance email@example.com (Ivan Boldyrev) (2004-11-28)|
|Date:||26 Nov 2004 22:41:06 -0500|
|Posted-Date:||26 Nov 2004 22:41:06 EST|
First of all, a lot of thanks for all the replies. I'll try to reply
all the tree mails in this one:
I agree with you, dynamic binding is better. But my question was not this.
My question is what is better for you, what Java does (the invariant
way that I think that is error prone) or to use contravariance and
don't allow to "override".
Because my problem is that I have a Precondition that for didactic
purposes I have to generate Java code. Thus I can't do things that
Java don't allow.
>The user has to clarify what he
>has in mind, in /your/ language and to /your/ compiler. Your compiler
>can be more restrictive than really required
I also agree with you. I do all the semantics and syntactic checks in
my language, and the user don't see any Java dependencies in the
errors or in the language. In other words, any program that it's ok in
my langauge, have to be ok in java (I don't delegate Java for any
Even so I have to have in mind what Java allows. And I can be more
restrictive, but not more permissive. Then even though I like more the
covariance than contravariance for parameters. I think that is better
to be more restrictive and use contravariant way to avoid the Java
invariant way that I think that is very error prone.
>type A is tagged ...;
>procedure m (X : in out A; Y : A);
> -- m is dispatching in both X and Y
>type B is new A with ...; -- Derived from A
>procedure m (X : in out B; Y : B);
> -- overrides, covariant in X and Y
I agree 100% with you to avoid error prone constructs, especially for
a language for didactic purpouses.
And about your ADA example, ADA is better than Java. Because In Java if you
class B extends A
m(B) don't override m(A). m(B) overloads A
A lot of thanks to all, and any other opinion will be very grateful.
Joan Jesús Pujol Espinar
Return to the
Search the comp.compilers archives again.