Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Using modules and classes recursively
@ 1999-01-09 20:24 Markus Mottl
  1999-01-12 17:29 ` Xavier Leroy
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Mottl @ 1999-01-09 20:24 UTC (permalink / raw)
  To: OCAML

Hello - Bonjour,

Even though I have tried hard, I couldn't solve the following problem:

I want to have a class that is able to return a set of objects of
its type, but I have no idea, how I have to formulate this (if it is
possible).

E.g.:

---------------------------------------------------------------------------
class foo =
object
  method bar = FooSet.singleton (new foo)
end
---------------------------------------------------------------------------

An object of this class would return a set containing itself if its
member function "bar" is called.
Before the definition of this class, the module "FooSet" has to be
created. But it seems impossible to do so.

E.g.:

---------------------------------------------------------------------------
module FooSet =
  Set.Make (struct type t = <bar : FooSet.t> let compare = compare end)
---------------------------------------------------------------------------

This does not work, because the type constructor "FooSet.t" cannot be
bound before "FooSet" exists - but that's what are defining!

Is it impossible to have modules and classes combined recursively?
If yes, what would be a good workaround?

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




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

end of thread, other threads:[~1999-01-13 11:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-09 20:24 Using modules and classes recursively Markus Mottl
1999-01-12 17:29 ` Xavier Leroy
1999-01-12 18:49   ` Brian Rogoff
1999-01-12 19:20     ` Markus Mottl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox