writef %d of string

bearophile bearophileHUGS at lycos.com
Sun Dec 4 18:52:31 PST 2011


Stewart Gordon:

> You mean all programming languages should support CTFE for argument validation?

This is not necessary, and it's not sufficient...


> What if the format string isn't even known at compile time in the first place?

In this case the format string validation is done at run-time. It's opportunistic static typing. And it's better than leaving all the tests at run-time. In a dynamically typed language I accept format strings to be verified at run-time. In a compiled language I want some of advantages of static typing, where possible.


> http://www.acronymfinder.com/ is your friend.

Or even better, reduce the usage of uncommon acronyms in normal communications :-)


> I meant rare among the world's various C compilers.  Are you going by usage statistics?

In the end D wants to be better than C and C compilers.


> What do you mean by a "built-in rule" exactly?

In GCC there is a hard-coded routine that tests (or tries to) the correctness of format strings known at compile-time.


> Maybe there's a way that the template instances can be very small, delegating most of the 
> work to non-templated functions.

This is easy to do, just call the same runtime function after the compile-time test done in the template :-) But DMD probably has to learn to better remove unnecessary template instances from the resulting binary. Walter has discussed this topic a bit several times.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list