J
Jonathan Gardner
If you get rid of the syntax specific to Perl, then having to explicitly
obtain a function reference, or to dereference the result, is not such a big
deal:
foo # Call 'foo' with no args.
bar = foo # Call 'foo; with no args, assign to 'bar'
bar = &foo # Don't call 'foo', but assign a pointer to it to 'bar'
bar^ # Call whatever 'bar' is pointing at with no args
(Here I use ^ instead of -> to dereference.) Compared with Python, it saves
3 lots of (), but needs & and ^ added. Still a net saving.
On one shoulder, a demon taunts the programmer: "Ohmygosh, you can
save three keystrokes if you introduce an entirely new syntax with odd
squiggles that make no pronounceable sound in the English language!
Perhaps one day, you can program APL in Python!"
The angel that sits on the other shoulder says, "Alas, poor
programmer, one day, you'll have to read that and understand it. And
heaven help us when we hire a poor college graduate to maintain the
code we wrote five years ago. Or worse, when that poor college
graduate writes code and expects us to read it!"
Thankfully, Guido has banished that demon from the realm of Python a
long time ago.
I'd say that having this "&" symbol in front of "foo" makes it more obvious
than just foo by itself. But I agree not quite as clean.
Another thing is that you have to know whether "bar" is a function, or a
function ref, and use the appropriate syntax. Sometimes this is helpful,
sometimes not.
Thankfully, in Python, everything is a ref, so everything is
consistent.