DEV Community

Discussion on: We don't need a ternary operator

Collapse
 
fnh profile image
Fabian Holzer

I think the ternary is mostly a symptom of the design decision to distinguish between expressions and statements, which many programming languages share. When you could just assign the value of an if or switch/case, as it is the case for example in Ruby, there would be much less need for a ternary operator and especally to nested tenarys.

When you considered the optional type for Leaf, did you have a type that abides the definition for monadic types in mind (e.g. something like the Maybe type in Haskell), to handle null values more gracefully, or was it more a construct for the sake of a simpler grammar?

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

I had an optional type, which is what these operations were based on. Optional was an essential part of the language, as nothing was allowed to not contain a value otherwise: all defaults were defined, and there weren't null pointers.