From: Trans Date: 2005-10-02T05:26:46+09:00 Subject: Re: ideas for an RCR: variable locality Eric Mahurin wrote: > --- Trans wrote: > > > And a way to share vars from the above scope specifically: > > > > z = lambda [ > > share :x > > ] > > I was hoping to not bring in any type of variable declaration > syntax (like perl's my/our/local) into play. I undertsnad but then you start getting into more syntax hacks like { |x,y; z|... }. That;s even worse. At least the above is simple and clear. > I was also > thinking that this type of block would have no write access to > the variables in the surrounding scope (block would need to > return data instead). Yes, I am too. You'd have to use #share to open a variable up. > You could give read-only access when the > block accesses one of its variables not yet assigned to (get > the value from the containing scope): > > x = 1+2 > z = lambda {{ > # becomes equivalent to y = (x=3) when compiled > y = x > }} That's cool. So you'd really only need a way to "send it out". hmmm.. #share cuold work for that, it's would then be more like #return instead of a declaration. > Hopefully this could be done in such a way so that once that > block is created it doesn't need access to its containing scope > anymore and you don't have to worry about the block preventing > GCing stuff in that scope (as you do with normal blocks). > Although you wouldn't be able to get the Binding of this type > of block, you would still want to have a way to get the file, > line, (and column?) of where the block was created. > > > Since hash and block share literal deliminators, it only > > seems fair > > that array do the same ;-) > > But [] is also an operator and {} is not. To use [] for a > different type of block, you'd have to differentiate between it > and the [] operator based on spacing - which I think is bad. That's true. But hey let's open up {} as an operator too. I'm not afraid of the spacebar! Besides I never put spaces before my [] operators anyway, and really who does? T.