assignment expression peeve
Dave Benjamin
ramen at lackingtalent.com
Fri Oct 17 18:56:30 EDT 2003
More information about the Python-list mailing list
Fri Oct 17 18:56:30 EDT 2003
- Previous message (by thread): assignment expression peeve
- Next message (by thread): assignment expression peeve
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <7x3cdrk0pg.fsf at ruckus.brouhaha.com>, Paul Rubin wrote: > "Donn Cave" <donn at drizzle.com> writes: >> But when you can say >> >> if g := match(a, b): >> >> then I suspect you will also be able to say things like - >> >> if not (dv := start() and f := nfile(dv) >> and ((t := f.find("--") > 0 and fx = f[:t]) or (fx = f))): >> print "Well, bless me!" > > Well, yes, you can write messy code in any language. There will > always be some need for tastefulness in programming. Language > designers can't make that need go away. Of course. But what I think a lot of people miss is that language design is, in some ways, an experiment on human behavior, with programmers as the subjects. If you wrote a language, and found that adding one particular set of features as opposed to another set of features resulted in code that, overall, you preferred to look at, you might prefer to design the language that way. Regardless of whether or not you trust yourself (or others) to use/abuse the features available. Some languages prefer to let the programmer do anything. This makes programmers very happy, because they have the freedom to do whatever they want. However, it also means that it's more difficult to read other people's code, because they have that same freedom. There's more variance. As a programmer, you already have the freedom to pick the language you want. If your job doesn't allow it, you can pick another job. Or you can start your own company, or program as a hobby. No language designer is telling you what to do; you are making the choice to pick a given language, ultimately. But from the perspective of a language designer, your decisions affect the code that other people will produce. By adding a single feature, you may be indirectly creating 10,000 actual usages of that feature in other people's code. In a sense, you are programming the programmers, and if you make things possible in your language, your programmers will do those things. If it turns out to be a fault, this reflects directly on you. This is, I think, the fundamental reason for the statement vs. expression dichotomy in Python. It's not that clear statements can't be written with embedded statements. It's that Guido doesn't want to have to read other people's code written that way (I'm guessing - feel free to unstuff these words from Guido's mouth if I'm in error ;), and he certainly doesn't want the "everyone" to which his "computer programming for everyone" refers to have to read code written that way. It's a problem for some people. He wanted a language that didn't pose that problem for those people. In the end, I fullheartedly recommend against taking an antagonistic viewpoint against language designers because they don't support Feature X. They didn't write the language for you; if they did, they would have included Feature X, because obviously it's important to you. But instead, they saw (hopefully) the greater picture; the gigantic body of code that others would go on to produce. By designing a language in a particular way, language authors in effect design this body of code as well. For instance, I personally think Python would be even better than it is if it had code blocks. I'm aware that this probably won't happen. But I understand why, and it has nothing to do with *me*. So, I don't take it personally. Besides, Python is free, and it rocks, and it makes me happy because it puts my code so much closer to my thoughts than any other language. Python targets a particular demographic, and it managed to find one which I belong to, to a fairly large degree. But when I want statements in my lambdas, I'll have to look elsewhere. This means I might play around with Ruby, or ActionScript, or SmallTalk, to get a taste of that. And if I want assignment expressions, maybe I'll try Java or C++. But I don't find myself wanting for those often... or ever... -- .:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:. : d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
- Previous message (by thread): assignment expression peeve
- Next message (by thread): assignment expression peeve
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list