Re: Is flags enum needed in Phobos?

2012-10-15 Thread bearophile
Era Scarecrow: But more likely it will be merged with another file, likely std.bitmanip or something... A Phobos pull request is OK even if it's meant to be merged with std.bitmanip. Pull requests are not just for separate modules. On GitHub people will be able to comment on single lines

Re: Is flags enum needed in Phobos?

2012-10-14 Thread Era Scarecrow
On Sunday, 7 October 2012 at 09:48:50 UTC, Era Scarecrow wrote: On Sunday, 7 October 2012 at 09:22:17 UTC, Denis Shelomovskij wrote: I'd like to see enum syntax for flug enum. So I dislike function calls like `set_flag`, `checkAll`, etc. (IMHO) You mean... binary basic syntax? That shouldn't

Re: Is flags enum needed in Phobos?

2012-10-14 Thread Era Scarecrow
On Sunday, 14 October 2012 at 06:34:39 UTC, Era Scarecrow wrote: I've added binary functionality. Looking at these notes I see I forgot the enum/array part; And checking for binary true isn't added yet. However I'll get to it sooner or later. Both opBinary and opOpBinary are supported so far.

Re: Is flags enum needed in Phobos?

2012-10-14 Thread bearophile
Era Scarecrow: I can't get opOpAssign working properly, and it's worse with arrays. Removing opOpAssign, everything else (arrays, single flags, other flags) works properly. Are such problems known? In bugzilla or here? Are those fixable? It's likely the last time I'll update it for a

Re: Is flags enum needed in Phobos?

2012-10-14 Thread Era Scarecrow
On Monday, 15 October 2012 at 02:54:38 UTC, bearophile wrote: Era Scarecrow: I can't get opOpAssign working properly, and it's worse with arrays. Removing opOpAssign, everything else (arrays, single flags, other flags) works properly. Are such problems known? In bugzilla or here? Are those

Re: Is flags enum needed in Phobos?

2012-10-14 Thread Era Scarecrow
K I have opOpAssign working. I may have to clean up documentation a little and clean the unittests up a bit, but it all appears to be working. Feel free to give it a try. I have added opSlice, which returns an array of your enum of all the flags it qualifies for. An empty enum (say, zero)

Re: Is flags enum needed in Phobos?

2012-10-07 Thread Denis Shelomovskij
06.10.2012 23:50, Era Scarecrow пишет: On Wednesday, 26 September 2012 at 19:11:37 UTC, bearophile wrote: I think it's a good idea to have a well written EnumFlags data structure in Phobos. In C# this feature is even built-in. So issue 6946 is not closing, unless Andrei or Walter decide it's a

Re: Is flags enum needed in Phobos?

2012-10-07 Thread Era Scarecrow
On Sunday, 7 October 2012 at 09:22:17 UTC, Denis Shelomovskij wrote: I'd like to see enum syntax for flug enum. So I dislike function calls like `set_flag`, `checkAll`, etc. (IMHO) You mean... binary basic syntax? That shouldn't be too hard. So something like..? Flags x; with(Flags) {

Re: Is flags enum needed in Phobos?

2012-10-06 Thread Denis Shelomovskij
25.09.2012 21:14, Denis Shelomovskij пишет: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? My variant is here (search for `flagEnum`): https://bitbucket.org/denis_sh/misc/src/tip/stdd/typecons.d It has a bug and I have no

Re: Is flags enum needed in Phobos?

2012-10-06 Thread Era Scarecrow
On Wednesday, 26 September 2012 at 19:11:37 UTC, bearophile wrote: I think it's a good idea to have a well written EnumFlags data structure in Phobos. In C# this feature is even built-in. So issue 6946 is not closing, unless Andrei or Walter decide it's a bad idea to have something like this

Re: Is flags enum needed in Phobos?

2012-09-26 Thread Denis Shelomovskij
25.09.2012 21:14, Denis Shelomovskij пишет: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? My variant is here (search for `flagEnum`): https://bitbucket.org/denis_sh/misc/src/tip/stdd/typecons.d It has a bug and I have no

Re: Is flags enum needed in Phobos?

2012-09-26 Thread Dmitry Olshansky
On 26-Sep-12 21:39, Denis Shelomovskij wrote: 25.09.2012 21:14, Denis Shelomovskij пишет: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? My variant is here (search for `flagEnum`):

Re: Is flags enum needed in Phobos?

2012-09-26 Thread Denis Shelomovskij
26.09.2012 21:52, Dmitry Olshansky пишет: On 26-Sep-12 21:39, Denis Shelomovskij wrote: 25.09.2012 21:14, Denis Shelomovskij пишет: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? My variant is here (search for

Re: Is flags enum needed in Phobos?

2012-09-26 Thread Dmitry Olshansky
On 26-Sep-12 22:17, Denis Shelomovskij wrote: Please give me usage examples (unittests), and I will implement the functionality. Now I don't understand what are n-state flags and what is the difference with std.bitmanip.bitfields. Well thinking more of it, bitfields indeed will do for a

Re: Is flags enum needed in Phobos?

2012-09-26 Thread bearophile
Denis Shelomovskij: OK. Looks like such functionality isn't needed and I don't have to do a pull request. What about to close http://d.puremagic.com/issues/show_bug.cgi?id=6946 with WONTFIX? I think it's a good idea to have a well written EnumFlags data structure in Phobos. In C# this

Re: Is flags enum needed in Phobos?

2012-09-26 Thread Michael
On Tuesday, 25 September 2012 at 17:13:44 UTC, Denis Shelomovskij wrote: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? +1. Also I'm not sure: * Should we support converting from a number to a flag enum? +1. * If so,

Re: Is flags enum needed in Phobos?

2012-09-26 Thread Jesse Phillips
On Wednesday, 26 September 2012 at 18:16:54 UTC, Denis Shelomovskij wrote: Thanks for the answer, but still there are only few guys here interesting in it to be included in Phobos, so WONTFIX-ing the issue looks reasonable. I can just support this struct in my library for you. There are few

Is flags enum needed in Phobos?

2012-09-25 Thread Denis Shelomovskij
.NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? My variant is here (search for `flagEnum`): https://bitbucket.org/denis_sh/misc/src/tip/stdd/typecons.d It has a bug and I have no idea how to fix it: `AB.init |= AB.a` and

Re: Is flags enum needed in Phobos?

2012-09-25 Thread bearophile
On Tuesday, 25 September 2012 at 17:13:44 UTC, Denis Shelomovskij wrote: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? See also: http://d.puremagic.com/issues/show_bug.cgi?id=6946 Bye, bearophile

Re: Is flags enum needed in Phobos?

2012-09-25 Thread Denis Shelomovskij
25.09.2012 22:03, bearophile пишет: On Tuesday, 25 September 2012 at 17:13:44 UTC, Denis Shelomovskij wrote: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? See also: http://d.puremagic.com/issues/show_bug.cgi?id=6946

Re: Is flags enum needed in Phobos?

2012-09-25 Thread Faux Amis
On 25/09/2012 20:03, bearophile wrote: On Tuesday, 25 September 2012 at 17:13:44 UTC, Denis Shelomovskij wrote: .NET has FlagsAttribute, Java has EnumSet. Looks like we need this too. How about to add a library solution to Phobos? See also: http://d.puremagic.com/issues/show_bug.cgi?id=6946

Re: Is flags enum needed in Phobos?

2012-09-25 Thread bearophile
Faux Amis: Isn't there a way to retrieve all reserved words? I think the answer is negative. And, did you do a pull request? I don't do those yet. And that code is just a prototype. Bye, bearophile

Re: Is flags enum needed in Phobos?

2012-09-25 Thread bearophile
Faux Amis: Isn't there a way to retrieve all reserved words? This is a possibility: assert(__traits(is_reserved_word, import)); Bye, bearophile