caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] co/contra-variance and class ?
@ 2001-04-27 18:51 Juergen Pfitzenmaier
  2001-04-29 10:24 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Pfitzenmaier @ 2001-04-27 18:51 UTC (permalink / raw)


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. 

pfitzen

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] co/contra-variance and class ?
  2001-04-27 18:51 [Caml-list] co/contra-variance and class ? Juergen Pfitzenmaier
@ 2001-04-29 10:24 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2001-04-29 10:24 UTC (permalink / raw)
  To: pfitzen; +Cc: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-04-29 10:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-27 18:51 [Caml-list] co/contra-variance and class ? Juergen Pfitzenmaier
2001-04-29 10:24 ` Jacques Garrigue

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).