Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
ddcovery
antoniocabreraperez at gmail.com
Thu Feb 4 10:38:00 UTC 2021
On Thursday, 4 February 2021 at 08:10:57 UTC, Ola Fosheim Grøstad
wrote:
> The whole "${}" thing is too verbose, it reminds me of the
> JavaScript variant which is basically no easier to read than
> concatenation. Python got it mostly right...
>
In my opinion,
`${a} plus ${b} is ${a+b}`
is definitely easier to read than
"" + a + " plus " + b + " is " + (a+b)
Dart
"${a} plus ${b} is ${a+b}"
or
"$a plus $b is ${a+b}"
Kotlin
"${a} plus ${b} is ${a+b}"
or
"$a plus $b is ${a+b}"
Javascript/Typescript
`${a} plus ${b} is ${a+b}`
Python
template = Template('$a plus $b is $c)
print( template.substitute(a=a, b=b, c=a+b) );
or
print( Template('$a plus $b is $c).substitute(a=a, b=b, c=a+b)
);
That without taking into account that python solution is a "run
time" template compiler while Dart/typescript/... is a compile
time type safe in place string expression.
More information about the Digitalmars-d
mailing list