caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
To: pfitzen@informatik.uni-tuebingen.de
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] co/contra-variance and class ?
Date: Sun, 29 Apr 2001 19:24:51 +0900	[thread overview]
Message-ID: <20010429192451J.garrigue@kurims.kyoto-u.ac.jp> (raw)
In-Reply-To: <200104271851.UAA03530@sunglasses.informatik.uni-tuebingen.de>

From: Juergen Pfitzenmaier <pfitzen@informatik.uni-tuebingen.de>

> It is nice to see the introduction of explicit co/contra-variance
> into ocaml. I just read the manual and didn't try some code, but
> my understanding is that the variance stuff is only for type definitions
> and not for classes. Why is this so ? Variance can be a mighty
> tool in dealing with class hierarchies. 

Actually variance annotations are also allowed for type parameters in
classes. I just forgot to add this to the reference manual.

To be more precise: explicit variance annotations are only useful on
abstract types. In all other cases covariance and contravariance of
type parameters is automatically computed.

So the question is rather: why can you write variance annotations on
concrete types also. At the beginning, this was just a syntax problem:
you cannot simultaneously allow annotations for abstract types and
refuse them in other cases. Then it appeared that they could be useful
to check the variance of a type parameter: since the compiler only
shows the variance of type parameters for abstract types, in other
cases writing it by hand will make sure that the parameters have at
least the variance expected (but they can be stronger).

Cheers,

Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


      reply	other threads:[~2001-04-29 10:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-27 18:51 Juergen Pfitzenmaier
2001-04-29 10:24 ` Jacques Garrigue [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010429192451J.garrigue@kurims.kyoto-u.ac.jp \
    --to=garrigue@kurims.kyoto-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=pfitzen@informatik.uni-tuebingen.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).