Re: Again: Referential Equality

1999-07-29 Thread Fergus Henderson
On 28-Jul-1999, Lennart Augustsson [EMAIL PROTECTED] wrote: Fergus Henderson wrote: equal x y = unsafePerformIO $ do ptrEq - ptrEqual x y return (ptrEq || deep_equals x y) Note that unlike `req', `equal' here _is_ referentially transparent.

Re: Again: Referential Equality

1999-07-28 Thread Hans Aberg
At 14:11 +0200 1999/07/27, Koen Claessen wrote: The contructs we add to the language are: type Ref a = ... ref :: a - Ref a deref :: Ref a - a (=) :: Ref a - Ref a - Bool This basically gives you ML-style but non-updatable references, but you can compare them for equality. You can

RE: Again: Referential Equality

1999-07-28 Thread Frank A. Christoph
So the two conditions if a `eq` b then F(a) `eq` F(b) if a `req` b then G(a) `req` G(b) will only lead to different classes of functions (homomorphisms with respect to different properties). The latter will in math more correspond to consider all underlying set functions,

Re: Again: Referential Equality

1999-07-28 Thread Fergus Henderson
On 27-Jul-1999, Andreas C. Doering [EMAIL PROTECTED] wrote: [Simon Peyton-Jones wrote:] [Andreas Doering wrote:] let x=[1..] in x==x would not terminate in the first case but succeed in the second. But, much worse let x = (a,b) in x `req` x = True but (a,b)

Re: Again: Referential Equality

1999-07-28 Thread Fergus Henderson
On 27-Jul-1999, Frank A. Christoph [EMAIL PROTECTED] wrote: I would like to have a comparison instruction that compares the internal reference of two objects. Let's call it "req". req :: a - a - Bool By coincidence, I was just looking at GHC's documentation on stable names and

Re: Again: Referential Equality

1999-07-28 Thread Fergus Henderson
On 27-Jul-1999, D. Tweed [EMAIL PROTECTED] wrote: On Tue, 27 Jul 1999, Simon Marlow wrote: req a b = unsafePerformIO $ do a' - makeStableName a b' - makeStableName b return (a' == b') That's exactly what to use in a situation like this. Pointer equality loses

Re: Again: Referential Equality

1999-07-28 Thread Fergus Henderson
On 27-Jul-1999, Hans Aberg [EMAIL PROTECTED] wrote: I think there is not a big problem with breaking "referential transparency"; the same think happens in pure math often and it is part of a normal procedure of constructing mathematical objects: Referential transparency means that if

RE: Again: Referential Equality

1999-07-28 Thread Frank A. Christoph
Fergus wrote: On 27-Jul-1999, Simon Marlow [EMAIL PROTECTED] wrote: I would like to have a comparison instruction that compares the internal reference of two objects. Let's call it "req". req :: a - a - Bool By coincidence, I was just looking at GHC's documentation on

Re: Again: Referential Equality

1999-07-28 Thread Fergus Henderson
On 27-Jul-1999, Theo Norvell [EMAIL PROTECTED] wrote: On Tue, 27 Jul 1999, Andreas C. Doering wrote: let x=[1..] in x==x would not terminate in the first case but succeed in the second. But, much worse let x = (a,b) in x `req` x = True but (a,b)

Re: Again: Referential Equality

1999-07-28 Thread Fergus Henderson
On 27-Jul-1999, Simon Marlow [EMAIL PROTECTED] wrote: I would like to have a comparison instruction that compares the internal reference of two objects. Let's call it "req". req :: a - a - Bool By coincidence, I was just looking at GHC's documentation on stable names and

Re: Again: Referential Equality

1999-07-28 Thread Lennart Augustsson
Fergus Henderson wrote: equal x y = unsafePerformIO $ do ptrEq - ptrEqual x y return (ptrEq || deep_equals x y) Note that unlike `req', `equal' here _is_ referentially transparent. No, it's not. If x and y are both bottom you can get unexpected

Re: Again: Referential Equality

1999-07-28 Thread Hans Aberg
At 14:02 +0100 1999/07/28, D. Tweed wrote: As for a math description of references, one could take the view that one always constructs objects a, with references r. Then what is indicated in the language is often the object pairs (a, r) modulo the equivalence relation that the references

Re: Again: Referential Equality

1999-07-28 Thread Fergus Henderson
Frank A. Christoph [EMAIL PROTECTED] wrote: Fergus wrote: If you put the call to `unsafePerformIO' in an unsafe primitive such as `req', then when your code is compiled with some optimizing compiler which assumes that functions are referentially transparent the resulting executable may

Re: Again: Referential Equality

1999-07-28 Thread D. Tweed
On Wed, 28 Jul 1999, Hans Aberg wrote: At 14:02 +0100 1999/07/28, D. Tweed wrote: As for a math description of references, one could take the view that one always constructs objects a, with references r. Then what is indicated in the language is often the object pairs (a, r) modulo the

Re: Again: Referential Equality

1999-07-28 Thread Lennart Augustsson
Fergus Henderson wrote: I'm not sure off-hand what the best fix would be. One possible solution would be to force evaluation of the arguments if they are equal: equal x y = unsafePerformIO $ do ptrEq - ptrEqual x y return (if ptrEq then x

Re: Again: Referential Equality

1999-07-28 Thread Bart Demoen
Lennart Augustsson wrote: ... This is OK in Mercury because in Mercury ... Well, given that I think I'll stick to functional languages. ;-) I appreciate your ;-) Indeed, for lots of logic programmers, Mercury is a functional language in a logic syntax disguise. You can be a functional

Re: Again: Referential Equality

1999-07-28 Thread Hans Aberg
At 16:49 +0100 1999/07/28, D. Tweed wrote: ... I see now that you were describing how you could implement `language defined references' with semantics which mean that the problems that were pointed out don't happen. Right. I think that in a computer language one tends to think of the semantics

RE: Again: Referential Equality

1999-07-27 Thread Simon Peyton-Jones
The expression let x=[1..] in x==x would not terminate in the first case but succeed in the second. But, much worse let x = (a,b) in x `req` x = True but (a,b) `req` (a,b) = False So referential transparency is lost. This is a high price to

RE: Again: Referential Equality

1999-07-27 Thread Andreas C. Doering
let x=[1..] in x==x would not terminate in the first case but succeed in the second. But, much worse let x = (a,b) in x `req` x = True but (a,b) `req` (a,b) = False So referential transparency is lost. This is a high price to pay. You are

RE: Again: Referential Equality

1999-07-27 Thread Simon Marlow
I would like to have a comparison instruction that compares the internal reference of two objects. Let's call it "req". req :: a - a - Bool By coincidence, I was just looking at GHC's documentation on stable names and pointers, and it seems relevant here.

RE: Again: Referential Equality

1999-07-27 Thread Frank A. Christoph
I would like to have a comparison instruction that compares the internal reference of two objects. Let's call it "req". req :: a - a - Bool By coincidence, I was just looking at GHC's documentation on stable names and pointers, and it seems relevant here.

Re: Again: Referential Equality

1999-07-27 Thread Koen Claessen
Andreas C. Doering wrote: | I would like to have a comparison instruction that compares the internal | reference of two objects. It might be of interest here to talk about a paper that Dave Sands and I have recently submitted to a conference, about something we call "observable sharing". It

Re: Again: Referential Equality

1999-07-27 Thread Lennart Augustsson
"D. Tweed" wrote: On Tue, 27 Jul 1999, Simon Marlow wrote: req a b = unsafePerformIO $ do a' - makeStableName a b' - makeStableName b return (a' == b') That's exactly what to use in a situation like this. Pointer equality loses referential transparency in general (as

RE: Again: Referential Equality

1999-07-27 Thread Theo Norvell
On Tue, 27 Jul 1999, Andreas C. Doering wrote: let x=[1..] in x==x would not terminate in the first case but succeed in the second. But, much worse let x = (a,b) in x `req` x = True but (a,b) `req` (a,b) = False So referential

RE: Again: Referential Equality

1999-07-27 Thread D. Tweed
On Tue, 27 Jul 1999, Simon Marlow wrote: req a b = unsafePerformIO $ do a' - makeStableName a b' - makeStableName b return (a' == b') That's exactly what to use in a situation like this. Pointer equality loses referential transparency in general (as Simon P.J. pointed out),