This auto-deref seems to be a good thing. C++ compilers
could do it,
but in C-language school of leaving it up to the programmer to
say what they mean, and mean what they say, they won't.
It would seem that under Perl 6, if a hash-type reference
is made to what is a hash-ref, then it dereferences automatically,
which enables the equivalence:
my $foo = {};
$foo{x} = "Bar"; # Auto-dereference
$foo->{x} = "Bar"; # Manual dereference
This sort of behaviour already occurs after the variable is resolved,
as in:
$foo->{y}->{z} = "Zoinks";
print "$foo->{y}{z}"; # Perl5 Auto-dereference
Under C/C++, there is a huge difference between an object
reference, an object pointer, and a stack object. In Perl,
though, you could hardly care less where the object is as
Perl should be able to figure it out for you.
From a point of style, though, I would have to agree with
srawls in that using '.' with hash or list variables
is a bit wacky. It makes a lot more sense when used with
object references.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.