English-like Python

Joe Strout joe at strout.net
Wed Jan 21 10:24:51 EST 2009


Aaron Brady wrote:

> Where functions are first-class objects, a bare function object isn't
> distinguishable either from its call.

That depends not on whether functions are first-class objects, but on 
the *syntax* of function invocation vs. function reference.  It just so 
happens than in Python, the syntax for the latter is the bare function 
identifier.  But it wouldn't have to be -- you could use "@foo" or 
"{foo}" or "ref foo" or (as in RB) "AddressOf foo" or any number of 
other alternatives to accomplish the same thing, and functions would 
still be first-class objects.

I'll grant that having any such syntax makes them *odd* first-class 
objects, since all other objects are referred to with a naked 
identifier, and invoked (if they are callable) with some other syntax. 
It'd be weird and inconsistent to have functions turn that around.  But, 
despite being inconsistent, it might still be sensible, based on the 
observation that we generally need to invoke methods a lot more often 
than we need to get a reference to them.

 > I'm granting that it's useful
> to return values a lot.  For example:
> 
> a= f
> 
> could mean either, 'a= f' or 'a= f()'.  Once again the return values
> save the day.

I think I agree (if I follow you correctly).  But then some other syntax 
would be needed for when you really mean "a=f" (i.e., make 'a' refer to 
the same function as 'f').

Best,
- Joe




More information about the Python-list mailing list