New syntax for blocks
apt.shansen at gmail.com
Tue Nov 17 20:55:47 CET 2009
On Tue, Nov 17, 2009 at 10:15 AM, r <rt8396 at gmail.com> wrote:
> On Nov 17, 9:28 am, Jonathan Saxton <jsax... at appsecinc.com> 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.)
> I think every new programmer wrestles with this dilemma in their first
> days but very soon after accepts it as reality. As for me it made
> perfect sense from day one to have '=' mean "assignment" and '==' to
> mean "equality". Programming is not mathematics (on the contrary) they
> are two sides of a mountain forever unknowing of each other but
> sharing the same space. I think the syntax was chosen because the
> alternatives are even worse AND since assignment is SO common in
> programming, would you *really* rather type two chars instead of one?
Well, equality testing is very very common too... I concede, a bit less
common (probably) then assignment, but still.
I too never had any issue with getting assignment verses equality-testing
with the operations as concepts (except that it is a not terribly uncommon
typo for me to type = and mean ==, and I'm quite happy its a syntax error as
a result), but in an ideal world? If I were today making my own private
little programming language to share with the world... I wish no one would
use a single "=" by itself for anything.
Neither assignment nor equality testing.
For me, the problem comes down to readability; when one sees "x = y", what
do they say in their head? "x equals y" -- the meaning of which for an
individual can depend on the context and intonation, how they are reading
the word "equal" in their head. They might be saying it as a verb, declaring
"let x become y", or they my be saying it as an noun, testing "x is equal to
I don't ever have that problem, but I know a lot of new programmers do and
its something which can stick for quite awhile. The word "equal" is just
sort of dodgy and fuzzy to the initiate and they start to confuse the two
entirely separate concepts (equality testing, assignment) by having the same
symbol in programming represent both.
Personally! I wish that equality and assignment both got their hands off the
bare "=" and let mathematics keep it, and programming take say, ":=" for
assignment and "==" for equality testing (or whatever, not advocating a
specific syntax) and have "=" by itself be an error all around. So yes, I'd
actually much rather type two characters instead of one-- purely in the
hypothetical sense that this conversation has gone down. :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list