Python and Ruby

bartc bartc at freeuk.com
Wed Feb 3 02:01:29 CET 2010


Jonathan Gardner wrote:
> On Feb 2, 7:23 am, "bartc" <ba... at freeuk.com> wrote:
>> Jonathan Gardner wrote:
>>> One of the bad things with languages like perl and Ruby that call
>>> without parentheses is that getting a function ref is not obvious.
>>> You need even more syntax to do so. In perl:
>> 
>>> foo(); # Call 'foo' with no args.
...
>> 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!"
... 
> Thankfully, Guido has banished that demon from the realm of Python a
> long time ago.

You mean & (bitwise AND in Python) and ^ (bitwise XOR in Python)?

:-)

-- 
Bartc





More information about the Python-list mailing list