Looking at the examples in the first post (but not other documents yet, sorry…), I almost feel the same as Steve Kargl (@kargl), i.e., both versions are not very readable In particular,
? cond ... (where the question mark appears first) seems extremely confusing. If the “?” is possibly to be used, I think the usual conditional (cond ? A : B) or the last example by @kargl above (using
|) seems better to me.
Also, I remember I have seen several discussions on the net that nested conditional expressions are rather confusing (and so discouraged by some people). I guess the same concern may also apply here, e.g., in the examples in the first post.
RE keyword (if-else) vs “?”, other languages that introduced conditional expressions recently might have related discussions about pros and cons, which may be useful as a reference.
In my case, I use only a single conditional expression in one statement, like
Nsteps = ifelse( some_flag, 10**6, 100 )
in a way similar to
some_flag ? 10**6 : 100, where
ifelse is a CPP macro
#define ifelse(q,x,y) merge(x,y,q)
This works fine for integers etc, but does not work for character strings (e.g.,
ifelse( flag, "yes", "no" ) is an error because “yes” and “no” have different string lengths.
For comparison, Julia has both
cond ? A : B and
ifelse(), and Chapel has
if (cond) then A else B. The latter seems close to the example in the first post, but without attaching