> On Oct 12, 2016, at 12:25 PM, Charles Srstka <cocoa...@charlessoft.com> wrote:
> 
>> On Oct 12, 2016, at 12:32 PM, Kevin Nattinger via swift-evolution 
>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>> 
>> or more like a body (some different options for syntax, pick one obviously):
>> enum Size {
>>      let height: Int
>>      let width: Int
>>      case small {
>>              height = 30
>>              width = 30
>>      }
>>      case medium: {
>>              .height = 60
>>              .width = 60
>>      }
>>      case large = {
>>              let height = 120
>>              let width = 120
>>      }
>> }
> 
> I sort of prefer to have a protocol-like syntax for declaring the properties, 
> instead of let, because we’re doing something similar to what protocols do: 
> we’re promising that each of these things will provide the property, although 
> they might do it in different ways. This also avoids the connotation we have 
> with “let” that the property will be a constant, when in actuality it may be 
> dynamically computed and thus there is the possibility for it to be different 
> each time.

My expectation is that the stored properties *are* constants, maybe even 
compile-time, though I’m open to runtime-initialized options. The whole point 
of the stored properties (as far as I’m concerned) is that they vary between 
cases but are always the same for a particular case, similar to int- or 
string-backed enums. If there’s a truly variable property, it should not be 
part of whatever associated storage backs the cases.

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to