Re: Throwing lexicals

2002-09-10 Thread Me
I'm talking about just in the same namespace, how do we keep rules from messing with file-scoped (or any-scoped, for that matter) lexicals or globals. How do we get rule- or closure-scoped lexicals that are put into $0? How about something like the following rework of the

Re: Throwing lexicals

2002-09-10 Thread Damian Conway
Luke Palmer fretted: This is terrible. Calling foo which calls bar mysteriously overwrites $date? Why is $date changing? the programmer asks. He does an exhaustive search through his code and finally says ohh, and has to change all references to the inner $date to something like

Throwing lexicals

2002-09-09 Thread Aaron Sherman
I was thinking about regular expressions and hypotheticals again this weekend, and something was bothering me quite a lot. How do rules create hypotheticals? Since a rule behaves like a closure, I can see how it could gain access to existing lexicals, if it's declared inside of the same scope:

Re: Throwing lexicals

2002-09-09 Thread Luke Palmer
Going back to patterns, this gives us an added bonus. It not only explains the behavior of hypotheticals, but also of subexpression placeholders, which are created when the pattern returns: $self but lexicals(0=$self, 1= $self.{1}, 2= $self.{2}, etc...) That yields the side

Re: Throwing lexicals

2002-09-09 Thread Me
I may be missing your point, but based on my somewhat fuzzy understanding: Oh. Duh. Why don't we have such a mechanism for matches? m/ my $date := date / is ambiguous to the eyes. But I think it's necessary to have a lexical scoping mechanism for matches The above would at least have

Re: Throwing lexicals

2002-09-09 Thread Andrew Wilson
On Mon, Sep 09, 2002 at 02:14:25PM -0500, Me wrote: Hence the introduction of let: m/ { let $date := date } / which makes (a symbol table like entry for) $date available somewhere via the match object. Somewhere? where it appears in in the namespace of the caller. Apparently there

Re: Throwing lexicals

2002-09-09 Thread Luke Palmer
On Mon, 9 Sep 2002, Andrew Wilson wrote: On Mon, Sep 09, 2002 at 02:14:25PM -0500, Me wrote: Hence the introduction of let: m/ { let $date := date } / which makes (a symbol table like entry for) $date available somewhere via the match object. Somewhere? where it appears in

Re: Throwing lexicals

2002-09-09 Thread Andrew Wilson
On Mon, Sep 09, 2002 at 02:13:55PM -0600, Luke Palmer wrote: Err.. I don't think so. # Date.pm grammar Date; my $date; rule date_rule { $date := something } # uses_date.p6 (hmm.. I wonder what a nice extension would be...) use Date; my

Re: Throwing lexicals

2002-09-09 Thread Aaron Sherman
On Mon, 2002-09-09 at 15:12, Luke Palmer wrote: Going back to patterns, this gives us an added bonus. It not only explains the behavior of hypotheticals, but also of subexpression placeholders, which are created when the pattern returns: [...] I think this is a very clean and simple way