caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Sébastien Furic" <programming.languages@furic.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Questions about default instances
Date: Tue, 16 Aug 2011 10:42:54 +0200	[thread overview]
Message-ID: <4E4A2D8E.8000404@furic.org> (raw)
In-Reply-To: <20B7E892-BB5F-40CE-9428-512E94B2B5A3@math.nagoya-u.ac.jp>

  Hello Jacques,

Le 08/08/2011 09:14, Jacques Garrigue a écrit :
> On 2011/08/05, at 1:22, Sébastien Furic wrote:
>
>> What is the usual way in OCaml to define mutually recursive classes that share default instances?
>
> There is no concept of "default instance" in OCaml, and as you discovered yourself,
> default instances create problems with initialization.
> Namely, an object constructor might attempt to access a default instance before it is built,
> so we need a way to know whether it is ready or not.

  But I still wonder why it is not possible to allow “direct let rec” in 
my example. Indeed, object creation is safe here since access to default 
instances is protected by method calls (there is a potential problem 
with initializers that may refer to, or call methods that refer to, 
not-yet-initialized objects but this can be statically checked, can't 
it?). As a benefit, it would avoid using lazy values in singleton 
patterns (which make the whole thing a bit unreadable IMO) and, in 
particular, the definition of not_ in my example would be more natural 
(I think about the poor readers of my code but also raw performance).

  Cheers,

  Sébastien.

      reply	other threads:[~2011-08-16  8:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-04 16:22 Sébastien Furic
2011-08-08  7:14 ` Jacques Garrigue
2011-08-16  8:42   ` Sébastien Furic [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4A2D8E.8000404@furic.org \
    --to=programming.languages@furic.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).