caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: micha-1@fantasymail.de
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] virtual instance variables
Date: Mon, 21 May 2007 15:04:10 +0900 (JST)	[thread overview]
Message-ID: <20070521.150410.48799413.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <20070518205020.59b45b61@hmmm.de>

From: micha <micha-1@fantasymail.de>

> entering in the toplevel: 
> 
> class virtual c = object val virtual d : int end;;
> 
> then:
> 
> class d = object inherit c val d = 9 end;;
> 
> gives me: Exception: Not_found.
> What is not found?  (compiling works)

Great, you found the first bug in this release!
To trigger it you must create a virtual instance variable without
using it (which is certainly useless, but allowed.)
This is now fixed in CVS.

Note that if you write 
  class virtual c = object val virtual d : int method d = d end;;
there is of course no problem.

> if I define:
>  class virtual c = object val d = 0 end;;
>  class d = object inherit c val d = 9 end;;
> 
> gives the warning:
> Warning V: the instance variable d is overriden.
> The behaviour changed in ocaml 3.10 (previous behaviour was hiding.)
> 
> I thought that  without the virtual declaration the behaviour is the
> same as before?

No, it is not. Or, more precisely, we reverted to the behviour of
ocaml 1. Visible instance variables are merged. To avoid this, you
must hide the first d by a coercion:

class d = object inherit (c : object end) val d = 9 end;;

Jacques Garrigue


  reply	other threads:[~2007-05-21  6:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-18 18:50 micha
2007-05-21  6:04 ` Jacques Garrigue [this message]
2007-06-28 13:34 Jeremy Yallop
2007-06-28 13:47 ` [Caml-list] " Jon Harrop
2007-06-28 13:48   ` Vincent Hanquez
2007-06-28 14:48 ` Jacques Garrigue

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=20070521.150410.48799413.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=micha-1@fantasymail.de \
    /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).