Discussion:
Ongoing work, maps and dictionaries
s***@public.gmane.org
2003-11-10 03:47:41 UTC
Permalink
In discussions just before and during the Scheme Workshop, Anton raised
the idea of separating the m:1 and m:n (single vs multivalue)
dictionaries into two types. This makes a tremendous amount of sense.
The current draft has this change, with a Map type for
single-key->single-value collections, and a Dictionary subtype for
single-key->multiple-value collections.

While correcting this, I made an attempt to rename the bulk operators to
be more consistent and less confusing. The current thought is:

*-{operator} - ordinary single instance call
*-{operator}-all - multiple value call
*-{operator}-from - call requiring another collection as a source
*-{operator}-all-from - multivalue version of above.

For example, dict-delete (deletes one key/value mapping),
dict-delete-all (deletes all mappings from a key), dict-delete-from
(deletes one key/value mapping for all keys in a source bag), and
dict-delete-all-from (deletes all key/value mappings for each key in the
source bag).

You can view the work-in-progress at sgmiller.org/code/srfi-44.html.
The concrete collection specification still needs to be updated to match
completely.

Scott
--
Bradd W. Szonye
2003-11-10 20:11:09 UTC
Permalink
Post by s***@public.gmane.org
In discussions just before and during the Scheme Workshop, Anton
raised the idea of separating the m:1 and m:n (single vs multivalue)
dictionaries into two types. This makes a tremendous amount of sense.
Good idea. While it isn't strictly necessary, many existing collection
libraries do it this way.
Post by s***@public.gmane.org
The current draft has this change, with a Map type for
single-key->single-value collections, and a Dictionary subtype for
single-key->multiple-value collections.
Not too happy about the specific name choices, though. Set theory calls
a MxN mapping a "relationship" or just "mapping." Mx1 mappings are
usually called "partial functions" or "functions" (depending on whether
the mapping covers the entire domain). In other words, "mapping" is the
more general name.

Unfortunately, "relationship" and "function" are probably confusing for
programmers, and they may imply semantics that the collections do not
have. For another example of prior art in this area, see C++, which
calls them "map" and "multimap."
Post by s***@public.gmane.org
While correcting this, I made an attempt to rename the bulk operators
*-{operator} - ordinary single instance call
*-{operator}-all - multiple value call
*-{operator}-from - call requiring another collection as a source
*-{operator}-all-from - multivalue version of above.
Good idea.
Post by s***@public.gmane.org
You can view the work-in-progress at sgmiller.org/code/srfi-44.html.
The concrete collection specification still needs to be updated to
match completely.
I don't have much time for a thorough review at this time, but the above
mentioned changes sound good.
--
Bradd W. Szonye
http://www.szonye.com/bradd
s***@public.gmane.org
2003-11-10 20:42:03 UTC
Permalink
Post by Bradd W. Szonye
Post by s***@public.gmane.org
The current draft has this change, with a Map type for
single-key->single-value collections, and a Dictionary subtype for
single-key->multiple-value collections.
Not too happy about the specific name choices, though. Set theory calls
a MxN mapping a "relationship" or just "mapping." Mx1 mappings are
usually called "partial functions" or "functions" (depending on whether
the mapping covers the entire domain). In other words, "mapping" is the
more general name.
Thats true in the literature but confusing as you note. Its consistent
though with the names used by a couple of other collection APIs.
Dictionary at least Just Makes Sense, as real dictionaries bind words to
one or more definitions.

Scott
Jens Axel Søgaard
2003-11-10 22:45:10 UTC
Permalink
Post by s***@public.gmane.org
Post by Bradd W. Szonye
Post by s***@public.gmane.org
The current draft has this change, with a Map type for
single-key->single-value collections, and a Dictionary subtype for
single-key->multiple-value collections.
Not too happy about the specific name choices, though. Set theory calls
a MxN mapping a "relationship" or just "mapping." Mx1 mappings are
usually called "partial functions" or "functions" (depending on whether
the mapping covers the entire domain). In other words, "mapping" is the
more general name.
Being a math major this use of the word "map" is very confusing.
I use the terms "map" and "function" as synonyms. If I want to
describe a one-to-many or a many-to-may relation, I use the word
"relation".

<http://mathworld.wolfram.com/Map.html>
<http://mathworld.wolfram.com/Relation.html>

I.e. I support the choice "Map" for single-key->single-value collections
and "Dictionary" for single-key->multiple-value collections.
Post by s***@public.gmane.org
Dictionary at least Just Makes Sense, as real dictionaries bind words to
one or more definitions.
The word "relation" are also well known to most programmers due to the
wide spread use of relational databases, but "dictionary"
has in this context the advantage that one knows its a one-to-many relation
and not a many-to-many relation.
--
Jens Axel Søgaard
Continue reading on narkive:
Loading...