On 8/3/2011 9:43 PM, David Barbour wrote:
On Wed, Aug 3, 2011 at 7:24 PM, BGB <[email protected]
<mailto:[email protected]>> wrote:
If you have dynamic scope, you do not need TLS.
some people could potentially get annoyed or complain about having
to re-declare their thread-local dynamic variables when spawning a
thread.
The new thread should inherit the entire dynamic scope - logically, a
local copy thereof. If there are object references mixed in, then the
new thread now has a copy of these references, but the reference
variables initially point to shared objects.
actually, they would inherit the entire dynamic scope directly, but the
issue would be that dynamic variables which were not re-declared would
likely be shared with the parent (and so couldn't be modified without
effecting the parent).
dynamic var x;
x=3;
...
async { x=5; }
...
printf("%d\n", x); //prints 3
...
printf("%d\n", x); //now prints 5
however, cloning the bindings is an idea, and simpler than my other
considered idea, so I may consider it.
Most of my earlier language designs (until late 2007) used a variation
of dynamic scope
<http://c2.com/cgi/wiki?ExplicitManagementOfImplicitContext> I
developed in the context of distributed systems. I eventually
eliminated it for two reasons:
(1) Secure Interaction Design
<http://people.ischool.berkeley.edu/%7Eping/sid/>. Dynamic scope
violates the *path of least resistance, visibility,
*and*awareness* properties. A lot of authority gets hidden inside the
dynamic scope - hidden from both the sender and the potential user.
(2) Many optimizations (memoization, caching, multi-cast and
content-distribution, stable partial-evaluation and specialization),
especially across module or distribution boundaries, are difficult
unless we know exactly which parts of the input might influence the
response.
Today, I only allow explicit scope. Developers may explicitly model
implicit context when they want it, similar to State monad in Haskell.
I use lexical scope by default (after all, one needs an explicit
"dynamic" modifier to get dynamic scope on their variables...).
dynamic scope is mostly also kept around because there are edge cases
where it can be useful.
technically, dynamic scope has a lower priority than lexical scope
though (and a lower priority than object/class scope), so if any
lexically visible bindings exist, they will be bound against first.
technically, dynamic scope is just just prior to doing a full
brute-force search (following delegation chains, tracing through
packages, seeing if the C FFI knows about it, ...).
also, lexically-visible variables are often referenced by an index
number or similar, whereas most others are referenced by a name, and use
a sort of wandering recursive search, and are cached using hash-tables
and similar.
both the type semantics and scope semantics are "soft" (which I
personally prefer over the very rigid "complain over the littlest thing"
behavior of C# and Java).
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc