in reply to Noble DOT vs the Allmighty ARROW

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.