Closed rizo closed 1 year ago
I don't remember why but nowadays I rather moved to use if'
, see for example:
https://erratique.ch/software/b0/doc/B0_std/Cmd/index.html#val-if' https://erratique.ch/software/brr/doc/Brr/At/index.html#val-if' https://erratique.ch/software/webs/doc/Webs_html/At/index.html#val-if'
what do you think ?
No strong opinions, but my thoughts are:
on
is already used by at least bos
which is why I proposed Fmt.on
;if'
closer indicates that there's a boolean involved, while on
is often times used for states or even event triggers;if'
bares a more imperative meaning (especially without else
) while on
is more declarative:
Cmd.on verbose (Cmd.v "--verbosity=debug")
– suggests that there's a state mapping;Cmd.if' verbose (Cmd.v "--verbosity=debug")
– might be perceived to suggest an action;on
avoids the '
by not being a keyword;Fm.on_bytes
and Fmt.on_string
, just Fmt.on
has nothing to do with them which feels inconsistent.Happy to rename this to Fmt.if'
.
I grepped a bit my code bases and even in the Cmd
case (which often happens inside a Cmd.()
) I definitively find if'
clearer to read and, considering the following progression, more natural:
Fmt.(if cond then that_way else this_way)
Fmt.(if cond then that_way else nop)
Fmt.(if' cond that_way)
I rather keep on
for labelling FRP event values.
That makes sense. Pushed Fmt.if'
.
Would you consider adding Cmd.if'
to Bos in that case and deprecating Cmd.on
?
Thanks your patch is in as 9db1a3c058973
Would you consider adding
Cmd.if'
to Bos in that case and deprecatingCmd.on
?
https://github.com/dbuenzli/bos/commit/6320f302eb9487518491511292a11ee6f04bd6e9
I was surprised this isn't present. This is similar to https://erratique.ch/software/bos/doc/Bos/Cmd/index.html#val-on