[Scheme-reports] 6.4 control features: -map and -for-each procedures
Andy Wingo 19 May 2011 19:31 UTC
Hello! Where was I? :)
Right, control features. I already mentioned the
multiple-return-from-mapping proc issue before. There are three options
that I am aware of:
1) Ignore the issue.
2) Specify that a second return from a mapped procedure cannot affect
the data structure returned by the first return. Effectively
prohibits the build-it-backwards-and-reverse-in-place idiom, though
you may reverse and form a new list.
3) Specify that it is an error to return multiple times.
Suggestion: choose one.
Suggestion: that it be an error for a mapped procedure to mutate the
list being mapped.
Also, what is the motivation for having multi-arg `map' terminate at the
first empty list? If it is to allow for circular lists, then the
implicit type of `map' is incorrect:
(map PROC LIST1 LIST2 ...)
because AFAIK a circular list does not pass `list?'.
Suggestion: provide a rationale, or revert to the previous spec.
Perhaps mention the expected behavior for circular lists.
The multiple-return issue is more important for string-map and
vector-map, IMO, as one natural technique would be mutate a string or
vector in-place.
Suggestion: choose a behavior for vector-map consistent with the
previous choice, or remove vector-map and string-map from the spec.
The early-termination behavior seems to have no corresponding
justification for vector-map and string-map.
Which, now that we've come to it, I don't like very much:
1) The obvious implementation (mutate-in-place) should be allowed, but
it prevents multiple returns, so perhaps it's not general enough
for this spec.
2) Vector-fold is often really what you want.
3) Vector-map is not common.
4) String-map is less common.
5) You'd need blob-map to be complete, for this report...
Basically I think they are sometimes useful combinators, but not useful
enough for WG1 scheme, and trivial to build yourself.
Suggestion: remove vector-map, string-map, and their for-each procedures
from the WG1 report.
Andy
--
http://wingolog.org/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports