>>>>> "KF" == Ken Fox <[EMAIL PROTECTED]> writes:

  KF> Simon Cozens wrote:
  >> [EMAIL PROTECTED] (Damian Conway) writes:
  >> 
  >>>> %hash4 = ("Something", "mixing", pairs => and, "scalars");
  >>> 
  >>> That's perfectly okay (except you forgot the quotes around the <and>
  >>> and you have an odd number of elements initializing the hash).
  >> Urgh, no. Either a pair is an atomic entity or it isn't. Which?

  KF> Odd meaning "not correct"... When initializing the hash, the pair
  KF> comes off as a single element. That leaves "scalars" as a key without
  KF> a value. So there's an even, but insufficient, number of elements
  KF> initializing the hash.

but what simon was saying (and i agree) is the the pair IS a single
item. it becomes the key and its value is 'scalars'. hashes can now take
objects as keys and won't just stringify them. i assume some string form
will be used for the internal hash key but the real object ref is saved
and returned by keys and friends.

so the question really is, what does assigning a list of mixed scalars
AND pairs to hash do? are the pairs listified and the whole thing
assigned 2 by 2? or are the pairs kept as single objects and they become
key or value according to their even/odd slot?

the earlier post said something about a list of pairs being assigned to
a hash works just fine. but if i do:

        @array = ( key => 1, key2 => 3, 4, 5 ) ;
        %hash = @array ;

what does that do? 3 pairs in the hash or 2 (the first pair is the key
for the second pair)?

it comes down to how much perl6 will look inside the list data assigned
to a hash. will it scan items and handle pairs specially or just act
like they are 1 item? it seems that a list of just pairs will be
assigned to a hash logically but what about a mixed list? both
assignment styles have their uses.

and i like pairs a lot. they make the => into something very useful and
not just sugar. but i think the handling of pairs in hash assignment is
still not on solid ground.  there needs to be some semantic way to
select the hash assignment style and a proper definition of the default
style.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to