@dyllongagnier has joined the channel
Is it good practice to use type-specific equality procedures (e.g. char=?
) instead of the generic equality procedures?
For readability, I prefer type-specific equality. It also produces an error when the contract is violated instead of failing silently. The downside, of course, is that it could be less efficient in a tight loop, since it needs to check for contract violation (especially when the alternative is eq?
which is super fast).
For readability, I prefer always using equal?
It makes things much easier when you don’t have to ask yourself which equality procedure to use or whether a given choice of equality procedure in some block of code is optimal
@steven has joined the channel
I mostly agree with @notjack but eq? is actually useful sometimes for pointer equality (== in Java). However, even for number types I would use equal? for clarity and only use eq? if you need the special behavior rather than as an optimization.