"Get rid of linear update!" and responses Wolfgang Corcoran-Mathe (10 Jun 2021 15:26 UTC)
Re: "Get rid of linear update!" and responses Per Bothner (10 Jun 2021 15:47 UTC)
Re: "Get rid of linear update!" and responses Marc Nieper-Wißkirchen (10 Jun 2021 16:12 UTC)
Re: "Get rid of linear update!" and responses Per Bothner (10 Jun 2021 16:27 UTC)
Re: "Get rid of linear update!" and responses Marc Nieper-Wißkirchen (10 Jun 2021 16:38 UTC)
Re: "Get rid of linear update!" and responses Marc Nieper-Wißkirchen (11 Jun 2021 08:36 UTC)
Re: "Get rid of linear update!" and responses Arvydas Silanskas (11 Jun 2021 17:13 UTC)
Re: "Get rid of linear update!" and responses Wolfgang Corcoran-Mathe (11 Jun 2021 17:21 UTC)
Re: "Get rid of linear update!" and responses Arvydas Silanskas (11 Jun 2021 17:32 UTC)
Re: "Get rid of linear update!" and responses Per Bothner (11 Jun 2021 18:36 UTC)
Re: "Get rid of linear update!" and responses John Cowan (12 Jun 2021 04:30 UTC)

Re: "Get rid of linear update!" and responses Per Bothner 10 Jun 2021 16:27 UTC


On 6/10/21 9:11 AM, Marc Nieper-Wißkirchen wrote:
> A typical coding error would be:
>
> (let ((mymap (mapping default-comparator 'a 1 'b 2)))
>    (mapping-set! mymap 'c 3)
>    (mapping-ref mymap 'c)) ;=> 3 ???
>
> In our proposal, a quality implementation will set a flag on the corpse of MYMAP that has been left by mapping-set!. This flag will make sure that an assertion violation is triggered by the subsequent mapping-ref.
>
> Note that SRFI 1 is, again, quite different. Although it began the use of linear update procedures, it works on a concrete, transparent data type. There, I don't have room for an I-am-a-corpse-flag.

Better to catch this at compile-time - which also works for SRFI-1.
However, you'd need a mechanism to annotate procedure with a 'result-must-be-used
property, which the compiler can check.  (Calls using apply would be too
difficult to handle, but would presumably be rare for linear-upadte procedures.)

Even better: Don't. It's a user-hostile idiom, which should be resticted
to "for-expert-users-only" libraries.
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/