Arthur A. Gleckler <xxxxxx@speechcode.com> schrieb am Mo., 3. Juli 2017 um 05:48 Uhr:
Hi, Marc.  I never saw a reply from you to Mr. Kawai's message below, but I believe John Cowan brought up the same issue recently and you addressed it.  Is that right?

Thanks.

Thanks for the reminder. The messages somehow got lost in my inbox.
 
From: Shiro Kawai <xxxxxx@gmail.com>
Date: Wed, May 3, 2017 at 9:09 PM
Subject: Precedence in mapping-unfold and mapping
To: srfi-146@srfi.schemers.org


The srfi doc states that, if the same key appears more than once in those constructors,
the earlier one takes precedence.

The reference implementation appears to disagree, though, for it just
applies mapping-set in order, so the earlier one will be replaced by the
latter one.  (I haven't run the code so pardon me if it is my misunderstanding.)

Yes, you are right. The reference implementation does not what it is supposed to do (by the current wording of the spec). 

In fact, the reference implementation of ‘alist->mapping‘ has the same problem because it builds upon ‘mapping-unfold’.
 

It may be defined so that it is consistent with alist->mapping.   But 
earlier-takes-precedence rule may cost extra lookup per item unless the
underlying map data structure provides "insert only when it is a
new key" operation.

Any implementation of this SRFI should be able to provide a fast ‘mapping-search’. With ‘mapping-search’ it is easy to implement.

In any case, at least for ‘mapping’, you can always reverse the list of arguments.

Would you agree?

What might be missing, though, is a primitive procedure for adjoining an association if and only if there is not already an association with that key (semantics like ‘set-adjoin’ from SRFI 113).

What do you think?

--

Marc