Re: return() in pointy blocks

2005-07-04 Thread Larry Wall
On Mon, Jul 04, 2005 at 07:01:00PM +0200, "TSa (Thomas Sandlaß)" wrote: : Larry Wall wrote: : >On Wed, Jun 08, 2005 at 12:37:22PM +0200, "TSa (Thomas Sandlaß)" wrote: : >: BTW, is -> on the 'symbolic unary' precedence level : >: as its read-only companion \ ?. : > : >No, -> introduces a term that h

Re: return() in pointy blocks

2005-07-04 Thread TSa (Thomas Sandlaß)
Larry Wall wrote: On Wed, Jun 08, 2005 at 12:37:22PM +0200, "TSa (Thomas Sandlaß)" wrote: : BTW, is -> on the 'symbolic unary' precedence level : as its read-only companion \ ?. No, -> introduces a term that happens to consist of a formal signature and a block. There are no ordinary expressions

Re: return() in pointy blocks

2005-06-09 Thread Piers Cawley
Larry Wall <[EMAIL PROTECTED]> writes: > On Wed, Jun 08, 2005 at 10:51:34PM +, Luke Palmer wrote: > : Yeah, that's pretty. But that will bite people who don't understand > : continuations; it will bite people who don't understand "return"; it > : will even bite people who understand continuat

Re: return() in pointy blocks

2005-06-09 Thread Piers Cawley
Luke Palmer <[EMAIL PROTECTED]> writes: > On 6/8/05, Piers Cawley <[EMAIL PROTECTED]> wrote: >> > In other words, it outputs: >> > >> >Foo >> >Foo >> ># dies > > Yep. My mistake. > >> If that works, then I think it means we can write: >> >> sub call-with-current-continuation(Code

Re: return() in pointy blocks

2005-06-08 Thread Larry Wall
On Wed, Jun 08, 2005 at 10:51:34PM +, Luke Palmer wrote: : Yeah, that's pretty. But that will bite people who don't understand : continuations; it will bite people who don't understand "return"; it : will even bite people who understand continuations, because they can : be made in such an awkw

Re: return() in pointy blocks

2005-06-08 Thread Luke Palmer
On 6/8/05, Piers Cawley <[EMAIL PROTECTED]> wrote: > > In other words, it outputs: > > > >Foo > >Foo > ># dies Yep. My mistake. > If that works, then I think it means we can write: > > sub call-with-current-continuation(Code $code) { > my $cc = -> $retval { return $retva

Re: return() in pointy blocks

2005-06-08 Thread Piers Cawley
"TSa (Thomas Sandlaß)" <[EMAIL PROTECTED]> writes: > Piers Cawley wrote: >> [..] then I think it means we can write: >> sub call-with-current-continuation(Code $code) { >> my $cc = -> $retval { return $retval } > > For the records: the return here is the essential ingredient, right? >

Re: return() in pointy blocks

2005-06-08 Thread Larry Wall
On Wed, Jun 08, 2005 at 12:37:22PM +0200, "TSa (Thomas Sandlaß)" wrote: : BTW, is -> on the 'symbolic unary' precedence level : as its read-only companion \ ?. No, -> introduces a term that happens to consist of a formal signature and a block. There are no ordinary expressions involved until you

Re: return() in pointy blocks

2005-06-08 Thread TSa (Thomas Sandlaß)
Piers Cawley wrote: [..] then I think it means we can write: sub call-with-current-continuation(Code $code) { my $cc = -> $retval { return $retval } For the records: the return here is the essential ingredient, right? Without it the block would be evaluated or optimized away to an

Re: return() in pointy blocks

2005-06-08 Thread TSa (Thomas Sandlaß)
Piers Cawley wrote: "TSa (Thomas Sandlaß)" <[EMAIL PROTECTED]> writes: Piers Cawley wrote: My preference is for: Boo Boo Can't dereferene literal numeric literal 42 as a coderef. How do you reach the second 'Boo'? Iff -> does not create a Sub but a Block instance then Luke's code

Re: return() in pointy blocks

2005-06-08 Thread Piers Cawley
Piers Cawley <[EMAIL PROTECTED]> writes: > "TSa (Thomas Sandlaß)" <[EMAIL PROTECTED]> writes: > >> Piers Cawley wrote: >>> My preference is for: >>> Boo >>> Boo >>> Can't dereferene literal numeric literal 42 as a coderef. >> >> How do you reach the second 'Boo'? Iff -> does not create

Re: return() in pointy blocks

2005-06-08 Thread Piers Cawley
"TSa (Thomas Sandlaß)" <[EMAIL PROTECTED]> writes: > Piers Cawley wrote: >> My preference is for: >> Boo >> Boo >> Can't dereferene literal numeric literal 42 as a coderef. > > How do you reach the second 'Boo'? Iff -> does not create a Sub > but a Block instance then Luke's code can b

Re: return() in pointy blocks

2005-06-08 Thread TSa (Thomas Sandlaß)
Piers Cawley wrote: My preference is for: Boo Boo Can't dereferene literal numeric literal 42 as a coderef. How do you reach the second 'Boo'? Iff -> does not create a Sub but a Block instance then Luke's code can be interpreted as a much smarter version of sub foo() {

Re: return() in pointy blocks

2005-06-08 Thread TSa (Thomas Sandlaß)
Well, does using -> as blockref creator also give anonymous scalars? $y = -> $x { $x = 3; $x }; # $y:(Ref of Block of Int) BTW, is -> on the 'symbolic unary' precedence level as its read-only companion \ ?. Are they pure macros? -- TSa (Thomas Sandlaß)

Re: return() in pointy blocks

2005-06-08 Thread Piers Cawley
Luke Palmer <[EMAIL PROTECTED]> writes: > On 6/7/05, Matt Fowles <[EMAIL PROTECTED]> wrote: >> On 6/7/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote: >> > Hi, >> > >> > sub foo (Code $code) { >> > my $return_to_caller = -> $ret { return $ret }; >> > >> > $code($return_to_caller); >> >

Re: return() in pointy blocks

2005-06-08 Thread TSa (Thomas Sandlaß)
Luke Palmer wrote: Says not: Boo Boo Boo ... This is clear, but I would expect the output Boo 42 because the return value of foo is a ref to a block that makes the caller return 42. This is written in my current Perl6 as &foo:( : --> Block --> 42) The question is when exa

Re: return() in pointy blocks

2005-06-07 Thread Matt Fowles
All~ On 6/7/05, Luke Palmer <[EMAIL PROTECTED]> wrote: > On 6/7/05, Matt Fowles <[EMAIL PROTECTED]> wrote: > > On 6/7/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > sub foo (Code $code) { > > > my $return_to_caller = -> $ret { return $ret }; > > > > > > $code($ret

Re: return() in pointy blocks

2005-06-07 Thread Luke Palmer
On 6/7/05, Luke Palmer <[EMAIL PROTECTED]> wrote: > Then let's put it this way: > >sub foo () { >for 0..10 { >when 6 { return 42 } >} >return 26; >} > > And if that didn't do it, then let's write it equivalently as: > >sub foo () { >&map(->

Re: return() in pointy blocks

2005-06-07 Thread Luke Palmer
On 6/7/05, Matt Fowles <[EMAIL PROTECTED]> wrote: > On 6/7/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote: > > Hi, > > > > sub foo (Code $code) { > > my $return_to_caller = -> $ret { return $ret }; > > > > $code($return_to_caller); > > return 23; > > } > > > > sub bar (Code $retu

Re: return() in pointy blocks

2005-06-07 Thread Ingo Blechschmidt
Hi, Matt Fowles wrote: > On 6/7/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote: >> sub foo (Code $code) { >> my $return_to_caller = -> $ret { return $ret }; >> >> $code($return_to_caller); >> return 23; >> } >> >> sub bar (Code $return) { $return(42) } >> >> say foo &bar; #

Re: return() in pointy blocks

2005-06-07 Thread Piers Cawley
Ingo Blechschmidt <[EMAIL PROTECTED]> writes: > Hi, > > sub foo (Code $code) { > my $return_to_caller = -> $ret { return $ret }; > > $code($return_to_caller); > return 23; > } > > sub bar (Code $return) { $return(42) } > > say foo &bar; # 42 or 23? > > I think

Re: return() in pointy blocks

2005-06-07 Thread Matt Fowles
Ingo~ On 6/7/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote: > Hi, > > sub foo (Code $code) { > my $return_to_caller = -> $ret { return $ret }; > > $code($return_to_caller); > return 23; > } > > sub bar (Code $return) { $return(42) } > > say foo &bar; # 42 or 23? > > I th