[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

One more voice on "linear update" and "!"

This page is part of the web mail archives of SRFI 1 from before July 7th, 2015. The new archives for SRFI 1 contain all messages, not just those from before July 7th, 2015.

I've been thinking a lot about the whole linear update issue, and I agree
that having a way to advise the system about object use without forcing a
particular paradigm (destructive or not) is a good thing. However, the
simple fact is that the pre-existing meaning of "!" in Scheme is *not*
linear update--it is destructive modification--as most obviously
demonstrated by these procedures:


What would each of these mean if they were linear update anyway? They all
return unspecified values, for one thing, so if they were recast in a
linear update light, that would have to change. But let's say that you did
that, then there are still problems. For example, set-cdr! is often used to
create circular lists, but if it were defined to be nondestructive in a
particular implementation, there would be no way to do this.

set! as linear update is even trickier. In terms of setting globals, you
would have to think about it in terms of being an operation on the entire
global environment (e.g., replacing the environment with an identical one
except for a new binding for the variable in question). In terms of setting
locals, you would have to think about it in terms of being an operation on
the continuation, similarly replacing the continuation with an identical
one modulo the specified variable binding. What does it mean in these cases
to be nondestructive? And in the local variable case, what are the
implications with respect to multiple calls to the same continuation in a
system that defined these procedures nondestructively?

Let me reiterate that I like the concept of linear update. (I am pre-sold
on the overall benefits to keeping data, to the extent possible, immutable,
and this is one way to make that possible without simultaneously losing
efficiency.) However, I think it's a bad idea to usurp "!" in Scheme for
that meaning, since it will only lead to confusion--some but not all "!"
procedures one encounters would be linear-update, and some would be
required-destructive. I can already hear the screams of millions of unhappy
programmers shooting themselves in the feet. I expect I'm too late to
really influence anything, but I felt that, even at the 11th hour, it was
worth it to try.