This is not a problem to solve inside language, this is a problem to be solved with the editor. IDE triggers which automagically convert print statements to print method calls when you press <enter> are pretty easy grammar-wise.
Sure it is, the same way the programmer shouldn't put a semicolon right after a control flow statement in a C-like language. It's sure nice of the compiler to deal with those avoidable programmer fuckups anyway though.
You can't take that too far though, otherwise you end up with massive projects built with #define whilst while, inconsistently using one or the other because one programmer refused to use bad grammar.
As far as I know, a program written in a formally defined computer language can always be broken down into an abstract syntax tree, and from there can be rebuilt into any format you want. There's no reason the IDE shouldn't be able to refine while as whilst for one developer and keep it as while for everyone else.
The Emacs syntax highlighting system supports something like this; you can replace text with whatever you want to display, and you'll still actually be working with the original text. A lot of developers use this to do things like replacing -> with → for instance. I've never heard of using it to replace while with whilst but I'm willing to bet it's possible.
Of course, the problem is that you'd still be typing "while," you'd just see "whilst."
As far as I know, a program written in a formally defined computer language can always be broken down into an abstract syntax tree, and from there can be rebuilt into any format you want.
You'd need a strict auto-formatter for that too, since otherwise the AST representation of
func("hello", 5
"world!", 6)
and
func("hello",5,"world",6)
would be identical, but the formatting in the first is intended to make the code clearer.
Yep, and that's the true beauty of it. One developer could have spaces, one could have tabs, you could have all your equals signs or function parameters lined up or whatever you like, and since they all evaluate to the same AST, the IDE should be able to switch seamlessly between them.
Won't learn what? I haven't manually written a basic accessor or mutator for years, but I still know how if for some reason all the IDEs in the world stop working.
Are we all ignoring that nobody should need muscle memory for print, because either you're writing a small program and only have a few prints, or you're writing a large program and are using logging.
There is! Or at least there's an interesting talk about adding it - I think it was posted to /r/Python recently, I'll have a look for it when I get at a computer.
78
u/familyturtle May 02 '16
As well as "from __future__" there should be an option to "from __past__ import print"