[closer-devel] slots on layers
Pascal Costanza
pc at p-cos.net
Fri Oct 3 14:24:16 UTC 2008
Hi,
Back to this topic... ;)
I wanted to write a response where I comment on the fact that I find
dynamic-wind quite questionable - primarily because the dynamic
environments established with dynamic-wind are not first-class.
Dynamic-wind is actually also a controversial feature in the Scheme
community - it can be shown that call/cc with dynamic-wind can be
implemented in terms of call/cc without dynamic-wind, but not the
other way around, so in a 'minimal' language, dynamic-wind is actually
not necessary.
But after spending some more thought on this, I think I can propose a
solution that should make everybody happy.
Assume we have a function current-dynamic-environment and a macro with-
dynamic-environment with which you can get and set the current dynamic
environment. The idea is that specifically registered special
variables can be captured in such dynamic environments. For example,
all special slots in special classes, and the current layer context
will be such registered special variables. On top of that, it will be
possible to switch off support for dynamic environments completely
for people who really don't like them. (There will be a restriction
wrt side effects - assignments to such special variables will probably
not be recorded correctly in all situations. But that shouldn't be a
too strong restriction, because you typically rebind such variables
rather than set them. I will provide a detailed description when
assignments work and when they don't.)
Now, if you have support for call/cc in some other library, you can
add support for ContextL dynamic enviroments like this:
(defun dcall/cc (continuation)
(let ((dynamic-environment (current-dynamic-environment)))
(call/cc (lambda (k)
(funcall continuation (lambda (value)
(with-dynamic-environment
dynamic-environment
(funcall k value))))))))
It should also be possible to integrate support for both ContextL
dynamic environments and dynamic-wind into one construct, if necessary.
Next, there should be a way to support partial continuations. My
current idea is to have something like a function mark-dynamic-
environment that marks a portion of the current dynamic environment,
and that current-dynamic-environment can refer to such marks. So for
example, something like this:
(let ((mark (mark-current-dynamic-environment)))
...
... (current-dynamic-environment mark) ...
...)
The idea is that current-dynamic-environment captures the current
environment up until the specified mark (and if no mark is given, the
whole dynamic environment is captured).
There should then also be a form of with-dynamic-environment with
reestablishes such a partial dynamic environment - don't know exactly
how to do that yet.
Partial dynamic environments should make it easier to work correctly
with partial continuations, and since that's what you typically get
for Common Lisp, I think that's quite important.
So, do you think that the sketched solution covers the major concerns?
Pascal
--
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium
More information about the closer-devel
mailing list