Dynamic scoping (was: Proposal: Squeak-E = Squeak x Kernel-E)

Stephen Pair spair at acm.org
Mon Jan 27 21:03:04 UTC 2003


What is not clear about those semantics?  Since the transcript output
occurs before setting the value, the correct output is:

0
0

Originally, I wanted the ability set a value for all subsequent
operations that occur in a process...however, to accomplish that *and*
use the stack for maintaining scope enclosures would be quite convoluted
(if at all possible).  And, it's also not clear to me at this point
whether or not I really need that ability.

- Stephen

> -----Original Message-----
> From: squeak-dev-bounces at lists.squeakfoundation.org 
> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On 
> Behalf Of Avi Bryant
> Sent: Monday, January 27, 2003 3:29 PM
> To: The general-purpose Squeak developers list
> Subject: RE: Dynamic scoping (was: Proposal: Squeak-E = 
> Squeak x Kernel-E)
> 
> 
> 
> On Mon, 27 Jan 2003, Stephen Pair wrote:
> 
> > Actually, I rather like the #dynamicValue pattern.  Why not 
> this then:
> >
> > ----
> > DynamicContext clamp: [
> > 	#foo dynamicValue: 42.
> > 	self assert: #foo dynamicValue = 42
> > ].
> >
> > self assert: #foo dynamicValue isNil
> > ----
> >
> > With the above, if you need to set several values, you 
> don't need to 
> > enclose your code in several blocks.
> 
> True, but I find the semantics less clear. Say I capture a 
> continuation just before the call to #dynamicValue:, and then 
> come back to it:
> 
> |k|
> 
> #foo dynamicValue: 0.
> DynamicContext clamp: [
>   k := Continuation current.
>   Transcript cr; show: #foo dynamicValue.
>   #foo dynamicValue: 42.
> ]
> 
> k ifNotNil: [k value].
> 
> Does this show
> 
> 0
> 0
> 
> or
> 
> 0
> 42
> 
> on the Transcript?
> 
> If you want to be able to set multiple bindings at once, I 
> would suggest
> 
> DynamicContext bindAll: {#foo -> 42} during: [...]
> 
> 
> 
> 
> 



More information about the Squeak-dev mailing list