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

I find it interesting to see so much emphasis on small syntax nit-picking while totally forgetting the large scale question.

Although I've used a ternary operator or 'if' statement from time to time, in general I would like to model the boundrary conditions themselves and separate condition and action (reduces coupling and enhances the possibility of reporting what is going on).

In your case, the a < b statement is most likely part of the natural ordering of the type of whatever variable a and b are. So we should be much more interested in describing the natural ordering of this type, so we can say things like:

to sort a list of ints in reverse order, or

to sort a list of tuples of ints and strings in natural ordering.

So, creating this natural ordering needs to be done only once, over all the possible programs that can be expressed with ints. Maybe that one, single, time you'd be writing the actual expression you wrote above. But this lower-level logic will be well hidden by the abstractions used to reason at a higher level about correctness when placed orthogonally with other low-level code.

In other words, every time I write ternary expressions or long if-then-else expressions, I am either writing something low-level, or I need to abstract away.

this is one of the most informative and clear response for this topic. thank you very much!

Thanks for replying. So many words but not sure whether the message came across.

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