A dict doesn't guarantee unique keys, but it *does* guarantee that dict-ref 
returns a single value and dict-set accepts a single value, which is really 
strange to guarantee if you're not also going to guarantee unique keys.

Honestly, I think association-lists-as-dicts were a mistake. If you want to 
allow multiple values per key, then use a collection interface that's 
actively designed around that (such as multidicts 
<https://docs.racket-lang.org/rebellion/Multidicts.html>). Racket needs to 
grow beyond using lists as a bunch of different ad-hoc collection types.

On Friday, October 25, 2019 at 11:40:16 PM UTC-7, Matthew Butterick wrote:
>
>
> On Oct 25, 2019, at 7:28 AM, Thomas Dickerson <
> thomas_d...@alumni.brown.edu <javascript:>> wrote:
>
> For reasons that are unclear to me, hash-keys and dict-keys both return a 
> list? instead of a set?(frankly, this seems like a bug in the API...).
>
>
>
> A dict doesn't guarantee unique keys. So `dict-keys` returns a list, not a 
> set. 
>
> #lang racket
> (require racket/dict)
> (define kvs '((a 1) (a 2)))
> (dict? kvs) ; #t
> (dict-keys kvs) ; '(a a)
>
> Why does `hash-keys` also return a list? For consistency, I suppose, 
> because every hash is a dict.
>

-- 
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/f01e6c65-7e1e-49eb-bb7c-2dbb299602f1%40googlegroups.com.

Reply via email to