[Issue 4927] writefln silently ignores arguments not present in the format string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 10 10:50:45 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4927



--- Comment #3 from bearophile_hugs at eml.cc 2011-09-10 10:50:28 PDT ---
If a programmer wants to format just the first argument, then this is the code
to write:

writef("%d", 1);
writefln(2);

Introducing/keeping a muddy semantics to avoid writing one more function call
like is not a so good design.

Keeping designs semantically clean is usually better, because it helps avoid
bugs and more importantly it avoids unexpected corner cases and unwanted side
interactions.

The introduction of a special case with muddy semantics is sometimes
acceptable, when it gives _significant_ advantages, that means it makes
something else significantly more handy or significantly simpler, etc. But in
this case I think it makes code only a bit more handy, while increasing the
probability of bugs.

----------------

(In reply to comment #2)

> One possibility would be to silently ignore arguments is positional parameters
> are used, and not ignore them otherwise.

This is better than the current situation.


> it's often good to present several arguments and let the user choose the
> formatting string (which may ignore some argument).

Usually explicit is better than implicit. If this is the desired behaviour,
then the right thing is to use/introduce an explicit syntax to do it.
Positional arguments are meant to do this, I presume.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list