C to D bindings: how much do you D-ify the code?

Mike Parker aldacron at gmail.com
Sat Oct 26 08:31:00 PDT 2013


On 10/27/2013 12:11 AM, Michel Fortin wrote:
> On 2013-10-26 14:52:42 +0000, Mike Parker <aldacron at gmail.com> said:
>
>> On 10/26/2013 9:09 PM, Benjamin Thaut wrote:
>>> Am 25.10.2013 15:10, schrieb Lionello Lunesu:
>>>>
>>>> 1. enum names vs prefixes
>>>> enum FOO { FOO_A, FOO_B }; -> enum FOO {A,B}
>>>
>>> I actually do number 1 whenever creating C bindings. Because its not
>>> really DRY to write: FOO.FOO_A
>>
>> alias FOO = int;
>> enum { FOO_A, FOO_B };
>>
>> Otherwise, it doesn't match the C API.
>
> But then you lose the type-safety of an enum. Why not this:
>
>      enum FOO { FOO_A, FOO_B };
>      alias FOO.FOO_A FOO_A;
>      alias FOO.FOO_B FOO_B;
>
> ?
>
> Overly verbose perhaps.
>

When you do it by hand, as I do, this approach can make you cry.


More information about the Digitalmars-d mailing list