Regarding the proposed Binray Literals Deprecation

Walter Bright newshound2 at digitalmars.com
Sun Sep 11 19:20:36 UTC 2022


On 9/10/2022 12:00 PM, Steven Schveighoffer wrote:
> https://github.com/schveiguy/poker/blob/master/source/poker/hand.d#L261
> 
> This was so much easier to comprehend than the equivalent hex.

     assert(beststraight(0b10000000011110) == Rank.Five);
     assert(beststraight(0b10101111111110) == Rank.Ten);

Are you sure the number of digits is correct? Does your card deck really have 14 
cards in a suite? :-)

Me, annoying curmudgeon that I am, would write a little parser so I could write 
such tests as:

    assert(beststraight(hand!"A234567890JQK") == Rank.Five);

and use HCDS for Hearts, Clubs, Diamonds, and Spaces.

D is ideal for creating such micro-DSLs, such as this one:

 
https://github.com/dlang/dmd/blob/master/compiler/src/dmd/backend/disasm86.d#L3601

which makes adding test cases for the disassembler dramatically easier to read 
and compose.



More information about the Digitalmars-d mailing list