English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] dynamic runtime cast in Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-07 (07:22)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] dynamic runtime cast in Ocaml
From: Walid Taha <taha@cs.rice.edu>

> Were nested quantifiers (either existentials or universals) considered in
> the context of OCaml?  If not, are there plans to add them?  Thanks.

I'm not sure of what you are asking about, and whether this is
relevant to the question of runtime casts.

If this is a question of type systems, then yes there are nested
universal quantifiers in ocaml, which you can use either through
object types (polymorphic methods), record types (polymorphic fields)
or the module system (not first-class quantification, but this was not
explicit in your question).
For existential quantification, you only get it more or less with
modules. Note that modules defined by "let module" are a bit weak in
this context, as the types they define cannot escape their scope.

Does this answer your question, or were you talking about something

By the way, for the expressivity addict (Curry-style), there is now a
branch in CVS with support for a specific form of dependent types. You
can get it by
  cvs update -r multimatch `cat testlabl/dirs_multimatch`
(when it is not broken).
I plan to provide it as a patch after the next release.

This allows you to do things like:
# let convert x y =
    multimatch y with
      `Int -> x
    | `Float -> float x
    | `String -> string_of_int x;;
val convert :
  int ->
  [< `Float & 'a = float | `Int & 'a = int | `String & 'a = string] -> 'a =
# convert 3 `String;;
- : string = "3"
# convert 2 `Float;;
- : float = 2.
and this without any overloading...

Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
		<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners