[perl6/specs] ace089: Fix typo

2015-07-03 Thread GitHub
Branch: refs/heads/master Home: https://github.com/perl6/specs Commit: ace089e004fee445759fa61cb380b92580e94a81 https://github.com/perl6/specs/commit/ace089e004fee445759fa61cb380b92580e94a81 Author: Elizabeth Mattijsen Date: 2015-07-03 (Fri, 03 Jul 2015) Changed paths:

[perl #125542] [PATCH] Warn on P5ish use of \ on single sigiled variable

2015-07-03 Thread via RT
# New Ticket Created by Brandon Allbery # Please include the string: [perl #125542] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=125542 > Inspired by a p6-users message where someone was confused after attempting to naïvely

Re: [perl #118559] [BUG] .clone affects the original object in Rakudo

2015-07-03 Thread Elizabeth Mattijsen
Fixed with 0c88527472c14cf9f834, tests unfudged. > On 21 Jun 2013, at 02:26, Carl Mäsak (via RT) > wrote: > > # New Ticket Created by "Carl Mäsak" > # Please include the string: [perl #118559] > # in the subject line of all future correspondence about this issue. > # https://rt.perl.org:443

[perl #112660] [BUG] Can push non-X objects to an attribute array typed with X in Rakudo

2015-07-03 Thread Christian Bartolomaeus via RT
AFAIU this ticket is about the type of @.slots not being respected. This seems to be fixed now: $ perl6 -e 'class A { has Method @.slots; }; A.new.slots.push: [1, 2, 3]' Type check failed in assignment to '@!slots'; expected 'Method' but got 'Array' in block at -e:1 I added a test to S32-arra

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Moritz Lenz
On 07/03/2015 10:02 PM, yary wrote: > On Fri, Jul 3, 2015 at 3:03 PM, Timo Paulssen wrote: >> but this does not >> >>> sub takes_int_array(Int @bar) { say @bar } >>> takes_int_array([1, 2, 3]) >> >> because the type match is against the defined type. We do not >> automatically infer that [1, 2,

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Timo Paulssen
On 07/03/2015 10:02 PM, yary wrote: > On Fri, Jul 3, 2015 at 3:03 PM, Timo Paulssen wrote: >> but this does not >> >>> sub takes_int_array(Int @bar) { say @bar } >>> takes_int_array([1, 2, 3]) >> because the type match is against the defined type. We do not >> automatically infer that [1, 2, 3] co

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread yary
On Fri, Jul 3, 2015 at 3:03 PM, Timo Paulssen wrote: > but this does not > >> sub takes_int_array(Int @bar) { say @bar } >> takes_int_array([1, 2, 3]) > > because the type match is against the defined type. We do not > automatically infer that [1, 2, 3] could be a Positional[Int]. How would one c

[perl #125543] [BUG] De-indentation should de-indent physical lines, not whitespace following a \n escape in heredocs in Rakudo

2015-07-03 Thread Carl Mäsak
# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #125543] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=125543 > I found some behavior using heredocs, and I'm not really sure what the right thing to do

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Tom Browder
On Fri, Jul 3, 2015 at 2:03 PM, Timo Paulssen wrote: > On 07/03/2015 07:20 PM, Tom Browder wrote: >> On Fri, Jul 3, 2015 at 10:26 AM, Tom Browder wrote: ... >> What is the proper type to use for the %hash for a more complete >> signature in function foo1? I've tried various types such ... > When

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Timo Paulssen
On 07/03/2015 07:20 PM, Tom Browder wrote: > On Fri, Jul 3, 2015 at 10:26 AM, Tom Browder wrote: >> While experimenting I've found the first two methods of passing a hash >> to a subroutine work: >> >> # method 1 >> my %hash1; >> foo1(%hash1); >> say %hash1.perl; >> sub foo1(%hash) { >> %hash{1}

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Tom Browder
On Fri, Jul 3, 2015 at 10:26 AM, Tom Browder wrote: > While experimenting I've found the first two methods of passing a hash > to a subroutine work: > > # method 1 > my %hash1; > foo1(%hash1); > say %hash1.perl; > sub foo1(%hash) { > %hash{1} = 0; > } Another question on method 1 above, please:

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Tom Browder
On Jul 3, 2015 11:14 AM, "Brandon Allbery" wrote: > > On Fri, Jul 3, 2015 at 11:26 AM, Tom Browder wrote: >> >> # method 1 ... >> foo1(%hash1); > This is what I would naïvely expect to work in any language except Perl 5. That comment, along with Liz's, has convinced me to use method 1 (less typi

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Brandon Allbery
On Fri, Jul 3, 2015 at 11:26 AM, Tom Browder wrote: > # method 1 > my %hash1; > foo1(%hash1); > say %hash1.perl; > sub foo1(%hash) { > %hash{1} = 0; > } > This is what I would naïvely expect to work in any language except Perl 5. > # method 2 > my %hash2; > my $href2 = %hash2; > foo2($href2)

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread Elizabeth Mattijsen
> On 03 Jul 2015, at 17:26, Tom Browder wrote: > > While experimenting I've found the first two methods of passing a hash > to a subroutine work: > > # method 1 > my %hash1; > foo1(%hash1); > say %hash1.perl; > sub foo1(%hash) { > %hash{1} = 0; > } > > # method 2 > my %hash2; > my $href2 = %ha

Passing a hash to a subroutine: best method?

2015-07-03 Thread Tom Browder
While experimenting I've found the first two methods of passing a hash to a subroutine work: # method 1 my %hash1; foo1(%hash1); say %hash1.perl; sub foo1(%hash) { %hash{1} = 0; } # method 2 my %hash2; my $href2 = %hash2; foo2($href2); say %hash2.perl; sub foo2($href) { $href{1} = 0; } # thi

[perl #125539] [BUG] samewith doesn't work on subs in Rakudo

2015-07-03 Thread Carl Mäsak
# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #125539] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=125539 > what's the idiomatic way to call a MAIN multi from another? masak: nextsame? masak: sa

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread Tom Browder
On Fri, Jul 3, 2015 at 7:40 AM, yary wrote: > > On Fri, Jul 3, 2015 at 8:35 AM, Tom Browder wrote: >> >> if $idx >= 0 { >> ... >> >> Which worked also (surprisingly given S32 and your comments)! > > > > That doesn't work when the line has no comment in it, it gives an error Oops--forgot about th

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread yary
On Fri, Jul 3, 2015 at 8:35 AM, Tom Browder wrote: > if $idx >= 0 { > ... > > Which worked also (surprisingly given S32 and your comments)! > That doesn't work when the line has no comment in it, it gives an error -y

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread Tom Browder
On Fri, Jul 3, 2015 at 7:35 AM, Tom Browder wrote: > On Fri, Jul 3, 2015 at 7:21 AM, yary wrote: >> On Fri, Jul 3, 2015 at 8:07 AM, Tom Browder wrote: > ... So, considering all the comments and S32 wording, I suspect that this would be sort of a "best practice" idiom: if defined $idx { ... Th

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread Tom Browder
On Fri, Jul 3, 2015 at 7:21 AM, yary wrote: > On Fri, Jul 3, 2015 at 8:07 AM, Tom Browder wrote: ... I completely missed the other obvious attempt to use Perl 5ish semantics: if $idx >= 0 { ... Which worked also (surprisingly given S32 and your comments)! Thanks for all the help Carl and yary

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread Tom Browder
On Fri, Jul 3, 2015 at 7:27 AM, Elizabeth Mattijsen wrote: > Hi Tom, ... > Apart from what Carl and yary said, I would like to add that *if* > you’re just interested in knowing whether a string starts with a > certain substring, you can use .starts-with: ... Thanks, Liz, Perl 6 certainly has a lo

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread Elizabeth Mattijsen
Hi Tom, > On 03 Jul 2015, at 14:07, Tom Browder wrote: > > I originally had problems with the S32 description of string function > index. S32 says that if the substring is not found then a bare Int is > returned which evaluates to false, otherwise an Int with the position > of the first substrin

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread yary
On Fri, Jul 3, 2015 at 8:07 AM, Tom Browder wrote: > if $idx { > $str = $str.substr(0, $idx); > } if defined $idx { $str = $str.substr(0, $idx); } -y

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread Carl Mäsak
Hi Tom, What you're experiencing is not a bug. It's the fact that if 0 ends up in your $idx variable, then that 0 will evaluate as False in an if statement (or in a && operand). But jumping ahead to what you probably *meant* to write: if defined($idx) && $idx >= 0 { $str = $str.substr(0, $idx)

Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread Tom Browder
I originally had problems with the S32 description of string function index. S32 says that if the substring is not found then a bare Int is returned which evaluates to false, otherwise an Int with the position of the first substring match is returned. It goes on to say that one should not evaluate