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

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

Thread Previous | Thread Next
From:
Juerd
Date:
May 25, 2005 02:03
Subject:
Re: (1,(2,3),4)[2]
Message ID:
20050525090338.GS31996@c4.convolution.nl
"TSa (Thomas SandlaƟ)" skribis 2005-05-25 10:47 (+0200):
> I have understand what you mean and how you---and other p6l'er---
> derive +@a == 1 from @a = [1,2,3]. But allow me to regard this
> as slightly inconsistent, asymmetric or some such.

If you STILL don't understand that it has nothing to do with
inconsistency or asymmetry, then please allow me to at this point give
up and stop trying to explain.

() do not construct lists, inside () is an expression, () does not
provide context. [] constructs arrays, inside [] is an expression that
is a list, [] does provide list context.

() and [] are as alike as [] and {} or <> and (), or ** and ++.

Your expectation, not the language, is wrong.

> Isn't hash context missing in the list above? How does
> %a = ( a => 1, b => 2, c => 3 )  # @a = (1,2,3)

HASH = THREE PAIRS

> compare with
> %b = { a => 1, b => 2, c => 3 }  # @b = [1,2,3]

HASH = ONE SCALAR

That probably does roughly the same as:

%b;
%b{ { a => 1, b => 2, c => 3 } } = undef;

Hopefully with a warning complaining about the odd number of elements in
the list.

> 3 == +%a == +%b

No.

> %a<a> == 1 == %b<a>

No, there is no %b{'a'}, only a $b{ $a_certain_hashref }.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

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