The problem with "as" [was "Re: PEP 318"]

Christian christian at
Fri Mar 26 19:52:05 CET 2004

Stephen Horne wrote:
> I would use the logic of 'preferring the return type at the end', and
> perhaps cite Ada, Pascal, Modula 2, etc (Algol as well?) as examples
> to follow. But then why do I have no problem with C, C++, Java, C# etc
> where the type of the return value usually comes first?

I think, what makes
	def foo[return(string)](x=42:int, y=3.14:float):
look so strange, is the fact that you have the function name, the
return type and after that the arguments

	def [return (string)] foo(x=42:int, y=3.14:float):
looks more familar, if you concentrate on the 'foo'. But this style
seems to push the function's name into the middle of the declaration.

The fact that there's no problem with reading C, C++ etc comes from the
continuity of their declaration. you can read
	void foo(int bar=42)
very fluently, and
	def foo [return void] (bar=34:int)

The problem is, that we are accustomated at having the function's name
right before the argumentlist, as it gets called
you don't write foo [x] = (32, 42) but x = foo(32, 42)

IMHO, if the function's name has to be right after the 'def', and 'def'
has to be the first command in a declaration, the return type has to
come last

More information about the Python-list mailing list