On Fri, Oct 25, 2019 at 1:27 PM wanderley.guimar...@gmail.com < wanderley.guimar...@gmail.com> wrote:
> On Fri, Oct 25, 2019 at 9:28 AM Alexis King <lexi.lam...@gmail.com> wrote: > >> Unlike eq? on symbols, eq?’s behavior on quoted lists is unspecified … >> Is there a reason you would like the answer to be #t? > > Not strong one. I was implementing a compiler (to a computer simulator > that I did) and I wanted to express some of my constants as list (because > it would make easier to read them in case expression). I switched to use > match instead. > Note that Racket's `case` (unlike the R5RS or R6RS versions) is based on `equal?`, so the expression: (case (list 'a) [((a)) "ok"] [else #f]) reliably produces `"ok"`. Also, as you very well may know, the left-hand side of a `case` clause isn't an implicitly-quoted list expression: it's a parenthesized sequence of implicitly-quoted expressions. I mention this because, often, you might represent a constant as a symbol. If you use a case expression to, in logical terms, test if some value is a member of a "list" of constant symbols, there aren't actually any Racket list values involved. It's often a good choice to use `match` rather than `case`, since `match` is more flexible and extensible. However, `match` doesn't provide `case`'s guarantee of O(log N) performance, which can be important if you are generating very large case expressions. -Philip -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAH3z3gYuV1KGRmZk%3D9oFc9VN2SQ%3DO42Tf%2Bh3wWB%2BjmJd1kSszQ%40mail.gmail.com.