Why is Phobos `Flag` so overthought ?
Nick Treleaven
nick at geany.org
Thu May 9 18:48:12 UTC 2024
On Thursday, 9 May 2024 at 13:40:56 UTC, cc wrote:
> It's pointless mandatory verbosity. StopWatch ctor only takes
> one boolean argument. It doesn't *need* to specify what it
> relates to. You either already know, or you have to look it up
> anyway. Flags made sense when you might get the order of
> multiple bools confused, but if there's only one, *or* if you
> can use named arguments to avoid ambiguity,
So you have justified Flag.
> there's no point in demanding every parameter be a unique type.
> It's easy to remember I can pass a bool to a StopWatch to
> autostart it.
But perhaps true means manual start? Remembering can also be used
to justify dynamic typing outside of hot loops, I'd rather not
rely on remembering with a big team of programmers working on a
project.
> It's less easy to remember that a specific unique type needs to
> be used, and remembering whether the name/casing of that type
> was Start, StartNow, StartAuto, Autostart, AutoStart,
> autostart, autoStart, etc.
So just pass it true, and run the compiler. The compiler will
tell you what the correct type is.
> We have a tool in our box already called `true` and that
> solves the problem. If we had to type out the full name of
> every argument passed to every function ever written we may as
> well just adopt ObjC Cocoa style and call it
> StopWatchWithAutoStartBool().
Strawman.
More information about the Digitalmars-d-learn
mailing list