Re: Inline aggregate types

2016-12-05 Thread Jacob Carlborg via Digitalmars-d
On 2016-12-05 13:32, Ethan Watson wrote: I also want to support statically sized bit arrays, Phobos only provides support for dynamically sized. That would be nice, I had a need for that. -- /Jacob Carlborg

Re: Inline aggregate types

2016-12-05 Thread Ethan Watson via Digitalmars-d
On Monday, 5 December 2016 at 11:57:18 UTC, Guillaume Chatelet wrote: Do you plan on contributing this back to phobos? I also came across this exact same problem. It'll want to go through a few polish iterations before I even think of doing that; and it'll need support for things like toStrin

Re: Inline aggregate types

2016-12-05 Thread Guillaume Chatelet via Digitalmars-d
On Friday, 2 December 2016 at 11:11:30 UTC, Ethan Watson wrote: On Friday, 2 December 2016 at 10:16:17 UTC, Jacob Carlborg wrote: [...] I was attempting to support all methods. new class isn't the cleanest way of doing things either, so I decided I'd support all the things and let the user c

Re: Inline aggregate types

2016-12-02 Thread Ethan Watson via Digitalmars-d
On Friday, 2 December 2016 at 10:16:17 UTC, Jacob Carlborg wrote: Using an alias without a template constraint works for me. I was attempting to support all methods. new class isn't the cleanest way of doing things either, so I decided I'd support all the things and let the user choose what t

Re: Inline aggregate types

2016-12-02 Thread Jacob Carlborg via Digitalmars-d
On 2016-12-02 10:11, Ethan Watson wrote: On Friday, 2 December 2016 at 08:33:17 UTC, Jacob Carlborg wrote: But wWhat about an anonymous class as ag0aep6g mentioned? Usability I see is something that is key here. Having to do a typeof yourself is one extra step away from an intuitive API. So I

Re: Inline aggregate types

2016-12-02 Thread Ethan Watson via Digitalmars-d
On Friday, 2 December 2016 at 08:33:17 UTC, Jacob Carlborg wrote: But wWhat about an anonymous class as ag0aep6g mentioned? Usability I see is something that is key here. Having to do a typeof yourself is one extra step away from an intuitive API. So I tried making a definition like this: m

Re: Inline aggregate types

2016-12-02 Thread Jacob Carlborg via Digitalmars-d
On 2016-12-01 21:31, Ethan Watson wrote: https://github.com/Remedy-Entertainment/binderoo/blob/master/binderoo_client/d/src/binderoo/bitpacking.d So I've been not-all-that-pleased with std.bitmanip.bitfields for a while. It's nice that it's there, but I'm binding to C++ objects where the meanin

Re: Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
On Thursday, 1 December 2016 at 20:31:32 UTC, Ethan Watson wrote: https://github.com/Remedy-Entertainment/binderoo/blob/master/binderoo_client/d/src/binderoo/bitpacking.d Stefan also reminded me that this would be a perfect spot where __symbol CTFE variables would make life much easier (especi

Re: Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
On Thursday, 1 December 2016 at 20:58:53 UTC, H. S. Teoh wrote: In cases like these, q{} comes to the rescue: I had precisely zero idea this existed.

Re: Inline aggregate types

2016-12-01 Thread H. S. Teoh via Digitalmars-d
On Thu, Dec 01, 2016 at 08:31:32PM +, Ethan Watson via Digitalmars-d wrote: [...] > So the invokation, while not as readable, looks like: > > mixin BitPack!( "@PackSize( 3 ) int iSomeInt = 3; @PackSize( 1 ) bool > bSomeBool = true; @PackSize( 4 ) int iSomeOtherInt;" ); > > I'm sure I just mad

Re: Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
On Thursday, 1 December 2016 at 20:57:13 UTC, Andrei Alexandrescu wrote: The simplest way to go here is to accept an initializer for the entire ubyte/ushort/uint/ulong underlying the bitfields. -- Andrei In terms of efficiency at compile time, indeed. But there's multiple paths there. You cou

Re: Inline aggregate types

2016-12-01 Thread Andrei Alexandrescu via Digitalmars-d
On 12/01/2016 03:31 PM, Ethan Watson wrote: I'm binding to C++ objects where the meaningful default values require those packed values to have initial values. It's rather painful to get that working with the Phobos implementation. The simplest way to go here is to accept an initializer for the

Re: Inline aggregate types

2016-12-01 Thread ag0aep6g via Digitalmars-d
On 12/01/2016 09:31 PM, Ethan Watson wrote: I'm also sure there's plenty of other legit uses for inline aggregate types. So while the feature doesn't exist in the language yet, at least you can now see that there's quite a legit hacky-as-all-fuck workaround for it. Inter

Inline aggregate types

2016-12-01 Thread Ethan Watson via Digitalmars-d
while not as readable, looks like: mixin BitPack!( "@PackSize( 3 ) int iSomeInt = 3; @PackSize( 1 ) bool bSomeBool = true; @PackSize( 4 ) int iSomeOtherInt;" ); I'm sure I just made someone cry looking at that. I'm also sure there's plenty of other legit uses for inline