New syntax for blocks

Nobody nobody at nowhere.com
Tue Nov 17 20:09:22 CET 2009


On Tue, 17 Nov 2009 17:31:18 +0000, MRAB wrote:

>> And if I ever find the genius who had the brilliant idea of using =
>> to mean assignment then I have a particularly nasty dungeon reserved
>> just for him.  Also a foul-smelling leech-infested swamp for those
>> language designers and compiler writers who followed his example.
>> (Come to think of it, plagiarizing a bad idea is probably the worse
>> evil.)
>> 
> C was derived from BCPL, which used ":=" and "=".

ISTR that Ritchie said that he chose "=" because assignment is more common
than testing for equality, so C's approach meant less typing.

> Fortran uses "=" and ".EQ.", probably because (some) earlier autocodes
> did.
> 
> It's a pity that Guido chose to follow C.

OTOH, functional languages use "=" for binding (let x = ... in ...), which
is more like C initialisation (which also uses "=").

Python's "=" is somewhere between assignment and binding. It's arguable
that Python should also have ":=" for in-place modification (as opposed to
re-binding a name). E.g. for an array, "foo := bar" would be equivalent to
"foo[:] = bar".




More information about the Python-list mailing list