<jsomedon>
why does racket have three equality check: eq?, eqv? and equal?
<jsomedon>
how are they different with each other
Sgeo__ has joined #racket
jsomedon has quit [Quit: jsomedon]
Sgeo_ has quit [Ping timeout: 248 seconds]
soegaard has joined #racket
_whitelogger has joined #racket
zipper has joined #racket
ZombieChicken has quit [Quit: Have a nice day]
mSSM has joined #racket
orivej has quit [Ping timeout: 245 seconds]
<tonyg>
jsomedon: eq? checks pointer equality. it's there for pragmatic reasons. eqv? is a leftover from scheme. equal? checks deep structural equality and is what you usually should use
pierpal has joined #racket
zipper has quit [Ping timeout: 248 seconds]
manualcrank has quit [Quit: WeeChat 1.9.1]
zipper has joined #racket
zipper has quit [Client Quit]
clacke_movim has left #racket [#racket]
soegaard has quit [Quit: soegaard]
clacke_movim has joined #racket
keep_learning_M has quit [Quit: This computer has gone to sleep]
soegaard has joined #racket
zipper has joined #racket
soegaard has quit [Quit: soegaard]
soegaard has joined #racket
clacke_movim has left #racket [#racket]
Roargh has joined #racket
jcowan has quit [Quit: Connection closed for inactivity]
zipper has quit [Ping timeout: 272 seconds]
zipper has joined #racket
clacke_movim has joined #racket
zipper has quit [Ping timeout: 248 seconds]
zipper has joined #racket
zipper has quit [Ping timeout: 244 seconds]
zipper has joined #racket
zipper has quit [Ping timeout: 272 seconds]
zipper has joined #racket
soegaard has quit [Quit: soegaard]
ubLIX has joined #racket
acarrico has joined #racket
jao has joined #racket
zipper has quit [Ping timeout: 246 seconds]
davidl has joined #racket
zipper has joined #racket
jao has quit [Ping timeout: 248 seconds]
<clacke_movim>
"Pragmatic reasons" sounds a bit dismissive. Object identity is a core concept in any language that allows mutation.
dddddd has joined #racket
<tonyg>
clacke_movim: exactly :)
<clacke_movim>
Hehe
<tonyg>
clacke_movim: but crucially, eq? can tell apart different immutable allocations
<tonyg>
it's not a sensible equivalence at the level of racket - only at the level of the racket implementation
<tonyg>
if you see what i mean
<tonyg>
it's a grungy performance hack that always bites you in the arse
<tonyg>
also, racket gets identity of mutable data slightly wrong imo.
<clacke_movim>
Aha?
<tonyg>
i'd like to have equal? distinguish non-eq? boxes
<tonyg>
that is, have equal? be Baker's egal
<clacke_movim>
Why would you want equal? to distinguish non-eq? things when you have eq? for that?
<tonyg>
because eq? can't identify equal? things
<tonyg>
so currently (equal? (list 1 (box 0)) (list 1 (box 0)))
<tonyg>
but I want that to be false
<clacke_movim>
... but they're equal
<tonyg>
however, I want (let ((b (box 0))) (equal? (list 1 b) (list 1 b))) to be true
<tonyg>
clacke_movim: they're `equal?` but not `egal`
<clacke_movim>
going to have to find this Baker fellow and talk some sense into him
<clacke_movim>
"The More Things Change, The More They Are the Same"
<clacke_movim>
Well put, I can see where this is going
<tonyg>
:)
zipper has joined #racket
<tonyg>
(wow that's a clever way of putting it. i hadn't reflected on that phrasing before now)
<tonyg>
"In the next section, we argue that neither EQ nor EQUAL is wrong; EQ is correct for mutable cons cells and EQUAL is correct for immutable cons cells. The major mistake of Lisp is in not distinguishing the two kinds of cons cells based on their mutability."
<tonyg>
I should say, there was some situation recently where I had some sympathy for the way Racket does it, but it eludes my recall at present
<clacke_movim>
I've been fascinated by battling my preconceived notions of data and identity while playing with Tcl
<clacke_movim>
They have fascinating workarounds for their lack of object identity.
<greghendershott>
To riff on Alan Perlis: "If you have a language with a half dozen equality operators, you probably missed some." :)
<technomancy>
eh; if you think need more than egal and eq I would be worried you're going off the deep end
pera has joined #racket
<bremner>
Do I have to read that paper to understand what egal is?
<technomancy>
you don't have to but it's such a good paper that it'd be a shame to miss out on it
<bremner>
I'll wait for the tweet
<technomancy>
egal? is just "is there no way these two things could behave in a different way from each other, other than possibly eq?"
<bremner>
sounds hard.
<technomancy>
(well, with false negatives)
<technomancy>
because Halting Problem
<bremner>
ack
<technomancy>
if you know of a predicate that can tell that (lambda (x y) (+ x y)) will always behave the same as (lambda (x y) (+ (* x 2) (* y 2) (- x) (- y))) that'd be a neat trick
cpup has joined #racket
ym555 has joined #racket
sleepnap has quit [Ping timeout: 272 seconds]
acarrico has quit [Ping timeout: 248 seconds]
pera has quit [Ping timeout: 272 seconds]
casaca has quit [Ping timeout: 245 seconds]
dan_f has quit [Quit: dan_f]
dan_f has joined #racket
dan_f has quit [Client Quit]
casaca has joined #racket
dan_f has joined #racket
<J_Arcane>
when I did the object system in Heresy, i was genuinely surprised how complicated a concept "equality" actually is when you break it down to what's expected
<J_Arcane>
I always thought it's weird that Lisps had so many kinds of equality predicates, but what I realized is it's because most other languages just ... punt on most of the questions
<bremner>
pointer equality ought to be good enough for everyone
pera has joined #racket
<J_Arcane>
in the end I kinda punted too, and things are checked with `equal?` because that seemed like it most fit what a user coming from non-Lisps might expect. *shrug*
<bremner>
I managaged to get through 1.3 semesters of teaching with racket only using equal?
<J_Arcane>
(well, actually they're hashed with `equal-hash-code`, and the hash is stored in the object and then compared when comparing objects)
<bremner>
I think it was only when writing a little GC simulator I needed eq?
<bremner>
someone else had a reasonable example of needing eq? when last the topic arose, but of course I forgot.
<J_Arcane>
yeah. I think eq? is probably useful when you're doing something low-level. Heresy doesn't really aim to do that so it didn't seem needed
<J_Arcane>
bremner: use in a GC tracks since you're essentially checking memory locations. another thought that pops in my mind is implementing new data structures, you might want to check for `eq?` as an optimisation maybe?
<J_Arcane>
"Don't bother doing <thing> to these two values if they're already the same". Or maybe even "don't do <mutating thing> to x if it's eq? to y"
<bremner>
checking for cyclic data structures maybe?
johnjay has quit [Ping timeout: 258 seconds]
<J_Arcane>
yeah, that's a good thought
<bremner>
looking back at my lectures I see I did use eq? for symbols a few places, but that probably just introduced confusion.
dan_f has quit [Quit: dan_f]
johnjay has joined #racket
iclon_ has joined #racket
ym555 has quit [Ping timeout: 258 seconds]
iclon__ has quit [Ping timeout: 272 seconds]
FreeFull has joined #racket
dan_f has joined #racket
manualcrank has joined #racket
johnjay has quit [Read error: Connection reset by peer]
selimcan has joined #racket
pera has quit [Ping timeout: 268 seconds]
johnjay has joined #racket
sauvin has quit [Ping timeout: 258 seconds]
johnjay has quit [Read error: Connection reset by peer]
acarrico has joined #racket
johnjay has joined #racket
vraid has joined #racket
johnjay has quit [Excess Flood]
johnjay has joined #racket
ubLIX has quit [Quit: ubLIX]
pera_ has joined #racket
dan_f has quit [Quit: dan_f]
FreeFull has quit []
FreeFull has joined #racket
johnjay has quit [Read error: Connection reset by peer]
pera_ has quit [Ping timeout: 246 seconds]
johnjay has joined #racket
johnjay has quit [Read error: Connection reset by peer]
johnjay has joined #racket
pera_ has joined #racket
johnjay has quit [Read error: Connection reset by peer]
johnjay has joined #racket
Sgeo__ has joined #racket
Sgeo_ has quit [Ping timeout: 244 seconds]
casaca has quit [Ping timeout: 272 seconds]
casaca has joined #racket
<samth>
technomancy: I think sometimes (eg testing) you want equal? instead of egal?
jsomedon has joined #racket
Sgeo__ has quit [Read error: Connection reset by peer]