Compile Time Argument Evaluation
bearophile
bearophileHUGS at lycos.com
Thu Jan 3 17:59:35 PST 2013
DProgrammer2:
> If there's no good way to do this that's fine.
>
> I bring this up because I saw
>
> https://github.com/xomboverlord/xomb/blob/unborn/kernel/core/kprintf.d
>
> which was neat, but it generates a new kprintf function for
> different arguments. I thought it'd be interesting to try and
> have the benefits of compile time checking without the extra
> generated code.
I think currently there is no other way. Despite it's something
I'd like a lot.
Someday I'd like a function like this in Phobos, that verifies
the formatting string at compile-time:
ctwritefln!"%d %s"(5, "hello");
Such function can be written with just a very light wrapper
around a normal writefln (and later to something more optimized).
This means that the actual template bloat can be minimized a lot,
but not fully removed.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list