Too much code - slicing
Seebs
usenet-nospam at seebs.net
Sun Sep 19 03:36:11 EDT 2010
On 2010-09-19, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> I'm not entirely sure I agree with you here... you can't ignore syntax in
> order to understand the meaning of code.
No, but the syntax should be invisible. When I read English, I don't have
to think about nouns and verbs and such unless something is very badly
written. The syntax is handled automatically at a lower level without
conscious intervention, as it should be. Calling my conscious attention
to it is disruptive.
> The term "syntax highlighting" for what editors I've seen do is actually
> misleading -- they don't highlight *syntax*, they try to highlight
> *semantics*.
I've never seen this. I've seen things highlight comments and keywords
and operators and constants and identifiers differently.
> When your editor highlights the function len() in the
> expression "x = len(y) + spam(z)" but not the function spam(), you know
> it has nothing to do with syntax. len() is singled out because of its
> semantics, namely the fact that it's a built-in.
Eww. (I had not yet gotten to the point of finding out that whether
something was "built-in" or not substantially affected its semantics.)
> In English, the meaning of the some sentences do benefit by syntax
> highlighting, and in fact that's partly what punctuation is for: English
> partly uses punctuation marks as tags to break the sentence structure
> into sub-sentences, clauses and terms (particularly when the sentence
> would otherwise be ambiguous).
Punctuation is very different from highlighting, IMHO. That said, I
find punctuation very effective at being small and discrete, clearly not
words, and easy to pick out. Color cues are not nearly as good at
being inobtrusive but automatically parsed.
> "Woman shoots man with crossbow"
> Was it the man armed with a crossbow, or the woman? If we could somehow group the
> clause "with crossbow" with "woman" or "man" by something *other* than
> proximity, we could remove the ambiguity.
Yes. But syntax highlighting won't help you here -- at least, I've never
yet seen any editor that showed precedence relations or anything similar
in its coloring.
> Bringing it back to Python, that's why punctuation like : are useful.
> They're syntax highlighting.
I don't think they are, though. I think punctuation is fundamentally
different in intent and purpose from colorizing things based on whether
they're, say, constants or identifiers or comments or keywords. The
punctuation is *itself* part of the syntax -- it's not being highlighted.
Syntax highlighting is putting all the punctuation in green so you know
it's punctuation.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
More information about the Python-list
mailing list