comp.lang.ada
 help / color / mirror / Atom feed
From: Karel Th�nissen <thoenissen@hello.confusion.nl>
Subject: covariance and parameter modes (was: Re: Instantiating Generic Object)
Date: 1997/11/13
Date: 1997-11-13T00:00:00+00:00	[thread overview]
Message-ID: <346B1E1F.25F3@hello.confusion.nl> (raw)
In-Reply-To: 3468E43B.7BCFFF2C@munich.netsurf.de

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1669 bytes --]


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




       reply	other threads:[~1997-11-13  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <646g1b$avs@solaria.cc.gatech.edu>
     [not found] ` <3466EBB8.61AE@stratus.com>
     [not found]   ` <EJFy23.47o@ecf.toronto.edu>
     [not found]     ` <slrn66f65r.f80.kennel@lyapunov.ucsd.edu>
     [not found]       ` <EJHnM4.H97@ecf.toronto.edu>
     [not found]         ` <3468E43B.7BCFFF2C@munich.netsurf.de>
1997-11-13  0:00           ` Karel Th�nissen [this message]
1997-11-14  0:00             ` covariance and parameter modes (was: Re: Instantiating Generic Object) Graham Perkins
1997-11-18  0:00               ` Karel Th�nissen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox