digitalmars.D - D-issapointed after using C# for a while.
- Taylor Hillegeist (7/7) Nov 11 2016 In the past I have worked with D, C#, Java, Python and C and some
- Jerry (7/15) Nov 11 2016 D doesn't have bitfields though? Phobos just has a template that
- Jonathan M Davis via Digitalmars-d (4/9) Nov 11 2016 What attributes do you need that aren't there already? UDAs? Looking at ...
- Jerry (4/15) Nov 11 2016 Yah I need to associate some extra information with the bitfields
- Jonathan M Davis via Digitalmars-d (51/69) Nov 11 2016 It would definitely be possible to make it so that std.bitmanip.bitfield...
- Era Scarecrow (7/14) Nov 12 2016 I can't help but remember that in my variant of Bitfields I had
suddenly realize the convenience and flexibility I had in D. One case in particular is with bit-fields in D they are a pleasure to Enums that are flexible for some cases, I suppose I just wanted to say thanks to the D community for their effort.
Nov 11 2016
On Friday, 11 November 2016 at 15:36:18 UTC, Taylor Hillegeist wrote:some other less popular languages. Most recently working with D. One case in particular is with bit-fields in D they are a sure they have Enums that are flexible for some cases, I suppose I just wanted to say thanks to the D community for their effort.D doesn't have bitfields though? Phobos just has a template that emulates them by mixing in functions that do the bit shifting. Because it done through mixins it means you can't attach attributes to the fields. Which I am in need of. Haven't found a good workaround though.
Nov 11 2016
On Friday, November 11, 2016 23:32:11 Jerry via Digitalmars-d wrote:D doesn't have bitfields though? Phobos just has a template that emulates them by mixing in functions that do the bit shifting. Because it done through mixins it means you can't attach attributes to the fields. Which I am in need of. Haven't found a good workaround though.What attributes do you need that aren't there already? UDAs? Looking at the code, the full set of appropriate built-in attributes are on them already. - Jonathan M Davis
Nov 11 2016
On Saturday, 12 November 2016 at 01:02:05 UTC, Jonathan M Davis wrote:On Friday, November 11, 2016 23:32:11 Jerry via Digitalmars-d wrote:Yah I need to associate some extra information with the bitfields using UDAs.D doesn't have bitfields though? Phobos just has a template that emulates them by mixing in functions that do the bit shifting. Because it done through mixins it means you can't attach attributes to the fields. Which I am in need of. Haven't found a good workaround though.What attributes do you need that aren't there already? UDAs? Looking at the code, the full set of appropriate built-in attributes are on them already. - Jonathan M Davis
Nov 11 2016
On Saturday, November 12, 2016 03:30:58 Jerry via Digitalmars-d wrote:On Saturday, 12 November 2016 at 01:02:05 UTC, Jonathan M Davis wrote:It would definitely be possible to make it so that std.bitmanip.bitfields could handle UDAs, but I don't expect that it would be particularly fun to implement. e.g. the example struct A { int a; mixin(bitfields!( uint, "x", 2, int, "y", 3, uint, "z", 2, bool, "flag", 1)); } A obj; obj.x = 2; obj.z = obj.x; could become something like struct A { int a; mixin(bitfields!( uint, "x", 2, " Foo Bar(12)" int, "y", 3, uint, "z", 2, " Foo" bool, "flag", 1)); } A obj; obj.x = 2; obj.z = obj.x; but that would require making it so that bitfields looks at the types of what it's passed to see if it has the extra string (similar to what std.getopt.getopt does), and if it does, then it mixes in that string as attributes on that field. It's a bit a of a pain to do, but it could be done. What would make it worse though is if you want to try and make it so that the attributes can be applied to just the setters or just the getters. Then you'd probably end up with stuff like struct A { int a; mixin(bitfields!( uint, "x", 2, " Foo Bar(12)", " Foo" int, "y", 3, uint, "z", 2, " Foo", "", bool, "flag", 1)); } A obj; obj.x = 2; obj.z = obj.x; which is getting a bit ugly IMHO. But it would be possible. In any case, that's the best approach that I can think of at the moment. - Jonathan M DavisOn Friday, November 11, 2016 23:32:11 Jerry via Digitalmars-d wrote:Yah I need to associate some extra information with the bitfields using UDAs.D doesn't have bitfields though? Phobos just has a template that emulates them by mixing in functions that do the bit shifting. Because it done through mixins it means you can't attach attributes to the fields. Which I am in need of. Haven't found a good workaround though.What attributes do you need that aren't there already? UDAs? Looking at the code, the full set of appropriate built-in attributes are on them already. - Jonathan M Davis
Nov 11 2016
On Saturday, 12 November 2016 at 03:59:08 UTC, Jonathan M Davis wrote:It would definitely be possible to make it so that std.bitmanip.bitfields could handle UDAs, but I don't expect that it would be particularly fun to implement. e.g. the example <Snip> which is getting a bit ugly IMHO. But it would be possible. In any case, that's the best approach that I can think of at the moment.I can't help but remember that in my variant of Bitfields I had it allow default values. I could probably extract that part out and re-inject it into the current bitfields version, although I remember quite the fun time debugging said code, namely extracting the text generated...
Nov 12 2016