Improvement of format string. Re: Suggestion for a D project/std module: templated format
Don Clugston
dac at nospam.com.au
Fri Feb 23 08:21:56 PST 2007
renoX wrote:
> Miles Wrote:
>
>> Derek Parnell wrote:
>>> For what its worth, I tend to just use '%s' in writefln() calls, and almost
>>> never use any of the other format codes, regardless of the data type being
>>> supplied in the arguments.
>
> Yes, %s and the like are useless except when you need a special format like %08d.
>
> In Ruby, they provide an escape syntax 'puts "test #{variable}"' without format for the default embedding.
>
> IMHO in D we could use a similar syntax: writef("text %{variable}"); and writef("test %08d{variable2}"); the %{} embedded in the strings helps a lot readability I think.
IMHO, to be really useful, it would need to be possible to embed
expressions in the string (not just variable names). This is
tantalizingly close to being possible with string mixins.
More information about the Digitalmars-d
mailing list