Re: Why is Phobos `Flag` so overthought ?

2024-05-11 Thread cc via Digitalmars-d-learn
On Thursday, 9 May 2024 at 18:48:12 UTC, Nick Treleaven wrote: 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

Re: Why is Phobos `Flag` so overthought ?

2024-05-09 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 8 May 2024 at 10:24:07 UTC, Nick Treleaven wrote: Named arguments are optional, so I don't see how they could make Flag redundant. Actually, an external tool could detect when a bool is passed as an argument to a function and warn when not done with a named argument. This would

Re: Why is Phobos `Flag` so overthought ?

2024-05-09 Thread Nick Treleaven via Digitalmars-d-learn
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

Re: Why is Phobos `Flag` so overthought ?

2024-05-09 Thread cc via Digitalmars-d-learn
On Wednesday, 8 May 2024 at 10:24:07 UTC, Nick Treleaven wrote: On Wednesday, 8 May 2024 at 04:27:13 UTC, cc wrote: It doesn't allow a simple boolean to be used as an argument, or any other Flag as they are different instantiations of a template rather than equivalent aliases. It is however

Re: Why is Phobos `Flag` so overthought ?

2024-05-08 Thread Dukc via Digitalmars-d-learn
Nick Treleaven kirjoitti 8.5.2024 klo 13.24: On Wednesday, 8 May 2024 at 04:27:13 UTC, cc wrote: It doesn't allow a simple boolean to be used as an argument, or any other Flag as they are different instantiations of a template rather than equivalent aliases. It is however awful, cumbersome,

Re: Why is Phobos `Flag` so overthought ?

2024-05-08 Thread Nick Treleaven via Digitalmars-d-learn
On Wednesday, 8 May 2024 at 04:27:13 UTC, cc wrote: It doesn't allow a simple boolean to be used as an argument, or any other Flag as they are different instantiations of a template rather than equivalent aliases. It is however awful, cumbersome, annoying design and needs to be completely

Re: Why is Phobos `Flag` so overthought ?

2024-05-07 Thread cc via Digitalmars-d-learn
On Monday, 6 May 2024 at 17:55:49 UTC, user1234 wrote: I think this just works: ```d enum Flag : bool { no, yes } ``` ... must be a reason but I cant find it RN ;) In "properly" designed Phobos packages, it's unambiguous. Take for example std.datetime.stopwatch: ```d import

Re: Why is Phobos `Flag` so overthought ?

2024-05-06 Thread user1234 via Digitalmars-d-learn
On Monday, 6 May 2024 at 18:06:53 UTC, Julian Fondren wrote: On Monday, 6 May 2024 at 17:55:49 UTC, user1234 wrote: I think this just works: ```d enum Flag : bool { no, yes } alias AllowVancancy = Flag; // example usage ``` ```d import std.stdio : writeln; enum Flag : bool { no,

Re: Why is Phobos `Flag` so overthought ?

2024-05-06 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 6 May 2024 at 17:55:49 UTC, user1234 wrote: I think this just works: ```d enum Flag : bool { no, yes } alias AllowVancancy = Flag; // example usage ``` ```d import std.stdio : writeln; enum Flag : bool { no, yes } alias Traditional = Flag; alias Color = Flag; void

Why is Phobos `Flag` so overthought ?

2024-05-06 Thread user1234 via Digitalmars-d-learn
I think this just works: ```d enum Flag : bool { no, yes } alias AllowVancancy = Flag; // example usage ``` Also this is completion friendly whereas Phobos version does not permit DCD completion as it's based on opDispatch. Compare to phobos version: ```d template Flag(string name)