Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Dynamically Scoped Dynamic Scopes
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dave Whipp  
View profile  
 More options Feb 27 2005, 1:52 pm
Newsgroups: perl.perl6.language
From: d...@whipp.name (Dave Whipp)
Date: Sun, 27 Feb 2005 10:52:58 -0800
Local: Sun, Feb 27 2005 1:52 pm
Subject: Dynamically Scoped Dynamic Scopes
I was thinking about scopes (for a problem unrelated to Perl 6), and I
realised that the scoping concepts in P6 are somewhat limited.

We have

   my $var   # lexical scope
   temp $var # lexically-scoped dynamic scope

C<temp> is lexically scoped in that its effect goes away at the closing
curly of the lexical scope that contains it.

A concept that we seem to be missing is the possibility of dynamically
scoped dynamic scopes. I hesitate to come up with a syntax; but I can
think of a couple of examples where it might be used. Caveat: if you
beleive that globals are fundamentally evil, and that everything should
be objects, then this is unnecessary. but for other people ...

Example 1: Create a dynamic scope, and then spawn N threads. Each thread
has its own lexical scope. After each thread has done some work, each
reaches a barrier. Once all the threads have reached that barrier, we
terminate the dynamic scope that we previously introduced: the threads
then continue in their lexical scopes, but with the different dynamic scope

Example 2: a state machine: imagine binding a number of variables into a
"scope space", in which we then instance multiple scopes. We can then
create a state machine in which we change the currently visible values
of the scoped variables by changing the "current scope" of the "scope
space".

One could imagine implementing this by creating the scopes as instances
of an object, and then binding the object's attributes onto the
variables (i.e. "our $foo := $obj.bar"). The "scope space" object would
then be the set of global vaiables to be bound; and the "scope" object
would be the set of values to bind.

However, when we want to release the global vaiables from our scope,
then we need a way to unbind the variables, and restore them to the
bindings that existed before they were bound to our scope space. I'm not
sure how to do that, because we don't have any builtin concept of
dynamically scoped scopes.

Dave.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Mar 1 2005, 8:38 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Tue, 1 Mar 2005 17:38:50 -0800
Local: Tues, Mar 1 2005 8:38 pm
Subject: Re: Dynamically Scoped Dynamic Scopes
On Sun, Feb 27, 2005 at 10:52:58AM -0800, Dave Whipp wrote:

: One could imagine implementing this by creating the scopes as instances
: of an object, and then binding the object's attributes onto the
: variables (i.e. "our $foo := $obj.bar"). The "scope space" object would
: then be the set of global vaiables to be bound; and the "scope" object
: would be the set of values to bind.
:
: However, when we want to release the global vaiables from our scope,
: then we need a way to unbind the variables, and restore them to the
: bindings that existed before they were bound to our scope space. I'm not
: sure how to do that, because we don't have any builtin concept of
: dynamically scoped scopes.

Hmm.  Just sounds to me like a form of tying involving delegation.
Piece o' cake.  Syntax left for the module author to decide, if a
special declarator is needed in preference to standard variable-type
syntax.

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »