[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
"unspecified" and SET!
Date: 19 Jun 89 23:24:37 GMT
From: Dorai Sitaram <firstname.lastname@example.org>
How do you deal with the other "commands" of Scheme? (E.g., READ,
SET-CAR!, PRINTF.) Easier than SET!. SIGMA-like counterparts need
_not_ be made for these, as that would lead to a plethora of special
forms (as opposed to 'procedures'). All of these "command"
procedures now take an additional argument for "the body" (thunk
actually) whose value is returned.
So we would write
(WRITE X (CURRENT-OUTPUT-PORT)
(LAMBDA () X))))
to newline, and then output and return the current value of X. (Or perhaps
the continuations are passed as the first argument -- it doesn't matter in
the current discussion.)
Now it would seem to me that the most uniform way to include assignment in
this scheme, is to have SET! take a continuation as well. So
(SET! X (+ X 1)
(LAMBDA () X))
would increment the value of X and return the new value.
SET! is still a keyword, so this isn't -exactly- parallel with the
side-effecting procedures. But I'll bet that once people start writing
programs using this scheme, the thing that will impress them the most is
that whenever they perform a side-effect they have to create an explicit
continuation to wait for the side-effect to happen. And I'll bet they will
be most comfortable if they have to make exactly the same kind of
continuation for SET!.
I'm currently working on a language where users really -must- control
sequencing by explicitly using thunks, so I'm very interested in linguistic
constructs that support this style. Actually, in my case its worse than in
plain Scheme, because users must also exert control over when variables are
-read- as well as written. Thus users have to write something like
(SET! X (+ 1 VALUE)
to increment the value of X, because if they wrote
(SET! X (+ 1 X)
the occurrence of X in (+ 1 X) might be taken to refer to the value of X
-after- the SET! happens (so that the value of X would become the fixed
point of (lambda (n) (+ 1 n))!).