Pairs question

0 views
Skip to first unread message

ihrd

unread,
Sep 6, 2008, 1:29:46 AM9/6/08
to november-wiki
Hello there,
when I:
say :foo<>.perl;

I expected ( "foo" => "" ) but Rakudo say:
("foo" => [])

is it right or just another bug?


Ilya

Johan Viklund

unread,
Sep 6, 2008, 2:16:17 AM9/6/08
to novemb...@googlegroups.com
I think it's a bug. But I'm not really sure, ask on #perl6 on freenode
or submit a bugreport to rakudobug.

--
Johan Viklund

Johan Viklund

unread,
Sep 6, 2008, 2:23:33 AM9/6/08
to novemb...@googlegroups.com
Ihrd, I was so curious that I asked myself on #perl6, this was the response:

<viklund> perl6: say :foo<>.perl [08:17]
<p6eval> rakudo 30809: OUTPUT[("foo" => [])␤]
<p6eval> ..elf 22166: OUTPUT[Odd number of elements in anonymous hash at
./elf_f line 19.␤Pair.new(!!!)␤]
<p6eval> ..pugs: OUTPUT[*** Named argument found where no matched parameter
expected: (foo,Syn "," [])␤ at /tmp/kGq5mr0wii line 1, column 1 -
line 2, column 1␤]
<viklund> hmm, that looks like a bug in rakudo to me, shouldn't the output be
("foo" => "") [08:18]
<viklund> irhd++ found it while hacking on november
<TimToady> well, pugs actually has it right :)
<viklund> ok

--
Johan Viklund

Dmitriy Dzema

unread,
Sep 6, 2008, 3:13:53 AM9/6/08
to novemb...@googlegroups.com
Hi.

> I think it's a bug. But I'm not really sure, ask on #perl6 on freenode
> or submit a bugreport to rakudobug.


I don't think it's a bug. There is no clarity about this construction
in Synopsises. This is a quote from Synopsis 2:
http://dev.perl.org/perl6/doc/design/syn/S02.html
Likewise, if bound to a scalar parameter, <a b> will be treated as a
single list object, but if bound to a slurpy parameter, it will auto-
flatten.

But note that under the parenthesis-rewrite rule, a single value will
still act like a scalar value. These are all the same:

$a = < a >;
$a = ('a');
$a = 'a';

Perl need to split string in the <> to list and after this transform
list to scalar if list consist of 1 element. It doesn't say anything
about calling it like <> without anything inside angles. Maybe this
nothing treated like empty string, maybe as undef. So i don't thik
it's a bug :)
And pugs works, it has problems with operators priority, but it works
as Rakudo:
pugs> say (:foo<>).perl
("foo" => ())


Илья

unread,
Sep 6, 2008, 4:12:33 AM9/6/08
to novemb...@googlegroups.com
After discussion and spec reading, I thing Rakudo do it right :)
But I was send mail to perl6-language for additional clarification.

2008/9/6 Dmitriy Dzema <dima...@gmail.com>:

Илья

unread,
Sep 6, 2008, 4:12:33 AM9/6/08
to novemb...@googlegroups.com
After discussion and spec reading, I thing Rakudo do it right :)
But I was send mail to perl6-language for additional clarification.

2008/9/6 Dmitriy Dzema <dima...@gmail.com>:
>

Илья

unread,
Sep 6, 2008, 4:26:39 AM9/6/08
to novemb...@googlegroups.com
s/thing/think/;
s/I was send/I have sent/x;

2008/9/6 Илья <for...@gmail.com>:

ihrd

unread,
Sep 6, 2008, 10:27:06 PM9/6/08
to november-wiki
Larry answered:
http://www.nntp.perl.org/group/perl.perl6.language/2008/09/msg29619.html

On Sep 6, 7:26 pm, "Илья" <fori...@gmail.com> wrote:
> s/thing/think/;
> s/I was send/I have sent/x;
>
> 2008/9/6 Илья <fori...@gmail.com>:
>
> > After discussion and spec reading, I thing Rakudo do it right  :)
> > But I was send mail to perl6-language for additional clarification.
>
> > 2008/9/6 Dmitriy Dzema <dimad...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages