Python-Dev: Adding braces to __future__
mail.python.org
mail.python.org
On Fri, Dec 9, 2011 at 12:26 PM, Cedric Sodhi <manday at gmx.net> wrote:
> IF YOU THINK YOU MUST REPLY SOMETHING WITTY, ITERATE THAT THIS HAD BEEN
> DISCUSSED BEFORE, REPLY THAT "IT'S SIMPLY NOT GO'NNA HAPPEN", THAT "WHO
> DOESN'T LIKE IT IS FREE TO CHOOSE ANOTHER LANGUAGE" OR SOMETHING
> SIMILAR, JUST DON'T.
Every single response in this thread so far has ignored this request. The
correct response honoring this should have been deafening silence.
For me, if I had to design a new language today, I would probably use
braces, not because they're better than whitespace, but because pretty much
every other lanugage uses them, and there are more interesting concepts to
distinguish a new language. That said, I don't regret that Python uses
indentation, and the rest I have to say about the topic would violate the
above request.
--Guido van Rossum (python.org/~guido) # Not valid.
my_button.on('click', lambda x: raise 'unimplemented')
my_button.on('click', lambda _: some_var = 'clicked')
I believe the whitespace delimiters is the main reason why we aren't allowed to have multi-lines lambdas. (CoffeeScript proves us wrong on that, but from my experience, multi-lines whitespaced functions look better in CS than in Python.)Also, I'd like to point out that "where's the patch" is really unfair. Python programmers are 'users/customers'. So, it's like if a customer asked for a feature and you'd tell her to implement it..
I believe it's not so much about multi-lines but more about how the standard library is designed. It's mostly imperative/OO and use really few callbacks. Thus, when you try mixing long lambdas, it feels wrong. Unlike in CS with node.js or jQuery (for example), where callbacks are really the way to go.
No they are not customers. They aren't paying anything to anyone nor do the python devs owe him anything. It infuriates me every time someone considers a non-paying (or otherwise contributing) open source software user a customer that's "always right". In general, if you have a feature that you wish to get in an open source project, you start off by making a crude implementation yourself and then go and submit it for peer review and further discussion.
If it were a humble feature request, it should have been sent to python-ideas, not python-devs. As it was not really a feature request and it didn't have any examples what the new syntax would look like, it was just an opinion piece that should have gone to his personal blog.
Now this jerk just wasted a whole lot of the python core dev team's time, including at least two responses from Guido van Rossum. I'd much more prefer seeing the python devs spending their time on developing python than answering e-mails like this.
Python's crippled lambdas, like you mentioned, are a much better illustration of where WSB causes irritation down the road. I was looking forward to comparisons with Ruby that highlight the expressiveness that blocks can provide, e.g.
def gratuitous_callback_name(bar):
while bar(): baz()
return meh()
foo(gratuitous_callback_name)
is clearly not preferable to foo {|bar| baz() while bar(); meh() }
and perhaps some demonstrations of how freedom with indentation can lead to more readable code, such as the XCode indentation style for Objective-C vs. the continuation line mess seen in PEP 8 [1]. Also, I would suggest that significant whitespace combined with docstring conventions lead to an unnecessarily complicated algorithm just to strip the whitespace back out [2]: that doesn't smell right either. Similar problems carry over to any Python code that involves defining lots of multiline strings within methods where the whitespace will be significant later (more often than you'd think).Alas, the OP dropped off so fast before even mentioning any of the above--I suspect a troll.
[1]: http://www.python.org/dev/peps/pep-0008/
[2]: http://www.python.org/dev/peps/pep-0257/#handling-docstring-...
And that's an argument? Why not include static typing, or single inheritance, GOTO while we're at it? I'm sure there are those who happen to like them.
Well if anything, this is one of the most vocative trolls I have ever read. :)
Why is static typing in that list? Unlike single inheritance or GOTO's, static typing is a good thing. Dynamic typing is often used in interpreted languages because once you're writing an interpreter, there's going to be a massive performance hit anyway and dynamic typing won't make it a lot worse. Dynamic typing makes compiling efficient code very difficult.
Of course, a good static typing programming language should have at least some kind of type inference mechanism to allow the programmer to leave out explicit type declarations when a compile can infer them from the program source code.
Boo is a statically typed, type-inferring language for the CLR that has a Python-like syntax. It seems pretty nice, I've written a few toy projects with it.
Examples: static typing with optional duck types: Boo. dynamic typing with optional type annotations: many Lisps, e.g. Racket.
One benefit is additional optimizations. Many good Lisp implementations take advantage of this.
People who find this problematic need to find another language or stop focusing on trivia.
Which is a silly reason. Why not add other things from other languages all to keep 'consistant'?
Curlies or Lisp-like curves play a ton nicer with tooling and visual inspection.
It's an ambiguity problem similar to the dangling else. There's no way to automatically tell the editor that I want the statements to go here or there.
edit: Yes, there's a reformat command in emacs. No, it does not work correctly for Python, because the lack of delimiters means it does not have the information it needs to do the job right.
If it were an actual grammatical ambiguity, any editor couldn't get it right but it can't be since the Python parser can understand it.
Here's a pastebin that illuminates the problem.
edit: What version of emacs are you using? Are you using python.el or python-mode.el for editing Python? python.el handles try/except, if/else, etc., etc., indentation pretty marvelously.
edit2: If you'd rather talk about this out-of-band I'm on freenode as mdeboard or my email address is in my profile.
There's a huge difference between going to a mailing list and asking for (unpopular) features and going ahead and implementing it. Provide a patch, along with test cases and practical use case examples and you're making a point. Abstract rambling with 0 lines of code examples is worthless.
What comes to the actual issue: I'm a huge fan of layout based syntax but I do hate writing white space sensitive parsers. I think Haskell's way of having curlies and semicolons in the core syntax and adding layout as a sugar coating hits a particular sweet spot.
> I think Haskell's way of having curlies and semicolons in the core syntax and adding layout as a sugar coating hits a particular sweet spot.
I agree with this.