caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* A nastier example
@ 2005-05-14 14:51 Julien Verlaguet
  2005-05-14 15:09 ` [Caml-list] " Eric Cooper
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Julien Verlaguet @ 2005-05-14 14:51 UTC (permalink / raw)
  To: caml-list

Here is a nastier case than the one in the previous msg.

exception E of int;;

let x=E(1);;

exception E of bool;;

x=E(true);;

answer : true

I received many mails (in private), explaining to me how the equality 
works in OCaml, how exceptions are represented etc ...
Which is not what I was asking, I will try to reformulate :

Is this the behaviour we want ?

Can two values of different types be equal ?

I agree that this wouldn't be a problem if it would only work in a 
toplevel ... But it compiles in structures as well !!

J


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

* Re: [Caml-list] A nastier example
  2005-05-14 14:51 A nastier example Julien Verlaguet
@ 2005-05-14 15:09 ` Eric Cooper
  2005-05-14 15:36 ` Marcin 'Qrczak' Kowalczyk
  2005-05-14 19:09 ` [Caml-list] " Jon Harrop
  2 siblings, 0 replies; 10+ messages in thread
From: Eric Cooper @ 2005-05-14 15:09 UTC (permalink / raw)
  To: caml-list

On Sat, May 14, 2005 at 04:51:07PM +0200, Julien Verlaguet wrote:
> Here is a nastier case than the one in the previous msg.
> 
> exception E of int;;
> 
> let x=E(1);;
> 
> exception E of bool;;
> 
> x=E(true);;
> 
> answer : true
> 
> I received many mails (in private), explaining to me how the equality 
> works in OCaml, how exceptions are represented etc ...
> Which is not what I was asking, I will try to reformulate :
> 
> Is this the behaviour we want ?
> 
> Can two values of different types be equal ?

But these aren't different types -- they're both type "exn".
For example:
    let test e = (e = Exit)
    val test : exn -> bool = <fun>
So test can be applied to any exception, no matter what kind of
structure it has.

-- 
Eric Cooper             e c c @ c m u . e d u


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

* Re: [Caml-list] A nastier example
  2005-05-14 14:51 A nastier example Julien Verlaguet
  2005-05-14 15:09 ` [Caml-list] " Eric Cooper
@ 2005-05-14 15:36 ` Marcin 'Qrczak' Kowalczyk
  2005-05-14 15:47   ` Julien Verlaguet
  2005-05-15 14:59   ` Vincenzo Ciancia
  2005-05-14 19:09 ` [Caml-list] " Jon Harrop
  2 siblings, 2 replies; 10+ messages in thread
From: Marcin 'Qrczak' Kowalczyk @ 2005-05-14 15:36 UTC (permalink / raw)
  To: caml-list

Julien Verlaguet <Julien.Verlaguet@pps.jussieu.fr> writes:

> I received many mails (in private), explaining to me how the equality
> works in OCaml, how exceptions are represented etc ...
> Which is not what I was asking, I will try to reformulate :
>
> Is this the behaviour we want ?
>
> Can two values of different types be equal ?

They don't have different types. They both have type exn.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


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

* Re: [Caml-list] A nastier example
  2005-05-14 15:36 ` Marcin 'Qrczak' Kowalczyk
@ 2005-05-14 15:47   ` Julien Verlaguet
  2005-05-15 14:59   ` Vincenzo Ciancia
  1 sibling, 0 replies; 10+ messages in thread
From: Julien Verlaguet @ 2005-05-14 15:47 UTC (permalink / raw)
  To: Marcin 'Qrczak' Kowalczyk; +Cc: caml-list


> They don't have different types. They both have type exn.

I was talking about the type of the parameters ...

Sorry for the confusion,

J


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

* Re: [Caml-list] A nastier example
  2005-05-14 14:51 A nastier example Julien Verlaguet
  2005-05-14 15:09 ` [Caml-list] " Eric Cooper
  2005-05-14 15:36 ` Marcin 'Qrczak' Kowalczyk
@ 2005-05-14 19:09 ` Jon Harrop
  2005-05-15 15:50   ` skaller
  2005-05-15 17:24   ` Mark Shinwell
  2 siblings, 2 replies; 10+ messages in thread
From: Jon Harrop @ 2005-05-14 19:09 UTC (permalink / raw)
  To: caml-list

On Saturday 14 May 2005 15:51, Julien Verlaguet wrote:
> Is this the behaviour we want ?

Ideally, no.

> Can two values of different types be equal ?

In theory, no.

> I agree that this wouldn't be a problem if it would only work in a
> toplevel ...

Does code ever work differently in the top-level than when compiled (with 
ocamlc)? Should it?

> But it compiles in structures as well !! 

I think everyone would agree that there are caveats here but this is a 
question of trade-offs. So the question should be "how can we improve upon 
the current implementation?". To which the answer, for me at least, is "I 
can't".

There are many pitfalls associated with equality in OCaml but the existence of 
polymorphic comparisons is easily justified by their usefulness, IMHO.

-- 
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] 10+ messages in thread

* Re: A nastier example
  2005-05-14 15:36 ` Marcin 'Qrczak' Kowalczyk
  2005-05-14 15:47   ` Julien Verlaguet
@ 2005-05-15 14:59   ` Vincenzo Ciancia
  1 sibling, 0 replies; 10+ messages in thread
From: Vincenzo Ciancia @ 2005-05-15 14:59 UTC (permalink / raw)
  To: caml-list

Il giorno sab, 14/05/2005 alle 17.36 +0200, Marcin 'Qrczak' Kowalczyk ha
scritto:
> 
> > Can two values of different types be equal ?
> 
> They don't have different types. They both have type exn.

Yes but one usually does not expect structural equality to "equalize"
things with different structure, while the example posted does something
really strange and implementation dependent - I don't know what other
discussions have been around about this so sorry if this is an old
flame :) but exception equality implemented that way makes physical data
structures implementation observable (or am I fooled by something?)

Vincenzo

-- 
Per rispondermi in privato per favore usate vincenzo_ml at yahoo dot it
To send me a private reply please use vincenzo_ml at yahoo dot it



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

* Re: [Caml-list] A nastier example
  2005-05-14 19:09 ` [Caml-list] " Jon Harrop
@ 2005-05-15 15:50   ` skaller
  2005-05-15 17:24   ` Mark Shinwell
  1 sibling, 0 replies; 10+ messages in thread
From: skaller @ 2005-05-15 15:50 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On Sun, 2005-05-15 at 05:09, Jon Harrop wrote:

> I think everyone would agree that there are caveats here but this is a 
> question of trade-offs. So the question should be "how can we improve upon 
> the current implementation?". 

> There are many pitfalls associated with equality in OCaml but the existence of 
> polymorphic comparisons is easily justified by their usefulness, IMHO.

Require the user to define the comparison, then provide a way
to generate them 'memberwise' for products and sums.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




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

* Re: [Caml-list] A nastier example
  2005-05-14 19:09 ` [Caml-list] " Jon Harrop
  2005-05-15 15:50   ` skaller
@ 2005-05-15 17:24   ` Mark Shinwell
  2005-05-16  0:15     ` Jon Harrop
  1 sibling, 1 reply; 10+ messages in thread
From: Mark Shinwell @ 2005-05-15 17:24 UTC (permalink / raw)
  To: Jon Harrop; +Cc: caml-list

On Sat, May 14, 2005 at 08:09:28PM +0100, Jon Harrop wrote:
> Does code ever work differently in the top-level than when compiled (with 
> ocamlc)?

Yes.  See for example "Reply 2" of:

http://pauillac.inria.fr/bin/caml-bugs/not%20a%20bug?id=3591;page=64;user=guest

Mark
-- 
Dr Mark Shinwell -- email: Mark.Shinwell@cl.cam.ac.uk
Theory and Semantics Group, University of Cambridge Computer Laboratory


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

* Re: [Caml-list] A nastier example
  2005-05-15 17:24   ` Mark Shinwell
@ 2005-05-16  0:15     ` Jon Harrop
  2005-05-16 11:40       ` Damien Doligez
  0 siblings, 1 reply; 10+ messages in thread
From: Jon Harrop @ 2005-05-16  0:15 UTC (permalink / raw)
  To: caml-list

On Sunday 15 May 2005 18:24, Mark Shinwell wrote:
> On Sat, May 14, 2005 at 08:09:28PM +0100, Jon Harrop wrote:
> > Does code ever work differently in the top-level than when compiled (with
> > ocamlc)?
>
> Yes.  See for example "Reply 2" of:
>
> http://pauillac.inria.fr/bin/caml-bugs/not%20a%20bug?id=3591;page=64;user=g
>uest

Very interesting. In summary, is it fair to say that Marshall has problems 
with functions when used in the top-level but not with ocamlc- and ocamlopt- 
compiled code?

Thanks for the link.

-- 
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] 10+ messages in thread

* Re: [Caml-list] A nastier example
  2005-05-16  0:15     ` Jon Harrop
@ 2005-05-16 11:40       ` Damien Doligez
  0 siblings, 0 replies; 10+ messages in thread
From: Damien Doligez @ 2005-05-16 11:40 UTC (permalink / raw)
  To: caml-list

On May 16, 2005, at 02:15, Jon Harrop wrote:

> Very interesting. In summary, is it fair to say that Marshall has 
> problems
> with functions when used in the top-level but not with ocamlc- and 
> ocamlopt-
> compiled code?

Yes, although it is a very small problem: it would pretty hard for the
average programmer to guarantee that the same function is compiled at
the same address in the top-level that unmarshals the closure.

So the usefulness of marshaling closures from the top-level would be
rather small.

-- Damien


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

end of thread, other threads:[~2005-05-16 11:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-14 14:51 A nastier example Julien Verlaguet
2005-05-14 15:09 ` [Caml-list] " Eric Cooper
2005-05-14 15:36 ` Marcin 'Qrczak' Kowalczyk
2005-05-14 15:47   ` Julien Verlaguet
2005-05-15 14:59   ` Vincenzo Ciancia
2005-05-14 19:09 ` [Caml-list] " Jon Harrop
2005-05-15 15:50   ` skaller
2005-05-15 17:24   ` Mark Shinwell
2005-05-16  0:15     ` Jon Harrop
2005-05-16 11:40       ` Damien Doligez

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