Re: .perl, nested arrays, parens and a bug with .perl after hyperop
在 May 21, 2007 8:45 AM 時,Juerd Waalboer 寫到: Steffen Schwigon skribis 2007-05-21 1:28 (+0200): That's ARRAY := ARRAY there, so the following should dwym: my @foo := [ 1, 2, 3 ]; However, this does not work with pugs, so I don't know if I am wrong, or pugs is wrong. Pugs is wrong and will be corrected before 6.28.0. :-) Audrey
.perl, nested arrays, parens and a bug with .perl after hyperop
Hi! Yesterday we discussed a strange behaviour of .perl on the result of a hyperoperator. The basic bug is that my @hyp = -« ([1, 2], 3); say @hyp.perl; outputs [(-1, -2), -3] which are strange inner parens inside the brackets that would get flattened after eval. I committed a :todo test for this in t/builtins/{perl,perl2}.t. Some questions arose during the discussion: 1. Should assigning an arrayref to an array dereference? Eg., so that @foo = [[1, 2], 3] is basically the same as @foo = ([1, 2], 3) Currently the first assignment generates a list whose first element is the complete array reference: [[[1, 2], 3],] which isn't maybe the expected behaviour. Or is it? Which Synopses describes this? 2. Shouldn't .perl generally use parens for outputting arrays (at least on the most outer level)? Because currently eval'ing the output contains the problem from question 1. 3. Which test file is the real one: pugs/t/builtins/perl.t or pugs/t/builtins/perl2.t ? They are similar but not identical. (Greeti+Tha)nX Steffen -- Steffen Schwigon http://renormalist.net Dresden Perl Mongers http://dresden-pm.org/ Deutscher Perl-Workshop http://www.perl-workshop.de/
Re: .perl, nested arrays, parens and a bug with .perl after hyperop
Steffen Schwigon skribis 2007-05-21 1:28 (+0200): 1. Should assigning an arrayref to an array dereference? No, an array in list context only flattens when it has the @ sigil, or when it is explicitly flattened with the [] postcircumfix operator, or the | prefix operator. Which Synopses describes this? S03 2. Shouldn't .perl generally use parens for outputting arrays (at least on the most outer level)? No, because parens are just for grouping and controlling precedence. They are not constructors. Note that in this assignment, my @foo = @bar; @bar is in list context. The syntax is ARRAY = LIST; and not ARRAY = ARRAY. Assigning an array to an array seems kind of useless to me. Binding probably makes a bit more sense: my @foo := @bar; That's ARRAY := ARRAY there, so the following should dwym: my @foo := [ 1, 2, 3 ]; However, this does not work with pugs, so I don't know if I am wrong, or pugs is wrong. -- korajn salutojn, juerd waalboer: perl hacker [EMAIL PROTECTED] http://juerd.nl/sig convolution: ict solutions and consultancy [EMAIL PROTECTED]