printf() metaprogramming challenge
Walter Bright
newshound2 at digitalmars.com
Fri May 24 18:39:41 UTC 2019
On 5/24/2019 8:35 AM, Jacob Carlborg wrote:
> This is kind of nice, but I would prefer to have a complete implementation
> written in D (of sprintf) that is @nogc @safe nothrow and pure. To avoid having
> to add various hacks to apply these attributes.
C's sprintf is already @nogc nothrow and pure. Doing our own is not that easy,
in particular, the floating point formatting is a fair amount of tricky work.
Besides, this is a few lines of code, and would fit in fine with betterC.
> I can also add that there was this guy at DConf that said that if a D string
> should be passed to a C library it should manually pass the pointer and length
> separately without any magic ;)
That wouldn't work with %.*s because the .length argument must be cast to int.
More information about the Digitalmars-d
mailing list