First off, coming from java OO programming, I definetely prefer the dot notation for this, but I don't really have a problem with the arrow either (anymore, should say). I am pretty sure that the arrow notation comes from C++, which have both. Note that I am not especially good at C++ (it was a long time ago) but I think this is how it works (in C++):

Method invokation on an object is done with object.method(), while method invokation on an object reference is done with object->method(). So the arrow operator also dereferences the object, and then invokes the method on that object.

Since all(?) objects in perl are references to something (often a hash), this syntax suddenly makes a lot more sense.

It is the same syntax you use when you dereference several things in perl, one of the most notable is when you invoke a reference to a sub with $code_ref->(), but also constructs like $hash_ref->{'key'}.

Since I started thinking like that, it made a lot more sense, since java has no pointers or references at all. As long as this notation type is somewhat consequent, I'm happy to use both. (Pedantic note: technically, everything in java is pointers/references, but the language hides this fact - for you nitpicks out there ;-) ).

People that are a lot better than me at this are very welcome to correct and fill in blanks. :)

Update: ariels says I am confusing references and pointers in C++ - and I am sure it is so. (Thanks for the heads up). I am not very good at it anyways... I thought it might be a reasonable explanation to why perl has the arrow notation, and not the dot as so many others. Then again, maybe not. :) Just don't try to apply any of the above to real life coding or anything. :)

Update 2: talexb sets things straight as well. Now, I remember some more... :)


You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

In reply to Re: Noble DOT vs the Allmighty ARROW by Dog and Pony
in thread Noble DOT vs the Allmighty ARROW by BUU

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.