Steve Wampler writes:
>> I felt, and still do, that it would be practical to optimize this so
>> that you only heap allocate a part of the environment, only those
local
>> variables that occur in a create statement. These variables would be
>> given a special class, not "global" or "local", but "heap", and would
be
>> accessed by a special virtual machine instruction. This would have no
>> (or very little) effect on programs that do not use c-expressions.
>
>I had forgotten aobut c-expressions! Thanks for reminding me. The
>behavior of c-expressions is very close to being a superior replacement
>for co-expressions (a few programs might break, but I bet it would be
>surprisingly few...)
>
>I think Dave is right - this would be (have been?) a nice language
feature,
>especially if implemented as he suggests (if I had thought of it, I
>probably would have implemented co-expressions that way to begin with).
>Replacing co-expressions with c-expressions would likely be a net win,
but I
>suspect is more of a change than anyone is willing to do at this
time...
You know, I wonder if it would be all that hard. I don't know how Clint
implemented objects, but it now that I think about it, what I'm
suggesting is just object-local variables where the coexpression is the
one and only method of the object. How hard would it be to flag all
local variables that occur in coexpressions and put them in an object
instead? I'm pretty sure the ! operator would be easy to implement. One
big advantage of this change is that it would remove the need for
stack-switching code from the implementation.
Hmm. As long as I'm getting carried away, why not allow parameters as
well? I'm thinking of something like
f := create(x,y) {2*x + y}
which could be called like a function f(2,3) to produce 7 or like an SL5
procedure call:
f with (2,3) #binds x to 2 and y to 3
i := @f # activates f with its current parameters
every !f # generates all values of f with current parameters
f with (4,5) #binds new parameters
j := @f # activates f with new parameters
This gives coroutines with 2-way message passing. Notice that @f
generates one result with the current bindings, !f generates a result
sequence with the current bindings, and f() generates a result sequence
with all-null bindings.
Then, of course, you would also allow access to the local variables like
this
f.x := 3 # bind the parameter x to 3
k := f.x # set k to the current value of the parameter x
_______________________________________________
Unicon-group mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/unicon-group