Re: SRFI 225: Dictionaries
Dr. Arne Babenhauserheide 21 Jul 2021 18:59 UTC
John Cowan <xxxxxx@ccil.org> writes:
> On Mon, Jul 19, 2021 at 4:02 PM Dr. Arne Babenhauserheide <xxxxxx@web.de>
> wrote:
>
> One thing I miss in the specification are non-mutating update-procedures
>> that are better suited to functional style (without !-suffix).
>> Complemented by a way to ask whether they are efficient.
>>
>
> The purpose of dictionaries is for a caller to pass a key-value store of
> its choice that the callee can operate on. You wouldn't normally create a
> key-value store and manipulate it yourself using the dictionary
> operations[*]: you'd use the operations specific to that type of
> store. That being so, there is no real benefit to letting the callee ask
> what is efficient; the caller has to make that decision.
There could be optimizations that only work if the operation does not
mutate. For example multithreading is safe without locks if I do not
mutate. So whether set without mutation is efficient could decide
whether to use a multithreaded algorithm with set or a single-threaded
one with set!.
As far as I understand it, the goal of this SRFI is to abstract away
differences between the storage types, so more higher-level procedures
(for example statistical aggregation) can take any dictionary-supporting
type.
Do I understand it correctly?
> [*] Another reason would be to take advantage of the automatically supplied
> operations for a store type that doesn't provide them all, but then the
> callee *is* the caller and is supposed to know what guarantees, if any, the
> type provides.
That requires knowing the implementation of the operations — whether
they actually mutate (see above). Otherwise the caller cannot have
enough information to decide based on efficiency.
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken