Statements dreamed up by the utterly deranged :comfyderp:

Imagine trying to top up JavaScript's ridiculousness and winning!

Or this:
> (eq 'a 'b) is false.
> (eq 'a 'a) is true.
> (eq 3 3) might be true or false, depending on the implementation.

In what universe 3 and 3 might not be equal by any metric imaginable? Common Lisp is truly a cursed language.

Every time I try to love Common Lisp, it slaps me on the face with a huge club and leaves me bleeding. Truly cursed language.


I'm lucky enough to only have used racket and scheme (small amount of guile too)

CLisp is scary

To be fair, those equality checks all mostly seem useful, if you don't wanna do specific checks,

But idk, I mostly just use eq and if it doesn't work, I do some mutations

@lunarised what if I just wanna compare to values? Surely, I could just use `equal` everywhere, except it doesn't always work on symbols.

>Symbols are compared as for eq. This method of comparing symbols can violate the rule of thumb for equal and printed representations, but only in the infrequently occurring case of two distinct symbols with the same print name.

What the literal fuck is this shit? :facepalm_cirno:

@lunarised going further, from the same page:
>Two arrays are equal only if they are eq, with one exception: strings and bit-vectors are compared element-by-element.

I have no idea how anyone can take this language seriously. It's even more of a joke than JavaScript.

@pureevil @lunarised This, admittedly, was a serious misstep. In practice it doesn't matter much, because you rarely need to compare arrays other than strings (and many uses of strings are replaced by symbols). But it's weird that the only standard generic function for this is equalp, which also forces case-insensitive character comparisons.

I rarely use anything other than = for numbers, eql for keys in a data structure, and equal for pretty much everything else.

@curtmack @lunarised what if I just want to write some abstract code without even thinking what kind of values it will work with? In Haskell, I can write just this:

f :: Eq a => a -> a -> IO ()
f x y | x == y = putStrLn "Equal"
| otherwise = putStrLn "Not equal"

How do I do the same in Common Lisp? Exactly..


@pureevil @lunarised Depending on your goal, you could make it a generic function that defaults to equal (or an appropriate alternative for non-string arrays), accepting that other users can override it however they want. Alternatively, you could use generic-cl which replaces many standard library functions, including equal, with generic versions. Then the function would call the generic version of equal, however the actual types choose to implement it.

@curtmack @lunarised generic-cl seems like it desperately needs to be the default, because it contains the behavior I would expect

Sign in to participate in the conversation

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.