Re: pdd20 and :outer

2005-11-23 Thread Dave Mitchell
On Tue, Nov 22, 2005 at 09:32:37AM -0800, Chip Salzenberg wrote: > On Tue, Nov 22, 2005 at 03:28:02PM +0100, Leopold Toetsch wrote: > > sub do_add3 { > > my $a = $_[0]; > > sub add3 { > > $a + 3; > > } > > add3(); > > } > > What Perl 5 does with that case is just a plain ol

Re: pdd20 and :outer

2005-11-23 Thread Roger Browne
Thanks to Leo and Will for clarifications, and to Leo for the r10150 bugfix. That has enabled me to implement lexical handling for Amber. With Parrot doing most of the heavy lifting, it wasn't too hard. Now I just have to write the tests and documentation :-) Leo wrote: > BTW I had to change (r101

Re: pdd20 and :outer

2005-11-23 Thread Leopold Toetsch
Roger Browne wrote: .sub add3 :method :outer('do_add3')#(4) .param pmc arg $P0 = n_add arg, 3 #(5) .return($P0) .end This segfaults at #(3). Actually at #(5) - replace line #(5) by "$P0 = n_neg arg" (the significance The reason was lexical lookuo inside M

Re: pdd20 and :outer

2005-11-23 Thread Roger Browne
I ran into a problem trying to convert Leo's "Case 1" example so that it uses methods instead of subs. Here's how far I got: .HLL 'Amber', 'amber_kernel' .sub main :main newclass $P0, 'FOO' $P1 = new 'FOO' $P1.main() .end .namespace [ "FOO" ] .sub main :method $P0 = self.do_add3(20

Re: pdd20 and :outer

2005-11-22 Thread Leopold Toetsch
On Nov 22, 2005, at 18:32, Chip Salzenberg wrote: OTOH, that same case in Perl 6 is a normal closure and is supported with the default LexPad: Ok. I'll change implementation accordingly. Below is the full code of case 1 / outer.pir leo .pragma n_operators 1 # add creates new PMC

Re: pdd20 and :outer

2005-11-22 Thread Chip Salzenberg
On Tue, Nov 22, 2005 at 09:42:38AM -0800, jerry gay wrote: > your example in the previous message made me think. what will parrot > do if a parrot sub declares the :outer subpragma, and the sub to which > it refers doesn't have a lexical pad? Nothing; that's entirely legal. And it's even useful,

Re: pdd20 and :outer

2005-11-22 Thread jerry gay
your example in the previous message made me think. what will parrot do if a parrot sub declares the :outer subpragma, and the sub to which it refers doesn't have a lexical pad? something like: .sub do_add3 .const .Sub add3 = "add3" $P1 = newclosure add3

Re: pdd20 and :outer

2005-11-22 Thread Chip Salzenberg
On Tue, Nov 22, 2005 at 09:32:37AM -0800, Chip Salzenberg wrote: > $P0 = fetch_lex '$a' I meant "find_lex", of course. PS: fetch_*, get_*, find_*, ... so many naming conventions, so little reason for them. -- Chip Salzenberg <[EMAIL PROTECTED]>

Re: pdd20 and :outer

2005-11-22 Thread Chip Salzenberg
On Tue, Nov 22, 2005 at 03:28:02PM +0100, Leopold Toetsch wrote: > Below are two cases of inner subs in Perl5 and Python. The first > (do_add3) is a plain nested subroutine, which is in the call chain. The > second (mk_add3) uses a closure. perl5 can't deal with case 1 properly > and warns. > >

pdd20 and :outer

2005-11-22 Thread Leopold Toetsch
Below are two cases of inner subs in Perl5 and Python. The first (do_add3) is a plain nested subroutine, which is in the call chain. The second (mk_add3) uses a closure. perl5 can't deal with case 1 properly and warns. The question is: should Parrot cover case 1 too with :outer and it's defau