Hacker News new | past | comments | ask | show | jobs | submit login

I don’t think strong/weak typing is the culprit here.

I think partly that being explicit is nice. Assignment and equality are two very different things, so it makes sense for there to be different syntax. You can easily prevent the code in the article from working—just disallow assignment inside of expressions. This is probably a good idea, and a lot of newer languages make that choice.

Even when you read papers about programming, you often see different notation for assignment and equality. Assignment may be <- or := or something, and equality will just be =, to match the mathematical notation. I see a lot of <- in manuals for processors & architectures. I would hate to see something like this in my code base:

    a = x = y;
If that meant “set ‘a’ to true if ‘x’ is equal to ‘y’, and false otherwise.” I would, honestly, be a little pissed off.

I would only accept something like that if it meant (a==x)&&(x==y).




> I would hate to see something like this in my code base:

> a = x = y;

> If that meant “set ‘a’ to true if ‘x’ is equal to ‘y’, and false otherwise.” I would, honestly, be a little pissed off.

Would you find it more acceptable as `a = (x = y)`? To me, that is reasonably clear.


> Would you find it more acceptable as `a = (x = y)`? To me, that is reasonably clear.

No, I don’t consider that acceptable. It is not enough that it is clear to some people who know what they are looking at. The language should be more clear to more people.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: