From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,INVALID_MSGID, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: fac41,d04de3979117f1b2 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,be374b0c80915daf,start X-Google-Attributes: gid103376,public X-Google-Thread: f79bb,be374b0c80915daf,start X-Google-Attributes: gidf79bb,public From: Karel Th�nissen Subject: covariance and parameter modes (was: Re: Instantiating Generic Object) Date: 1997/11/13 Message-ID: <346B1E1F.25F3@hello.confusion.nl>#1/1 X-Deja-AN: 289260143 References: <646g1b$avs@solaria.cc.gatech.edu> <3466EBB8.61AE@stratus.com> <3468E43B.7BCFFF2C@munich.netsurf.de> Organization: Hello Technologies, Netherlands Newsgroups: comp.lang.eiffel,comp.lang.sather,comp.lang.ada Date: 1997-11-13T00:00:00+00:00 List-Id: Joachim Durchholz wrote: > I haven't read the Sather references too closely, but I think you can > add superclasses in a post-hoc way. In fact I think Sather was created > exactly because covariant parameter definition was considered to be the > wrong way around; post-hoc superclasses are just a necessity if you > accept contravariance as a premise. I am always a bit puzzled if a language is deemed contravariant or covariant in relation with typesafety. The point is, that if in the parameter mechanism a distinction is made among in-parameters, out-parameters and in-out-parameters (like in Ada), contravariance and covariance can both be typesafe depending on the mode of the parameter. For in-parameters, contravariance is the typesafe approach. For out-parameters, and hence function results, covariance is the typesafe approach. For in-out-parameters, being a combination of the two, only 'invariance' is typesafe. Unfortunately, many modern languages do not make the distinction among parameter modes, and are, therefore, cursed with variancy problems. In well-designed languages, the issue is not contravariance or covariance, as they should both be provided by the language, but it is rather typesafety or typebreakage. IIRC, this is okay in Sather. BTW, I do not understand why not more languages make use of parameter modes, because it catches a lot of other bugs as well 8-( -- Groeten, Karel Th�nissen -- mijn e-adres is versleuteld om junk-mailers op het net te verwarren -- verwijder confusion om zo mijn echte adres te verkrijgen -- my e-mail address is scrambled to confuse spammers -- remove the confusion to obtain my true address