jai-like CTFE string formating

Manu via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 13 06:35:11 PDT 2017


On 13 August 2017 at 12:07, Stefan Koch via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Sunday, 13 August 2017 at 00:42:08 UTC, Manu wrote:
>
>> On 13 August 2017 at 00:15, Stefan Koch via Digitalmars-d <
>>
>>> [ ... ]
>>>
>>
>> If you're keen to introduce a new function, I'd strongly suggest changing
>> to {1} {2} {3}, or %1 %2 %3, format/printf functions where you don't supply
>> the place index are useless a lot of the time and need to be rewritten,
>> which is a tedious task.
>>
>
> I am not too keen introducing a new function, given that it most likely
> won't be accepted into phobos.
>
> However your suggestion is indeed a good suggestion.
> The check would then see if the number of args are equal to the max index.
> And it would check that all indices from 0 to maxIdx are used at least
> once.
>

No, it's not always the case that a format string uses every argument.
Format strings are usually taken from the translation table. Different
languages have different word orders (which is why placeholders need to
accept an arg index), and occasionally, some translations don't use all the
args because the sentence structure doesn't make sense, or excess args are
supplied because one language requires a string that others don't use.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20170813/1ae84873/attachment-0001.html>


More information about the Digitalmars-d mailing list