Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"`List<int` might evaluate to True, and then `True>` would lead to a syntax error"

You are confusing parsing and reduction. In most languages - and almost certainly in Python - these are separate steps. "Parsing it wrong leads to a syntax error" is a good thing - it means you're forced to parse it right. It would be worse if there were multiple syntactically-valid interpretations (which there may well be).



Here's the problem: `a<b>c` is already valid python. `3<5>2` evaluates to true, because python allows operator overloading. Because the < and > operators can be overloaded, there is no guarantee that an object of type "class" will not have them (this would, I believe, require some metaclass hackery, but still).

So, given that `object<int>()` throws a type error in python and not a syntax error, you can't unambiguously parse that.


Yeah, that's for sure a problem. There are potential ways around it, but none of them great (that I see, at least).

"So, given that `object<int>()` throws a type error in python and not a syntax error, you can't unambiguously parse that."

Apparently in Python 2, it's not even an error.




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

Search: