[I remember an old discussion about this, but I can't find the message.]
For small number of clauses, case is expanded to a bunch of if. When there
are more than ¿12? it may be use a hash table or binary search. It has a
few tricks:

https://github.com/racket/racket/blob/master/racket/collects/racket/private/case.rkt

Gustavo

On Thu, Aug 22, 2019 at 3:38 PM George Neuner <gneun...@comcast.net> wrote:

>
> On 8/21/2019 3:25 PM, Jon Zeppieri wrote:
> > Racket's `case` is an implementation of this approach:
> > http://scheme2006.cs.uchicago.edu/07-clinger.pdf
> >
> > It is not significantly complicated by `else`. And that approach was
> > created in the context of Scheme, which leaves the return value
> > unspecified when none of the tests are successful. That seems like it
> > should offer more opportunities for optimization, but I don't think
> > this approach is any less efficient when the unsuccessful result is
> > specified as #<void> (as it is in Racket) than when it is not.
> >
> > - Jon
>
> Thanks for the pointer!
>
> 'case' in Scheme is an interesting challenge for compilation because it
> can involve dispatching on multiple types, each having its own
> comparison ordering.  I would hope that Racket leverages generic table
> searches where possible - depending on the use, generating a complete
> static dispatch routine everywhere can result in explosive growth of the
> code.  [Not that I've seen this happen, but I haven't had occasion to
> experiment in Racket with extremely large or complicated 'case'
> constructs.]
>
> George
>
> --
> 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/a8dd208d-dd3f-a2a7-3d20-3c1027932ac9%40comcast.net
> .
>

-- 
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/CAPaha9PvohKnSZwsnF8gn8hOKejQMpCCVWVPiNmZuQOjO2Odzw%40mail.gmail.com.

Reply via email to