On 06/13/2015 04:06 PM, Elizabeth Mattijsen (via RT) wrote:

Hi,
May I react on this? Would it be easier to have perl6 throw an error when there is a named parameter in the call while it isn't defined in the method. Something like 'Named parameter 'x' not defined by push' in the example set below. It would start me thinking... It would in any case be better than saying nothing.

# New Ticket Created by  Elizabeth Mattijsen
# Please include the string:  [perl #125400]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=125400 >


I’m sending this in as a rakudo bug because I think it is.

We have confusion about what is a Pair and what is a named parameter.  I see 
just about everybody fall into this trap.

The only way I see around this, is to separate the meaning of Pair and named 
parameter visually as well:

a => 42     # a Pair
:a(42)      # a named parameter

I could also see going as far as making a named parameter an Enum, or a(nother) 
subclass of it.


Liz
===================
Begin forwarded message:

Date: 13 Jun 2015 04:25:43 GMT-6
From: mt1957 <mt1...@gmail.com>
To: perl6 users <perl6-us...@perl.org>
Subject: problem pushing pairs onto an array of pairs

l.s.

Can't push/unshift onto an array of pairs!

Below a repl session with pushes

my @p = a => 1, b => 2;
a => 1 b => 2
@p.push(x=>1);
a => 1 b => 2

my Pair @p = a => 1, b => 2;
a => 1 b => 2
@p.push(x=>1);
a => 1 b => 2


my Array $p = [ a => 1, b => 2];
a => 1 b => 2
$p.push(x=>1);
a => 1 b => 2

my @p = a => 1, b => 2;
a => 1 b => 2
@p.push(Pair.new(x=>1));
a => 1 b => 2 (Any) => (Mu)

In all cases the pair x=>1 is not added. The last case is weird to me.

greetings,
Marcel


Reply via email to