Re: [perl #131392] %() creates a Map

2017-05-29 Thread Elizabeth Mattijsen
> On 29 May 2017, at 18:26, brian d foy  wrote:
> I did pull my first example out of a slightly larger program I was
> playing with, but I thought that a match would surely have no effect.
> Stupid me, because I've been around long enough to know that
> assumption is almost always false. That "harmless" thing you leave out
> is the actual problem. Here's a complete program that reproduces it:
> 
>'abcdef' ~~ m/ cd /;
> 
>my $thingy = %();
>put $thingy.^name;  #Map

Well, do we consider the named matches of a match modifiable or not?  Feels to 
me having it as an (immutable) Map feels actually closer to the intent, rather 
than it being a (modifiable) Hash.  It also gives more opportunity for 
optimization.

So perhaps the Hashes should be considered the odd ones out?



Liz

Re: [perl #131392] %() creates a Map

2017-05-29 Thread Elizabeth Mattijsen via RT
> On 29 May 2017, at 18:26, brian d foy  wrote:
> I did pull my first example out of a slightly larger program I was
> playing with, but I thought that a match would surely have no effect.
> Stupid me, because I've been around long enough to know that
> assumption is almost always false. That "harmless" thing you leave out
> is the actual problem. Here's a complete program that reproduces it:
> 
>'abcdef' ~~ m/ cd /;
> 
>my $thingy = %();
>put $thingy.^name;  #Map

Well, do we consider the named matches of a match modifiable or not?  Feels to 
me having it as an (immutable) Map feels actually closer to the intent, rather 
than it being a (modifiable) Hash.  It also gives more opportunity for 
optimization.

So perhaps the Hashes should be considered the odd ones out?



Liz


Re: [perl #131392] %() creates a Map

2017-05-29 Thread brian d foy via RT
I did pull my first example out of a slightly larger program I was
playing with, but I thought that a match would surely have no effect.
Stupid me, because I've been around long enough to know that
assumption is almost always false. That "harmless" thing you leave out
is the actual problem. Here's a complete program that reproduces it:

'abcdef' ~~ m/ cd /;

my $thingy = %();
put $thingy.^name;  #Map


Re: [perl #131392] %() creates a Map

2017-05-29 Thread brian d foy
I did pull my first example out of a slightly larger program I was
playing with, but I thought that a match would surely have no effect.
Stupid me, because I've been around long enough to know that
assumption is almost always false. That "harmless" thing you leave out
is the actual problem. Here's a complete program that reproduces it:

'abcdef' ~~ m/ cd /;

my $thingy = %();
put $thingy.^name;  #Map


[perl #131392] %() creates a Map

2017-05-28 Thread Zoffix Znet via RT
On Sun, 28 May 2017 18:18:14 -0700, raiph wrote:
> If there hasn't been significant adoption of these tokens in extant code then 
> I'd personally +1 deprecation of them in v6.d in favor of `%$/` and `@$/`.

+1. Even knowing $() was special, it didn't occur to me %() and @() could be 
special too. While $() saves some typing, the %() vs %$/ are no win IMO.

I listed removal as a proposal in 6.d doc: 
https://github.com/perl6/specs/blob/master/v6d.pod

Renaming this ticket to @LARRY/6.d RFC


[perl #131392] %() creates a Map

2017-05-28 Thread Zoffix Znet via RT
On Sun, 28 May 2017 18:18:14 -0700, raiph wrote:
> If there hasn't been significant adoption of these tokens in extant code then 
> I'd personally +1 deprecation of them in v6.d in favor of `%$/` and `@$/`.

+1. Even knowing $() was special, it didn't occur to me %() and @() could be 
special too. While $() saves some typing, the %() vs %$/ are no win IMO.

I listed removal as a proposal in 6.d doc: 
https://github.com/perl6/specs/blob/master/v6d.pod

Renaming this ticket to @LARRY/6.d RFC


[perl #131392] %() creates a Map

2017-05-28 Thread raiph via RT
The token `%()` isn't an empty hash, it's a synonym for `%$/` or `$/.hash`.

'foo' ~~ /$=.*/; say %(); # Map.new((:bar(Match.new...

Similarly, `@()` is a synonym for `@$/` or `$/.list`.



These tokens are documented at 
https://docs.perl6.org/language/variables#index-entry-variable_%24%3Cnamed%3E-variable_%2525%28%29-Named_Attributes



If there hasn't been significant adoption of these tokens in extant code then 
I'd personally +1 deprecation of them in v6.d in favor of `%$/` and `@$/`.


Re: [perl #131392] %() creates a Map

2017-05-28 Thread Elizabeth Mattijsen via RT
> On 28 May 2017, at 20:56, brian d foy (via RT)  
> wrote:
> 
> # New Ticket Created by  "brian d foy" 
> # Please include the string:  [perl #131392]
> # in the subject line of all future correspondence about this issue. 
> # https://rt.perl.org/Ticket/Display.html?id=131392 >
> 
> 
> It looks like %() with no characters between the parens creates a
> Map, but if there's at least one character between the parens, it
> creates a Hash. I figure all of these should create a Hash:
> 
>my %hash = %();
>put '1: ', %hash.^name;  # 1: Hash
> 
>my $hash-empty = %();
>put '2: ', $hash-empty.^name;# 2: Map
> 
>my $hash-space = %( );
>put '3: ', $hash-space.^name;# 3: Hash

FWIW, I have not been able to reproduce it, not on 2017.04.3 or HEAD or even 
2015.12.  So I find all of this rather strange  :-)


[perl #131392] %() creates a Map

2017-05-28 Thread Zoffix Znet via RT
On Sun, 28 May 2017 11:56:51 -0700, comdog wrote:
> It looks like %() with no characters between the parens creates a
> Map, but if there's at least one character between the parens, it
> creates a Hash. I figure all of these should create a Hash:
> 
> my %hash = %();
> put '1: ', %hash.^name;  # 1: Hash
> 
> my $hash-empty = %();
> put '2: ', $hash-empty.^name;# 2: Map
> 
> my $hash-space = %( );
> put '3: ', $hash-space.^name;# 3: Hash
> 
> Where is %() documented (other than examples using it)?
> 
> $ perl6 -v
> This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-
> g66c6dda
> implementing Perl 6.c.


Failing to reproduce this on any of the versions, including the one mentioned 
in OP.

Is this being run in REPL? Do you have some modules loaded? (if in REPL, do you 
have Readline or Linenoise installed?)


Re: [perl #131392] %() creates a Map

2017-05-28 Thread Elizabeth Mattijsen
> On 28 May 2017, at 20:56, brian d foy (via RT)  
> wrote:
> 
> # New Ticket Created by  "brian d foy" 
> # Please include the string:  [perl #131392]
> # in the subject line of all future correspondence about this issue. 
> # https://rt.perl.org/Ticket/Display.html?id=131392 >
> 
> 
> It looks like %() with no characters between the parens creates a
> Map, but if there's at least one character between the parens, it
> creates a Hash. I figure all of these should create a Hash:
> 
>my %hash = %();
>put '1: ', %hash.^name;  # 1: Hash
> 
>my $hash-empty = %();
>put '2: ', $hash-empty.^name;# 2: Map
> 
>my $hash-space = %( );
>put '3: ', $hash-space.^name;# 3: Hash

FWIW, I have not been able to reproduce it, not on 2017.04.3 or HEAD or even 
2015.12.  So I find all of this rather strange  :-)

[perl #131392] %() creates a Map

2017-05-28 Thread brian d foy
# New Ticket Created by  "brian d foy" 
# Please include the string:  [perl #131392]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=131392 >


It looks like %() with no characters between the parens creates a
Map, but if there's at least one character between the parens, it
creates a Hash. I figure all of these should create a Hash:

my %hash = %();
put '1: ', %hash.^name;  # 1: Hash

my $hash-empty = %();
put '2: ', $hash-empty.^name;# 2: Map

my $hash-space = %( );
put '3: ', $hash-space.^name;# 3: Hash

Where is %() documented (other than examples using it)?

$ perl6 -v
This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda
implementing Perl 6.c.