Re: [racket] clarification for beginners please

2013-04-25 Thread Pierpaolo Bernardi
On Fri, Apr 26, 2013 at 4:19 AM, Robby Findler wrote: > You wouldn't happen to have a citation for this traditional way, would you? > No. But I'll take note if I happen to remember some place where it is explained in this way. Racket Users list: http://lists.racket-lang.

Re: [racket] clarification for beginners please

2013-04-25 Thread Matthias Felleisen
Opaque structures are inaccessible to all operations, including equality. That's why only (eq? z y) can succeed because z and y point to the same object and eq? compares the pointers not the objects. This opacity is needed to ensure the integrity of values created by the core (lambdas) and by

Re: [racket] clarification for beginners please

2013-04-25 Thread Robby Findler
You wouldn't happen to have a citation for this traditional way, would you? tia, Robby On Thu, Apr 25, 2013 at 9:11 PM, Pierpaolo Bernardi wrote: > Ah, yes, right. > > > > On Fri, Apr 26, 2013 at 4:09 AM, Robby Findler < > ro...@eecs.northwestern.edu> wrote: > >> Yes, except that we do know som

Re: [racket] clarification for beginners please

2013-04-25 Thread Neil Van Dyke
Alan Johnsey wrote at 04/25/2013 10:04 PM: (define x (make-posn 4 5)) (define y (make-posn 4 5)) [...] > (equal? x y) #f [...] Adding #:transparent to the posn struct definition makes x equal? to both y and z as it should, and eq? gives #f when comparing x and y as it should. Seem

Re: [racket] clarification for beginners please

2013-04-25 Thread Pierpaolo Bernardi
Ah, yes, right. On Fri, Apr 26, 2013 at 4:09 AM, Robby Findler wrote: > Yes, except that we do know something about what happens when it returns > #t in the "in all other cases" case. > > Robby > > > On Thu, Apr 25, 2013 at 9:03 PM, Pierpaolo Bernardi > wrote: > >> The traditional way of expla

Re: [racket] clarification for beginners please

2013-04-25 Thread Robby Findler
Yes, except that we do know something about what happens when it returns #t in the "in all other cases" case. Robby On Thu, Apr 25, 2013 at 9:03 PM, Pierpaolo Bernardi wrote: > The traditional way of explaining eq? is that it works when one of the > arguments is a symbol or a mutable data struc

Re: [racket] clarification for beginners please

2013-04-25 Thread Alan Johnsey
I've followed this discussion and thought I understood it quite well until I tried it. Following are my results, using Racket 3.3 on Windows XP: Test 1: #lang racket (define-struct posn (x y)) (define x (make-posn 4 5)) (define y (make-posn 4 5)) (define z y) > (equal? x y) #f > (

Re: [racket] clarification for beginners please

2013-04-25 Thread Pierpaolo Bernardi
The traditional way of explaining eq? is that it works when one of the arguments is a symbol or a mutable data structure. In all other cases the result is implementation dependent. Is this explanation still valid for racket? On Fri, Apr 26, 2013 at 1:37 AM, Robby Findler wrote: > I don't thin

Re: [racket] clarification for beginners please

2013-04-25 Thread Robby Findler
I don't think that either of these explanations are really the right way to think about eq?. The only way to really understand eq? on immutable values is to understand that it is exposing low-level details of the implementation to you (ostensibly for performance reasons). That is, if (eq? a b) retu

Re: [racket] clarification for beginners please

2013-04-25 Thread Sam Tobin-Hochstadt
On Thu, Apr 25, 2013 at 5:35 PM, Matthias Felleisen wrote: > eqv? is Scheme's attempt at incorporating an approximation to the so-called > notion of observational equivalence. Two values are observationally > equivalent if they are interchangeable in all contexts -- wherever you see > one value

Re: [racket] clarification for beginners please

2013-04-25 Thread Matthias Felleisen
On Apr 25, 2013, at 4:57 PM, David Vanderson wrote: > > On 04/25/2013 02:57 PM, Matthias Felleisen wrote: >>> (eqv? (factorial 1000) (factorial 1000)) ;; ... but they point to >>> observably equal numbers, so eqv? uses = to compare them >> #t >>> (eqv? (cons 1 2) (cons 1 2)) ;; distinct pointe

Re: [racket] clarification for beginners please

2013-04-25 Thread David Vanderson
On 04/25/2013 02:57 PM, Matthias Felleisen wrote: (eqv? (factorial 1000) (factorial 1000)) ;; ... but they point to observably equal numbers, so eqv? uses = to compare them #t (eqv? (cons 1 2) (cons 1 2)) ;; distinct pointers point to allocated structures, on the other hand, and eqv? compare

Re: [racket] clarification for beginners please

2013-04-25 Thread Marco Morazan
Joe, Perhaps a more pedestrian explanation might help. There is a difference between two items having the same value and two items being the same item. equal? tests if its two items have the same value. eq? tests if two items are the same item. Using your example: (define A (make-posn 4 5)) (d

Re: [racket] clarification for beginners please

2013-04-25 Thread Danny Yoo
Probably a crab would be filled with a sense of personal outrage if it could hear us class it without ado or apology as a crustacean, and thus dispose of it. "I am no such thing, it would say: I am MYSELF, MYSELF alone." - William James, The Varieties of Religiou

Re: [racket] clarification for beginners please

2013-04-25 Thread Matthias Felleisen
On Apr 25, 2013, at 2:31 PM, "Ford, Joe" wrote: > I have a group of high school students with a question... can someone please > explain to beginner Racket users the differences between these three boolean > functions: eq? equal? eqv? Welcome to Racket v5.3.4.5. > (require math) > (eq?