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

I really don't understand the point of shortcuts where this is the result.

I'm a really big fan of clear and legible code. I'm not at In-n-Out with a secret menu. I'm trying to make changes/updates to code someone else wrote. I don't care how clever they felt they were by using esoteric shortcuts that might make things short and fit on one line. I want to be able to read the code and follow what it does in the least amount of time. Now, if the compiler makes different/better decisions when reading something like that vs much more legible code, we can maybe have a discussion.



Those aren't shortcuts though, it's composition of 3 basic statements. The `(...);` says to gather the results of the statements contained within it into one result. The `._;` is a reference to the previous result. And then the `>;` is an operator that says to go fetch the children of the previous statement. So you are taking the last result and gathering it up together with any children, which is necessary in the OpenStreetMap data model where lines and areas are built up out of other objects.

Depending on the use case, the shortcut is often to add `geom` to the print statement, so instead a line with the above and a line with `out;` you just write `out geom;`.


I could just upvote your comment (which I did), but I'd like to tell you explicitly that your comment was particularly informative. Thanks!




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

Search: