Re: What about other mechanisms to support polymorphism?
Dr. Arne Babenhauserheide 23 Jul 2021 20:38 UTC
John Cowan <xxxxxx@ccil.org> writes:
> I understand what nullary constructors are, but not why they are relevant
> to SRFI 225, which provides no generic constructors of any kind, the
> assumption being that the information required by a constructor is
> arbitrarily different for different dictionary types.
What happens if we remove the last entry from an alist and then add a
new entry? Can this turn it into a plist — or the other way round?
(dict-set! (dict-remove! (λ(x) #t) dict) 1 2)
One thing I’d like to see is an equivalent to assoc, i.e. dict-item:
(dict-item '((1 . 2)) 1)
;; => (1 . 2)
(dict-item '((1 . 2)) 2)
;; => #f
If an entry with the key exists, return the entry in the dictionary (car
as key, cdr as value), if it does not exist, return #f.
This allows distinguishing between value #f and not existing key,
without having to query the datastructure twice.
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken