DerelictSASS
Mike Parker via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Sat Nov 22 16:26:43 PST 2014
On 11/23/2014 1:44 AM, ponce wrote:
> A tip to keep in mind when translating C/C++ headers:
>
> ---
> enum Sass_Tag {
> SASS_BOOLEAN,
> SASS_NUMBER,
> SASS_COLOR
> };
> ---
>
> is best translated as
>
> ---
>
> alias Sass_Tag = int;
> enum : Sass_Tag {
> SASS_BOOLEAN,
> SASS_NUMBER,
> SASS_COLOR
> }
> ---
>
> That way your enum isn't namespaced.
>
I completely missed that.
@Lodin The reason ponce suggests this is that when using the binding in
D, it's a good idea to for it to look as close to the C code as
possible. That way, existing C code (especially examples from
documentation and tutorials) can more easily be ported to D. Since C
enums aren't namespaced, they shouldn't be in the binding, either.
Some people may prefer the bindings to include more D features, but IMO
if you're going to put something out there for everyone and anyone to
use, particularly if you want to be consistent with other Derelict
bindings, it's better to avoid them.
More information about the Digitalmars-d-announce
mailing list