[perl #81336] [BUG] infix:~~ isn't chaining in Rakudo

2010-12-27 Thread Carl Mäsak
# New Ticket Created by Carl Mäsak # Please include the string: [perl #81336] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81336 masak rakudo: say 0 ~~ 0 ~~ 0 p6eval rakudo cae7f9: OUTPUT«Bool::False␤» * masak

Q: Code example in Using Perl 6 - methods and spaces.

2010-12-27 Thread Daniel Carrera
Hello, After a long absence (been busy) I'm trying to re-learn Perl 6. I'm reading the book Using Perl 6, from Jonathan S, Moritz, Mäsak, PM and Jonathan W.: http://github.com/downloads/perl6/book/2010.08.a4.pdf I tested the first program using the latest release of Rakudo Star. The first

Re: Q: Code example in Using Perl 6 - methods and spaces.

2010-12-27 Thread Darren Duncan
Daniel Carrera wrote: I tested the first program using the latest release of Rakudo Star. The first program has the following: my @sorted = @names.sort({ %sets{$_} }).sort({ %matches{$_} }).reverse; This works correctly, but it's long and I'd rather format this line like this: This works

Re: Q: Code example in Using Perl 6 - methods and spaces.

2010-12-27 Thread Daniel Carrera
On Mon, Dec 27, 2010 at 8:37 PM, Darren Duncan dar...@darrenduncan.netwrote: A relevant reading would be http://perlcabal.org/syn/S02.html#Whitespace_and_Comments I think; what you are trying to do may not directly be allowed, though there may be workarounds such as by using unspace.

Q: Is there a reason why I can't do this?

2010-12-27 Thread Daniel Carrera
Hello, Looking at the first example in Using Perl6, I have: if $r1 $r2 { %matches{$p1}++; } else { %matches{$p2}++; } I was thinking that it should be possible to make this more compact, but the two ideas I tried didn't work: # Idea 1 gives: Unable to parse postcircumfix:sym{ },

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Chas. Owens
On Mon, Dec 27, 2010 at 15:46, Daniel Carrera dcarr...@gmail.com wrote: Hello, Looking at the first example in Using Perl6, I have: if $r1 $r2 {    %matches{$p1}++; } else {    %matches{$p2}++; } I was thinking that it should be possible to make this more compact, but the two ideas I

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Tadeusz Sośnierz
On 27-12-2010 21:46:05, Daniel Carrera wrote: Hello, Looking at the first example in Using Perl6, I have: if $r1 $r2 { %matches{$p1}++; } else { %matches{$p2}++; } I was thinking that it should be possible to make this more compact, but the two ideas I tried didn't work:

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Daniel Carrera
On Mon, Dec 27, 2010 at 9:49 PM, Chas. Owens chas.ow...@gmail.com wrote: The [conditional operator][1] is now spelled test ?? true !! false not test ? true : false. Thanks! Now the following code works: %matches{ $r1 $r2 ?? $p1 !! $p2 }++; I'm still having trouble with the other

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Chas. Owens
On Mon, Dec 27, 2010 at 15:55, Daniel Carrera dcarr...@gmail.com wrote: On Mon, Dec 27, 2010 at 9:49 PM, Chas. Owens chas.ow...@gmail.com wrote: The [conditional operator][1] is now spelled test ?? true !! false not test ? true : false. Thanks! Now the following code works: %matches{  $r1

Re: Q: Code example in Using Perl 6 - methods and spaces.

2010-12-27 Thread Moritz Lenz
On 12/27/2010 09:12 PM, Daniel Carrera wrote: Thanks. The blacklash unspace works. my @sorted = @names.sort({ %sets{$_} })\ .sort({ %matches{$_} })\ .reverse; Though I'm a bit sad that you need that and you can't just separate methods with spaces.

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Moritz Lenz
On 12/27/2010 09:55 PM, Daniel Carrera wrote: On Mon, Dec 27, 2010 at 9:49 PM, Chas. Owens chas.ow...@gmail.com wrote: The [conditional operator][1] is now spelled test ?? true !! false not test ? true : false. Thanks! Now the following code works: %matches{ $r1 $r2 ?? $p1 !! $p2

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Chas. Owens
On Mon, Dec 27, 2010 at 16:00, Chas. Owens chas.ow...@gmail.com wrote: On Mon, Dec 27, 2010 at 15:55, Daniel Carrera dcarr...@gmail.com wrote: On Mon, Dec 27, 2010 at 9:49 PM, Chas. Owens chas.ow...@gmail.com wrote: The [conditional operator][1] is now spelled test ?? true !! false not test ?

Re: Q: Code example in Using Perl 6 - methods and spaces.

2010-12-27 Thread Daniel Carrera
On Mon, Dec 27, 2010 at 10:00 PM, Moritz Lenz mor...@faui2k3.org wrote: But there's a good reason: .method is a term on its own, and actually means $_.method. So if you write @names.foo .bar, that's two terms in a row. That is indeed a good reason. I think I knew about it but forgot. That

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Daniel Carrera
On Mon, Dec 27, 2010 at 10:03 PM, Chas. Owens { } by itself creates a lambda (i.e. an anonymous function), so it may be that you are returning an anonymous function that never gets executed. Try using parentheses instead of braces. Or better yet, don't use anything. Since ++ has higher

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Daniel Carrera
On Mon, Dec 27, 2010 at 10:03 PM, Moritz Lenz wrote: or my $closure = $r1 $r2 ?? { %matches{$p1}++ } !! { %matches{$p2}++ }; # invoke it $closure(); That's very cool. Perl 6 is a functional language with lambdas and everything. Daniel. -- No trees were destroyed in the generation of

[perl #81352] [BUG] defined returns Int rather than Bool results in Rakudo

2010-12-27 Thread Carl Mäsak
# New Ticket Created by Carl Mäsak # Please include the string: [perl #81352] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81352 masak rakudo: say defined Nil; say defined () p6eval rakudo cae7f9: OUTPUT«0␤1␤» *

[perl #71462] [BUG] Smartmatching against a type yields an Int, not a Bool in Rakudo

2010-12-27 Thread Carl Mäsak via RT
On Sat Jun 26 11:43:15 2010, pmichaud wrote: Now fixed in a579f8e. Closing ticket. Pm masonkramer How do I see if a thing does Callable? masak rakudo: sub foo {}; say foo ~~ Callable p6eval rakudo cae7f9: OUTPUT«1␤» masak rakudo: sub foo {}; say foo.^does(Callable) p6eval rakudo cae7f9:

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Mason Kramer
One method-like thing that's come in handy for me as I've tinkered with the language is .WHAT. { ... }.WHAT Block() AFAIK, you can use .WHAT on *any* term, because every term in Perl6 is an object that is implemented by a class, and every class has a corresponding type object (which is what

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Daniel Carrera
On Tue, Dec 28, 2010 at 12:38 AM, Mason Kramer mason.kra...@gmail.comwrote: One method-like thing that's come in handy for me as I've tinkered with the language is .WHAT. { ... }.WHAT Block() AFAIK, you can use .WHAT on *any* term, because every term in Perl6 is an object that is

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Chas. Owens
On Mon, Dec 27, 2010 at 18:18, Daniel Carrera dcarr...@gmail.com wrote: On Mon, Dec 27, 2010 at 10:03 PM, Moritz Lenz wrote: or my $closure = $r1 $r2 ?? { %matches{$p1}++ } !! { %matches{$p2}++ }; # invoke it $closure(); That's very cool. Perl 6 is a functional language with lambdas

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Chas. Owens
On Mon, Dec 27, 2010 at 18:49, Daniel Carrera dcarr...@gmail.com wrote: snip That's cool. Thanks. I notice it works on numbers and string literals: hello.WHAT   # Str() 3.WHAT         # Int() 3.3.WHAT       # Rat() pi.WHAT        # Num() (1+3i).WHAT    # Complex() But it seems to give very

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Mason Kramer
Sorry. TTIAR = Two Terms In A Row. It's always a syntax error in Perl6, unlike Perl 5. print, say, and sin as you've used them are not terms, actually. They're expressions which happen to be function calls. You're calling .WHAT on their return values. This is predictable going forward

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Daniel Carrera
On Tue, Dec 28, 2010 at 1:21 AM, Mason Kramer mason.kra...@gmail.comwrote: Sorry. TTIAR = Two Terms In A Row. It's always a syntax error in Perl6, unlike Perl 5. print, say, and sin as you've used them are not terms, actually. They're expressions which happen to be function calls.

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Chas. Owens
On Mon, Dec 27, 2010 at 19:41, Daniel Carrera dcarr...@gmail.com wrote: snip Hmm... I think this will only make sense to me if I ask you to define what a term is, but I am sure that this term (pun intended) is difficult to define. In particular, if a number like 5 is a term, then I would think

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread Daniel Carrera
On Tue, Dec 28, 2010 at 2:06 AM, Chas. Owens On Mon, Dec 27, 2010 at All of your examples are in fact terms. A term is a thing that is considered one unit. So, numbers, strings, and variables are all obviously terms. A function or method call that includes parentheses is also a term. But

Re: Q: Is there a reason why I can't do this?

2010-12-27 Thread yary
On Mon, Dec 27, 2010 at 8:50 PM, Daniel Carrera dcarr...@gmail.com wrote: So TTIR just means that any two terms must be separated by something, like an operator (2+5). Which basically is common sense and I'm actually surprised to hear that in Perl 5 you could have two terms one after the

Announce: Niecza v1

2010-12-27 Thread Stefan O'Rear
Announce: Niecza Perl 6 v1 To mark one month since the first announcement of Niecza, to be known retroactively as v0, this is another announcement, to be known as v1. Further announcements will occur at intervals on the last Monday of each month. You have my assurance that the 'v1' tag,