[swift-evolution] Promote "primitive" types to enums in extensions

Carlos Rodríguez Domínguez carlos at everywaretech.es
Fri Mar 25 06:43:54 CDT 2016


Yes, exactly, that’s a great summary of the proposal!

> El 25 mar 2016, a las 12:25, Haravikk <swift-evolution at haravikk.me> escribió:
> 
> 
>> On 25 Mar 2016, at 09:56, Carlos Rodríguez Domínguez via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> The key of this proposal is that the struct/class should come from outside any swift source code, that is, either imported by the compiler from C, or auto-generated from any external tool (i.e., a CoreData autogenerated class from a graphically specified data model). Of course, in well written structures (as specified by Paul Ossenbruggen) we shouldn’t have any need for this proposal. However, many C structures make use of a raw type instead of an enum type, but specifying (through the associated documentation, not by any type enforcement) that only a set of enum values are allowed. Consequently, the resulting code making use of those structures becomes highly error prone, and, particularly in swift, very “old-style” code and difficult to understand for newcomers.
>> 
>> Again, I would like to highlight that my proposal intends to avoid as much as possible the use of enums’ raw values.
> 
> I think I may be similarly misunderstanding your proposal; your intention then is to import the type as an enum with raw value (to facilitate the conversion to/from the C code) but without exposing that raw value on the Swift side?
> 
> In that case I think I’m in favour.



More information about the swift-evolution mailing list