The new core.sys.windows

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 16 11:48:50 PDT 2015


On 2015-10-14 23:52, Vladimir Panteleev wrote:

> For example: usage of named enums. In C, all enums (or #defines) all
> live within the name namespace, with a prefix serving as the
> disambiguating "namespace", and all are implicitly convertible to each
> other. In many places, the bindings use named enums instead, which
> provides the advantage of strong typing - if a function accepts a
> parameter of a certain enum, you cannot accidentally pass a member of
> another enum.

Apple exposes their C/Objective-C enums in Swift without the usual 
prefix, example:

Objective-C:

enum {
    NSOrderedAscending = -1,
    NSOrderedSame,
    NSOrderedDescending
};
typedef NSInteger NSComparisonResult;

Swift:

enum NSComparisonResult : Int {
     case OrderedAscending
     case OrderedSame
     case OrderedDescending
}

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list