Piers Cawley writes: : Andy Wardley <[EMAIL PROTECTED]> writes: : > Hang on, now I'm a little confused - I thought that hashes were supposed : > to keep their % sigil. So shouldn't that be %foo.keys or %foo.{keys}? : > But then that would then violate the uniform access principle because : > hash/key access has a different syntax from object/method?
%foo is just a typed reference varaible. $foo works just about as well. : $foo = %hash; # Take a reference to %hash; I'd say "Copy a reference", since I think of %hash as a reference already. : $foo.{keys} # get the value keyed by 'keys' in the hash refered : # to by $foo. : $bar = Object.new # Make an object : $bar.{keys} # Get the value of $bar's '$.keys' instance : # variable. Mmm. I think it always calls the virtual method, which might or might not map directly to $.keys, depending on how fancy the accessors get. If you want a particular type's method regardless of the actual type of the object, you have to do as in Perl 5 and say $bar.This::Type::keys() : I think that the '.' is optional in this case too... Yes, as long as there's no whitespace before it. I imagine some style guides will require the dot for that reason. I can just see some poor schmuck walking out of a job interview because the company requires dots on all hash subscripts. :-) Larry