[Python-ideas] Where-statement (=?utf-8?q?Proposal=09for=09function=09expressions?=)
Steven D'Aprano
steve at pearwood.info
Sat Jul 18 08:41:49 CEST 2009
On Sat, 18 Jul 2009 03:50:11 pm Ben Finney wrote:
> If the source code is hard enough to read that we need special tools
> to make it readable, there's not much point any more in pretending
> that it's plain text. I hope we never approach that.
But source code isn't plain text. It has syntax, and grammar. Source
code is a structured collection of tokens -- you can't put arbitrary
plain text in source code and expect it to execute, or compile.
There's value in treating source code like (say) HTML or XML -- it's
structured text, human readable, and in a pinch if all else fails human
writable as well, but normally you're expected to use a smart editor
that understands the tokens and structure of the file. (Except for
those who think there's something virtuous about keeping track of
nested tags yourself.)
To a certain extent we already do that: people say "you'll be far more
productive if you use vi or emacs than if you use Microsoft Notepad".
We accept that you simply can't be a productive, professional
programmer using Notepad. (It is a bonus that, if you're stuck without
your proper tools, you can edit code with Notepad, or ed. Great. It
would be nice to be able to repair a car with nothing but a
screwdriver, but nobody honestly thinks that's practical.)
And we do expect people to edit source code using a *text* editor, a
program that understands about text elements like lines and characters:
nobody edits source with a hex editor, or by direct manipulation of the
bytes, so there's already precedence for increasing specialisation.
Perhaps it's time for programmers to start using token editors instead
of text editors. Of course it will be a big paradigm shift, and we'll
need to think about how token files will interact with utilities like
grep that expect text files, but none of these things are problems,
they're opportunities.
--
Steven D'Aprano
More information about the Python-ideas
mailing list