[swift-evolution] Proposal: Support constant expressions in enum case raw values.

Chris Lattner clattner at apple.com
Thu Dec 31 15:52:24 CST 2015


> On Dec 31, 2015, at 1:46 PM, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Example:
> 
> enum A : [Int] {
>    case B = [1,2,3]
> }
> 
> 
> Currently, the following error occurs: "raw value for enum case must be a literal”

A more typically requested example is “case B = 1+2”.

Swift currently has no notion of a “constant expression”.  Once it does, implementing this sort of feature is reasonable, but we need to design out “computed lets” and “pure functions” first.

-Chris




More information about the swift-evolution mailing list