Inline aggregate types
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Thu Dec 1 12:58:53 PST 2016
On Thu, Dec 01, 2016 at 08:31:32PM +0000, 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 made someone cry looking at that.
In cases like these, q{} comes to the rescue:
mixin BitPack!(q{
@PackSize( 3 ) int iSomeInt = 3;
@PackSize( 1 ) bool bSomeBool = true;
@PackSize( 4 ) int iSomeOtherInt;
});
See? Not so bad after all. ;-)
(And *that* is why we have a q{} literal in a language that, arguably,
already has far too many ways to write a string literal.)
T
--
Customer support: the art of getting your clients to pay for your own incompetence.
More information about the Digitalmars-d
mailing list