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

Reply via email to