DIP 1027--String Interpolation--Final Review Discussion Thread
dweldon
danny.weldon at gmail.com
Wed Feb 19 03:40:33 UTC 2020
On Friday, 7 February 2020 at 22:48:03 UTC, Dennis wrote:
> Considering that, what is the purpose of putting the format
> specifier inside brackets {}?
Brackets are necessary to distinguish variables from other
alpha-numeric characters.
Eg. In shell (bash) programming, you can specify variables as
$VARNAME
or ${VARNAME}, the second form only necessary if the variable is
adjacent
to any alphanumeric characters.
So, having said that, I would have thought that syntax like this
would be better:
1. $variable
2. ${variable}
3. ${variable%d}, and eg. ${variable%02d}
so that form 1 can be used when the variable is bounded by
whitespace or punctuation
but form 2 is needed to distinguish it from any adjacent alnum
chars.
Eg. "/tmp/prog${random}whatever"
Form 3 would be for numeric type variables and allows optional
formatting.
More information about the Digitalmars-d
mailing list