Linear update - just say no [was: New draft (#6) of SRFI 146: Mappings]
Per Bothner 02 May 2017 22:15 UTC
"Linear update" APIs make me very uncomfortable and nervous.
Names like mapping-set! and mapping-replace! are especially dangerous,
and most definitely do not belong in a programming-language standard as
would be used by typical textbooks and programmers, at least without
compiler support. It's just guaranteed to lead to unportable programs
and hard-to-find bugs.
If there were some way to annotate a procedure with a "result-must-be-used"
property then one might consider the idea, but as it is: don't.
The procedure mapping-replace! must be *guaranteed* to update-in-place
its first parameter, and should have unspecified result.
The linear-update versions should be moved to a separate library, and
renamed to something line mapping-linear-replace.
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/