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
Unquantifiable escaping type in variation of visitor pattern
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-02-24 (23:58)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Unquantifiable escaping type in variation of visitor pattern
From: Christian Stork <cstork@ics.uci.edu>

> It's not that I didn't try otherwise.  These are the reasons (I attached
> illustrative code):
> - The mutable parts/alts/item fields in aggrRule/choiceRule/listRule
>   seem necessary since I cannot define grammars (ie recursively defined
>   objects).  Object instantiation is not allowed to the right of a let
>   rec!  
>   "This kind of expression is not allowed as right-hand side of `let rec'"

The alternative is to use "lazy", which has the extra advantage of
being covariant.

> (Does that mean that 3.08.3 will be released soon?)

There was supposed to be a "Valentine day release", but clearly it
didn't happen.

> > But in your particular example there is no subtyping at all, so there
> > should be no problem anyway.
> I don't know which particular subtyping you refer to, but, of course, I
> intend to subtype the rules and visitors.

Well, as long as you use refs in your definitions, subtyping is
impossible on nodes.
You may of course subclass rules, but then you won't need to use
explicit subtyping either, since it is already done in your make*Node
methods through a self-coercion.
So the specific problem I was writing about should not happen.

> > I attach the modified part of your example, which uses a few tricks to
> > make the code much less verbose.
> Hmm, are these tricks documentd anywhere?  I didn't even see the option
> to use constraints in regular variant types in the official OCaml
> manual.  Anyway, thanks a lot for the improvements.

They are in the reference part of the manual.
In the tutorial, they only appear for objects, which is what they were
originally introduced for.
Somehow it's fortunate that these tricks are not well publicized,
since they trigger a bug. On the other hand the bug could have been
corrected earlier...

Jacques Garrigue