Python and Ruby
e_d_k at yahoo.com
Sun Jan 31 13:28:41 CET 2010
--- On Sun, 1/31/10, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> From: Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au>
> Subject: Re: Python and Ruby
> To: python-list at python.org
> Date: Sunday, January 31, 2010, 6:35 AM
> On Sun, 31 Jan 2010 03:01:51 -0800,
> rantingrick wrote:
> > On Jan 30, 10:43 am, Nobody <nob... at nowhere.com>
> >> That's also true for most functional languages,
> e.g. Haskell and ML, as
> >> well as e.g. Tcl and most shells. Why require
> "f(x)" or "(f x)" if "f
> >> x" will suffice?
> > yuck! wrapping the arg list with parenthesis (python
> way) makes the most
> > sense. Its to easy to misread somthing like this
> > onetwothree four five six
> > onetwothree(four, five, six) #ahhh... plain english.
> I think the readability factor is mostly down to what
> you're familiar
> with. But consistency is also important: in Python, you
> always refer to
> an object the same way. Given an object called x, you
> ALWAYS refer to the
> object itself as x. In languages that don't use
> parentheses, x refers to
> the object, unless the object is a function, in which case
> x refers to
> the result of calling the object with no arguments.
> Other languages need special syntax to get access to the
> function object
> itself. Because it's hard to do, people don't do it often.
> But in Python,
> getting the function object is easy, and so treating
> functions as first-
> class objects is easy.
In most functional languages you just name a function to access it and you do it ALL the time.
for example, in if you have a function 'f' which takes two parameters to call the function and get the result you use:
f 2 3
If you want the function itself you use:
The reason no parentheses are used is to support Currying (http://en.wikipedia.org/wiki/Currying). To get a new function which is equivalent to f with the first parameter set to a constant 2 you use:
this give you a function which take only one parameter. Using parenthesis make currying more complicated, so most functional languages do not use them. It did take me a LONG time to get used to this, but it is only syntax, I do not let syntax bother me. Semantics on the other hand, are a big deal.
e_d_k at yahoo.com
More information about the Python-list