* Changes on equality between 3.06 and 3.08.3
@ 2005-04-28 10:02 Olivier Michel
2005-04-28 16:29 ` [Caml-list] " Damien Doligez
2005-04-28 16:41 ` Alex Baretta
0 siblings, 2 replies; 6+ messages in thread
From: Olivier Michel @ 2005-04-28 10:02 UTC (permalink / raw)
To: caml-list; +Cc: the MGS project
Hi dear ocamlers,
I just noticed the following change in Ocaml between release 3.06 and 3.08.3, as far
as equality on records is concerned :
////////////////////////////////////////////////////////////////////////////////
//
//release 3.06
//
dellfp-3 7 > /ocaml
Objective Caml version 3.06
# type toto = { b : int -> int; } ;;
type toto = { b : int -> int; }
# let a = { b = (fun x -> x) } ;;
val a : toto = {b = <fun>}
# a = a;;
- : bool = true
//
//release 3.08.3
//
dellfp-3 8 > ocaml
Objective Caml version 3.08.3
# type toto = { b : int -> int; };;
type toto = { b : int -> int; }
# let a = { b = (fun x -> x) } ;;
val a : toto = {b = <fun>}
# a = a;;
Exception: Invalid_argument "equal: functional value".
////////////////////////////////////////////////////////////////////////////////
Is this supposed to be a bug, or a feature ? Will future releases of Ocaml follow
the new way of handling equality between records or the old one ?
Best regards,
Olivier.
--
Olivier MICHEL Email : michel@lami.univ-evry.fr
Universite d'Evry Val d'Essonne http : www.lami.univ-evry.fr/~michel
Equipe Specif / Projet MGS http : mgs.lami.univ-evry.fr
LaMI - UMR 8042 du CNRS Phone : +33 (0)1.60.87.39.10
523, place des terrasses de l'agora Fax : +33 (0)1.60.87.37.89
91000 Evry - FRANCE
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Changes on equality between 3.06 and 3.08.3
2005-04-28 10:02 Changes on equality between 3.06 and 3.08.3 Olivier Michel
@ 2005-04-28 16:29 ` Damien Doligez
2005-04-28 16:41 ` Alex Baretta
1 sibling, 0 replies; 6+ messages in thread
From: Damien Doligez @ 2005-04-28 16:29 UTC (permalink / raw)
To: caml users
On Apr 28, 2005, at 12:02, Olivier Michel wrote:
> I just noticed the following change in Ocaml between release 3.06 and
> 3.08.3, as far
> as equality on records is concerned :
>
> # type toto = { b : int -> int; };;
> type toto = { b : int -> int; }
> # let a = { b = (fun x -> x) } ;;
> val a : toto = {b = <fun>}
> # a = a;;
> Exception: Invalid_argument "equal: functional value".
>
>
> Is this supposed to be a bug, or a feature ? Will future releases of
> Ocaml follow
> the new way of handling equality between records or the old one ?
New feature. Carefully thought out. Well documented. Ultimately
caused
by a strange wart of the IEEE floating-point standards.
You should use the "compare" function if you want the old behaviour.
-- Damien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Changes on equality between 3.06 and 3.08.3
2005-04-28 10:02 Changes on equality between 3.06 and 3.08.3 Olivier Michel
2005-04-28 16:29 ` [Caml-list] " Damien Doligez
@ 2005-04-28 16:41 ` Alex Baretta
2005-04-28 17:06 ` Olivier Andrieu
1 sibling, 1 reply; 6+ messages in thread
From: Alex Baretta @ 2005-04-28 16:41 UTC (permalink / raw)
To: Olivier Michel; +Cc: caml-list, the MGS project
Olivier Michel wrote:
> Hi dear ocamlers,
>
> I just noticed the following change in Ocaml between release 3.06 and 3.08.3, as far
> as equality on records is concerned :
> ..
> # a = a;;
> Exception: Invalid_argument "equal: functional value".
Keep in mind that in 3.06 physical equality (==) implied structural
equality (=). Now, (=) now longer checks for (==), so no functional
value can be found to be structurally equal to any other functional
value. The following line illustrates this point.
# (=) (=) (=);;
Exception: Invalid_argument "equal: functional value".
Actually, an interesting question related to this one is why the
following line behaves as it does.
# (==) (==) (==);;
- : bool = false
Alex
--
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL
tel. +39 02 370 111 55
fax. +39 02 370 111 54
Our technology:
The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>
The FreerP Project
<http://www.freerp.org/>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Changes on equality between 3.06 and 3.08.3
2005-04-28 16:41 ` Alex Baretta
@ 2005-04-28 17:06 ` Olivier Andrieu
2005-04-28 18:20 ` Marcin 'Qrczak' Kowalczyk
2005-04-28 18:23 ` Jon Harrop
0 siblings, 2 replies; 6+ messages in thread
From: Olivier Andrieu @ 2005-04-28 17:06 UTC (permalink / raw)
To: alex; +Cc: caml-list
> Alex Baretta [Thu, 28 Apr 2005]:
> Actually, an interesting question related to this one is why the
> following line behaves as it does.
>
> # (==) (==) (==);;
> - : bool = false
Probably because == is defined by an "external" in pervasives.ml, not
a regular function definition. So here, when you use (==), you're
building three closures.
--
Olivier
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Changes on equality between 3.06 and 3.08.3
2005-04-28 17:06 ` Olivier Andrieu
@ 2005-04-28 18:20 ` Marcin 'Qrczak' Kowalczyk
2005-04-28 18:23 ` Jon Harrop
1 sibling, 0 replies; 6+ messages in thread
From: Marcin 'Qrczak' Kowalczyk @ 2005-04-28 18:20 UTC (permalink / raw)
To: caml-list
Olivier Andrieu <andrieu@ijm.jussieu.fr> writes:
> > # (==) (==) (==);;
> > - : bool = false
>
> Probably because == is defined by an "external" in pervasives.ml,
> not a regular function definition. So here, when you use (==),
> you're building three closures.
Two. OCaml materializes function objects corresponding to external
functions each time they are used instead of once at the point of
their definition (presumably because it assumes that usually they are
not passed as first-class objects at all), but application of such
function doesn't need the function object but jumps straight to its
machine code.
--
__("< Marcin Kowalczyk
\__/ qrczak@knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] Changes on equality between 3.06 and 3.08.3
2005-04-28 17:06 ` Olivier Andrieu
2005-04-28 18:20 ` Marcin 'Qrczak' Kowalczyk
@ 2005-04-28 18:23 ` Jon Harrop
1 sibling, 0 replies; 6+ messages in thread
From: Jon Harrop @ 2005-04-28 18:23 UTC (permalink / raw)
To: caml-list
On Thursday 28 April 2005 18:06, Olivier Andrieu wrote:
> > Alex Baretta [Thu, 28 Apr 2005]:
> > Actually, an interesting question related to this one is why the
> > following line behaves as it does.
> >
> > # (==) (==) (==);;
> > - : bool = false
>
> Probably because == is defined by an "external" in pervasives.ml, not
> a regular function definition. So here, when you use (==), you're
> building three closures.
# let f = (==) in (==) f f;;
- : bool = true
Interesting. I don't like it, but it's interesting. :-)
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-04-28 18:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-28 10:02 Changes on equality between 3.06 and 3.08.3 Olivier Michel
2005-04-28 16:29 ` [Caml-list] " Damien Doligez
2005-04-28 16:41 ` Alex Baretta
2005-04-28 17:06 ` Olivier Andrieu
2005-04-28 18:20 ` Marcin 'Qrczak' Kowalczyk
2005-04-28 18:23 ` Jon Harrop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox