Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Mixed class / type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Mixed class / type
> I got this problem :
> - two classes called wmenu and wmenuitem, are mutaly recursive
> - one wmenuitem can be constructed either with a wmenu or with a wmenuitem
> 
> so I need a type like this :
> 
> type menu =
>     Mainmenu of wmenu
>     | Menuitem of wmenuitem
> 
> So I tryied :
> 
> type menu = .....
> and
>     class wmenuitem : menu -> object ... end
> and
>     class wmenu : object ... end
> 
> But it doesn't work.
> Any clue is welcomed.

A light workaround would be

class wmenuitem : [ `Mainmenu of wmenu | `Menuitem of wmenuitem] -> ...
and wmenu : object ... end

Since polymorphic variants do not need to be defined, the problem does
not appear.

    Jacques Garrigue
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr