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

I don't think ternary expression is ugly by itself, it's only ugly if parameters themselves are chains beacuse then you're back to having a tree. Which is the fundamental problem - chaining is not good for branches, so any branches send you back to nesting. On the higher level theproblem is that you are trying to express a tree as a list - ain't going to work.

Haskel side-steps this problem in a neat way - you can take advantage of delayed evaluation and give names to both arguments of the ternary expression so each individual piece looks linear. So your "tree" is broken down line by line:

  x=...
  y=...
  z=f?x:y
  
which is as neat and easy to read as a chain, but is more powerful because it can express a tree.

Once could enforce this sort of reader-friendly style by forbidding expressions in ternary operators.




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

Search: