Alex Shinn <xxxxxx@gmail.com> schrieb am Mi., 24. Mai 2017 um 15:42 Uhr:
On Wed, May 24, 2017 at 2:39 PM, Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:
I have to admit that it is true that also "we" make mistakes when it
comes to the linear-update procedures. The test code of SRFI 113 assumes
that linear-update procedures modify their argument, see e.g. here:
https://github.com/scheme-requests-for-implementation/srfi-113/blob/master/sets/sets-test.scm#L153.
Some volunteer should correct the test cases (or take the SRFI 113 tests
from SRFI 146, where I had to fix it because the linear-update
procedures from the SRFI 146 sample implementation do not change their
argument).

I would like to suggest to take the following steps to make the Scheme
world a bit safer again:

1) The definition of linear update procedures in SRFI 146 should be
stricter by adding the following error conditions explicitly: "It is an
error to reference a (mapping) parameter after a linear-update procedure
has been invoked. It is an error not to reference the result of invoking
a linear-update procedure in its continuation."

I don't think the latter is a good idea, there can be valid uses
even without resorting to call/cc or just running a benchmark.


Now that I have thought more about it, I have come to the conclusion that forbidding not to reference the result is in fact not a good idea.

The problem is not so much about benchmarks where one could simply wrap a call whose result would otherwise be unused in a call to `reference-barrier` or the like from SRFI 124 to make sure that the result appears to be used.

Much worse, problems would already show up with day-to-day code:

(let ((x (append! list1 list2)))
  (write (if write? x #f)))

In case the flag ‘write?’ isn't set, the result of ‘append!’ may never be referenced (note that the Scheme implementation may optimize the above code by eliminating the variable `x` altogether).

--

Marc
 
A nice compiler should probably warn you if it sees the result
unused though.

-- 
Alex

To unsubscribe from this list please go to http://www.simplelists.com/confirm.php?u=oa8YQq670QJsajDJIblEsMJ9MoezHUAm