Re: Java static binding for parameters and covariance/contravariance

Lujop <lujoplujop@gmail.com>
26 Nov 2004 22:41:06 -0500

          From comp.compilers

Related articles
Java static binding for parameters and covariance/contravariance lujoplujop@gmail.com (Lujop) (2004-11-19)
Re: Java static binding for parameters and covariance/contravariance newsserver_mails@bodden.de (Eric Bodden) (2004-11-20)
Re: Java static binding for parameters and covariance/contravariance vbdis@aol.com (2004-11-20)
Re: Java static binding for parameters and covariance/contravariance mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2004-11-20)
Re: Java static binding for parameters and covariance/contravariance lujoplujop@gmail.com (Lujop) (2004-11-26)
Re: Java static binding for parameters and covariance/contravariance vbdis@aol.com (2004-11-26)
Re: Java static binding for parameters and covariance/contravariance boldyrev+nospam@cgitftp.uiggm.nsc.ru (Ivan Boldyrev) (2004-11-28)
| List of all articles for this month |
From: Lujop <lujoplujop@gmail.com>
Newsgroups: comp.compilers
Date: 26 Nov 2004 22:41:06 -0500
Organization: Compilers Central
References: 04-11-070 04-11-076
Keywords: Java, design
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:


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


>VBDis
>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
error checking).
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.


>Dmitry
>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
do
class A
    m(A)
class B extends A
    m(B)


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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.