Compile-Time Constant Expressions for Swift

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.

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

I don't see why this would be necessary. Just as the outermost @compilerEvaluable function will ascertain that any functions it may call will be @compilerEvaluable (or otherwise fail to compile), it can also decide to export their code in the process.

any updates on this? I would love to see regex validation on StaticString during compiling.

Terms of Service

Privacy Policy

Cookie Policy