caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* virtual instance variables
@ 2007-06-28 13:34 Jeremy Yallop
  2007-06-28 13:47 ` [Caml-list] " Jon Harrop
  2007-06-28 14:48 ` Jacques Garrigue
  0 siblings, 2 replies; 5+ messages in thread
From: Jeremy Yallop @ 2007-06-28 13:34 UTC (permalink / raw)
  To: Caml List

Should this be considered a bug?

    # (object val virtual c : float method m = c end) # m;;
    Segmentation fault


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

* Re: [Caml-list] virtual instance variables
  2007-06-28 13:34 virtual instance variables Jeremy Yallop
@ 2007-06-28 13:47 ` Jon Harrop
  2007-06-28 13:48   ` Vincent Hanquez
  2007-06-28 14:48 ` Jacques Garrigue
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Harrop @ 2007-06-28 13:47 UTC (permalink / raw)
  To: caml-list

On Thursday 28 June 2007 14:34:20 Jeremy Yallop wrote:
> Should this be considered a bug?
>
>     # (object val virtual c : float method m = c end) # m;;
>     Segmentation fault

Yes:

$ ocaml
        Objective Caml version 3.09.1

# (object val virtual c : float method m = c end) # m;;
Syntax error

$ ocaml
        Objective Caml version 3.10.0

# (object val virtual c : float method m = c end) # m;;
Signal -10

and what is signal -10?! :-)

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
The OCaml Journal
http://www.ffconsultancy.com/products/ocaml_journal/?e


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

* Re: [Caml-list] virtual instance variables
  2007-06-28 13:47 ` [Caml-list] " Jon Harrop
@ 2007-06-28 13:48   ` Vincent Hanquez
  0 siblings, 0 replies; 5+ messages in thread
From: Vincent Hanquez @ 2007-06-28 13:48 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On Thu, Jun 28, 2007 at 02:47:59PM +0100, Jon Harrop wrote:
> $ ocaml
>         Objective Caml version 3.10.0
> 
> # (object val virtual c : float method m = c end) # m;;
> Signal -10
> 
> and what is signal -10?! :-)

$ ocaml
        Objective Caml version 3.10.0

# Sys.sigsegv;;
- : int = -10
# 


-- 
Vincent Hanquez


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

* Re: [Caml-list] virtual instance variables
  2007-06-28 13:34 virtual instance variables Jeremy Yallop
  2007-06-28 13:47 ` [Caml-list] " Jon Harrop
@ 2007-06-28 14:48 ` Jacques Garrigue
  1 sibling, 0 replies; 5+ messages in thread
From: Jacques Garrigue @ 2007-06-28 14:48 UTC (permalink / raw)
  To: jeremy.yallop; +Cc: caml-list

From: Jeremy Yallop <jeremy.yallop@ed.ac.uk>

> Should this be considered a bug?
> 
>     # (object val virtual c : float method m = c end) # m;;
>     Segmentation fault

Any segmentation fault using no unsafe features is clearly a bug, and
should go in the bug database.
Should be fixed soon.

Jacques Garrigue


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

* Re: [Caml-list] virtual instance variables
  2007-05-18 18:50 micha
@ 2007-05-21  6:04 ` Jacques Garrigue
  0 siblings, 0 replies; 5+ messages in thread
From: Jacques Garrigue @ 2007-05-21  6:04 UTC (permalink / raw)
  To: micha-1; +Cc: caml-list

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


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

end of thread, other threads:[~2007-06-28 14:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-28 13:34 virtual instance variables 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
  -- strict thread matches above, loose matches on Subject: below --
2007-05-18 18:50 micha
2007-05-21  6:04 ` [Caml-list] " Jacques Garrigue

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).