Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure you've picked the right example here - far from being a gnarly wart, differences types of equality are a fundamental issue. Your language can choose to either a) hide it effectively (constraining some things) b) expose it to the user which means they have to think about it or c) try (a) but leak and give weird corner cases.

It's not obvious that (a) is superior to (b), an (c) is often what you get.



In the abstract you're right that equality is subtle and complicated, but it seems to me that in practice, most practicing software engineers just want value-equality on garden-variety data structures most of the time (remember == for Strings in Java?), and that for this use-case, a leaky abstraction is fine--preferable, even. At least, the alternative--forcing users to consider the subtleties of equality even in circumstances where it can be safely ignored and having them memorize dozens of cryptic equality operator names--is excessive and unnecessary.


I'm not really saying any of those choices is wrong (although clearly you can make design mistakes that make the leaks problematic, if you pick (c)). It's more that none of them are clearly right.

Really I'm rejecting the idea that that equality as presented in CL was any of: wrong, design by committee, or something we have learned do better since '84.

There are historical artifacts in CL that aren't great (cf filesystem stuff) but this wasn't a good example in my opinion.

I hear your argument - not fully convinced other than in a 80/20 sense. And CL was not designed as a language to leave the 20% out in the cold.

To be fair I don't find clojure compelling as a lisp but I don't think I'm being biased in above.


Yeah, equalp is a really useful abstraction. Deep equality mashed together with case-folding. Something I've always wanted.


Of course in the rare cases I want deep equality without case (and number) folding, I can always implement it myself using... ooops!


I've had a lot of success in my own language designs with dividing the problem into two cases, equality and identity, or EQUALP and EQ in CL lingo. Despite having written a ton of CL over the years, I still fail to remember the specifics of EQL & EQUAL. Defaulting to full value equality does come with a performance cost, but I feel like we're mostly past the point where we should waste precious time on these kinds of micro optimizations for most use cases.

https://github.com/codr7/gfoo


I agree at least separating identity and equality seem to be important in practice. I'm not completely sold on where the other lines should be.

I don't love the CL implementation, particular eql vs equalp on numerics seems fiddly, and it's hard to keep all the cases separate. Homoiconicity introduces the need for a "representation equality" i guess which isn't always needed, etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: