DIP 1027---String Interpolation---Community Review Round 1
Robert M. Münch
robert.muench at saphirion.com
Fri Dec 13 09:17:55 UTC 2019
On 2019-12-11 22:55:22 +0000, Steven Schveighoffer said:
> On 12/11/19 5:49 PM, Steven Schveighoffer wrote:
>
>> OK, this is definitely a winner, way better than my idea. Only thing
>> better would be some way to set the default specifier to avoid all the
>> verbosity.
>
> Hm... heredoc gives us a precedent that might be valuable here.
>
> e.g.:
>
> db.exec(i"{?}INSERT INTO mytable VALUES ($name, $serial, $cost)")
>
> printf(i"{%d}I ate $apples and $bananas totaling $(apples + bananas)
> fruit.\n");
>
> -Steve
Yes, much better to reduce syntax-cluttering. Why not lean towards
existing syntax from templates:
i(?)"INSERT INTO mytable VALUES ($name, $serial, $cost)"
or even make it more configurable to catch more cases:
i($,?)"INSERT INTO mytable VALUES ($name, $serial, $cost)"
i(#,?)"INSERT INTO mytable VALUES (#name, #serial, #cost)"
i(#,?,$,??)"INSERT INTO mytable VALUES (#name, $serial, #cost)"
By provding a standard case, where the printf relevant type is
automatically deduced from the used variables, when no specification is
given the syntax would be simple in a lot of cases:
i"I ate $apples and $bananas totaling $(apples + bananas) fruit.\n"
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d
mailing list