Compile-Time Constant Expressions for Swift

(Saleem Abdulrasool) #142

I don't think that we want Int.bitWidth but rather #sizeof(pointer) or something else. What happens when someone tries to do something like CLong.bitWidth? Well, LLP64 says that should be 32 and not 64.

(Joe Groff) #143

I don't think it'd be practical to allow compile-time evaluation in #if blocks at all. That'd require a pretty deep entanglement of layers in the compiler, since #if can affect what declarations and even what imported modules are available, in turn affecting what name lookup is able to find in #if compile-time expressions. You can make it work with enough rules, but all the rulesets I know of for this kind of thing inevitably lead to confusion.

1 Like