[Python-ideas] Making colons optional? Syntactic alternative.
pyideas at rebertia.com
Thu Feb 5 20:33:21 CET 2009
On Thu, Feb 5, 2009 at 4:26 AM, spir <denis.spir at free.fr> wrote:
> Le Wed, 4 Feb 2009 23:35:30 -0330,
> Riobard Zhan <yaogzhan at gmail.com> a écrit :
> * Extend name binding format "name:value" to assignments. That is, write "a:1" instead of "a=1. This may avoid tons of misunderstandings (imo, '=' for assignment is a semantic plague, a major error/fault, a pedagogic calamity).
> * Which lets the "=" sign free for better use: use "=" for the semantics of equality, like in math and common interpretation learnt from school.
> * Perhaps: use "==" for identity, instead of "is".
I'm sorry but regarding these bullet points, C makes for a persuasive
argument for not changing the meaning of those operators. Pretty much
everyone in computing either knows well or is at least familiar with C
and probably knows one of its syntactic descendants quite well, so
gratuitous deviation from C violates the Principle of Least Surprise
for anyone who already is a programmer. Newbies may trip over it, but
they catch on eventually. If you did want to change the assignment
operator, the colon seems visually a poor choice IMHO; it's too easily
overlooked and `x : y` looks rather sparse on a line by itself.
The other somewhat popular choices of assignment syntax that I've seen
are x := y, x <- y, and let x = y. The first and last of those still
use a =, albeit with something extra, and so aren't too much of a
stretch. x <- y is particularly deviant and isn't readable (as in read
it out loud) IMHO; you either have to read it right-to-left (which is
unnatural) as "Take y and put it into x", or as "x has y placed into
it" (which uses the passive voice and so does not fit well with an
Follow the path of the Iguana...
More information about the Python-ideas