Not sure that chained/nested command structures are an improvement. Most of my code can be written far more concisely, compact, and condensed, using nested commands, but 100% of the time, I will err on verbosity, resulting in readability / maintainability / "debugability", over short. I'd rather repeat commands multiple times than to nest a command structure.
Those arguments might sway me in other situations but they aren't convincing me here. Especially as it's a core function and any improvements to it's performance and behaviour will flow straight into plain-vanilla usage. Nesting the function when it allows for an optional number of parameters might kindly be described as eccentric.
Substitute (
tbl::fld
; ["&" ; "&"]
; ["<" ; "<"]
; [">" ; ">"]
)
Substitute ( Substitute ( Substitute ( tbl::fld ; "&" ; "&" ) ; "<" ; "<" ) ; ">" ; ">" )
In this case, I agree with you. The "case" type structure of Substitute lends itself well to repeated arguments; IMHIO, it is more the aspect of nested commands that lends itself to verbosity and resultant maintainability over a minor tradeoff in performance
It's not very fair to show calculations that way and it is a weired concept of adding semicolons, but the last one, in front of the expression pair
Substitute ( Substitute ( Substitute (
tbl::fld ;
"&" ; "&" ) ;
"<" ; "<" ) ;
">" ; ">" )
does not look that much worse - and I doubt that there is a major performance tradeoff since in both cases the commands are done in sequence. It might be easy to run a test for comparison.
What I actually hate is the nesting [ ], which are not required e.g. for a case statement.
I guess that you have this substitution command within a custom formula already?