develooper Front page | perl.perl6.language | Postings from May 2005

Re: (1,(2,3),4)[2]

Thread Previous | Thread Next
From:
=?ISO-8859-1?Q?=22TSa_=28Thomas_Sandla=DF=29=22?=
Date:
May 19, 2005 12:06
Subject:
Re: (1,(2,3),4)[2]
Message ID:
428CE39D.1070702@orthogon.com
Juerd wrote:
> Parens and square brackets are very different things.

I know. The parens relevant here are the ones for precedence overrides.
And Comma is pretty low, so it almost always needs parens around it to
form lists. In particular it is below = and friends.


> The above is more commonly written as
> 
>     my @b = ([1,2,[3,4]);

Assuming you meant @b = ([1,2,[3,4]]) what do the parens accomplish
here? Would it even need to be @b = (,[1,2,[3,4]]) to have the list
contructing comma?
Does the following hold: @a = (1,2,3); @b = @a; +@b == 1?

My pivot question here is if +[1,2,[3,4]] == +(1,2,[3,4]) == 3 and
why then is @a = [1,2,[3,4]]; +@a == 1 but $a = [1,2,[3,4]]; +$a == 3.
And yes, I know that it is the case in Perl5. Perl6 has automatic deref
and ref---or pretends to do so for people like you and Perl5 legacy.
Otherwise $a = @b in Perl6 weren't the equivalent of Perl5's $a = \@a.
There are no Hash or Array registers in Parrot after all. On the engine
level strings and PMCs are referential in nature but this shouldn't
bother the Perl6 programmer.

Or putting the question different: does &prefix:<+>:(Any $x) get a
different thing for its $x when called with @array = (1,2,3) or
a literal [1,2,3]?

BTW, how does @a = <one two three> compare to $a = <one two three>?
Is +@a == 3?
Is $a[1] == 'two'?


> Having arrayrefs flatten in list context, or having [] to be able mean

I don't think they shall flatten. I'm just saying that it might be nice
to let variables with the @ sigil just absorb them as they are.

> something other than constructing an arrayref, is a change that requires
> the very fundaments of Perl to change very heavily, beginning by
> eliminating lists entirely, and using only arrays.

Larry only recently said something to that effect in
http://groups-beta.google.com/group/perl.perl6.language/msg/6c306a1b0b885b5a

To summarize in my words:
1) no List type or class
2) Eager and Lazy sounds more like closures, iterators, generators
    or whatever
3) And Array having a slot for each sounds to me like two private,
    scalar attributes that behave like $:eager = [1,2,3] which undeniably
    gives +$:eager == 3


> These are mistakes many Perl 5 beginners make, especially those coming
> from Python.

But this is the Perl6 language list, not a Perl5 beginners list.
And I see a lot of things changed from Perl5 to Perl6, including
referential semantics. Until now you haven't convinced me of
the advantages of the old-style Perl5 references. What do they buy us?
-- 
TSa (Thomas SandlaƟ)


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About