What IDE/EDITOR do you use for D?

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 30 13:12:43 PDT 2014


On Thu, Oct 30, 2014 at 10:03:32PM +0200, ketmar via Digitalmars-d wrote:
> On Thu, 30 Oct 2014 09:46:48 -0700
> "H. S. Teoh via Digitalmars-d" <digitalmars-d at puremagic.com> wrote:
> 
> > I saw that. Do you think it might be extendible enough to replace
> > std.stdio.writef?
>
> p.s. i'm actually planning to add the things like "%?s", where "?"
> means "take width from the writef!() argument". i.e. this will be
> possible: `writef!"%?s"(8, "abc")`, and it will work like
> `writef!"%8s"("abc");`. that's why i'm using that ugly
> `wrWriteWidth()` function to do formatted write.

std.format already supports passing the width argument as a parameter.
In fact, both the precision and the width can be used:

	size_t prec = 3, width = 5;
	writefln("%*f", width, 1.0); // same as "%5f"
	writefln("%.*f", prec, 1.0); // same as "%.3f"
	writefln("%*.*f", prec, width, 1.0); // same as "%5.3f"


> it also can analyze argument types to avoid "to!string" conversions
> and use it's own nuber printing function which not allocates, for
> example.
[...]

Actually, to!string doesn't always allocate, for example, if the target
type supports the toString(scope void delegate(const(char)[])) overload.
There are a few places where it still allocates, but I'm hoping one of
these days to track them all down and eliminate them (where possible).

One of my goals for the CT format string project is to modularize format
string processing, so that it actually will not reference any conversion
code that it doesn't actually use. So if you only use format strings
that don't need allocation, the resulting function should be inferrable
as @nogc. Ditto for pure, nothrow, etc.. Obviously this is impossible
for runtime format strings, since you don't know what formatting the
format string might ask for at runtime, but with compile-time known
format strings, you can easily omit all the unnecessary cases that you
know will never actually get called.


T

-- 
Just because you can, doesn't mean you should.


More information about the Digitalmars-d mailing list