Enums and Dynamic Member Lookup

Nice. We're getting into minutia now, but I feel a small SwizzleComponent enum with cases x, y, z, etc. is nicer than a large Swizzle enum whose cases are the combinations of all orderings (e.g. .xxyy).

SwizzleComponent has a much smaller surface area and is more composable. I think it's harder to pattern match on "concatenated" .xxyy cases.

A related idea is to use OptionSet? That would enable grouping of related swizzles. Need to think more about it.


I think we should continue further discussion of swizzles on the SIMD proposal thread. Folks there may have more ideas.

There is probably a better solution for swizzles, yeah, especially if you don't need extreme brevity. Compile-time validation of dynamic member lookup and method calls would still be useful for the intended purpose of interoperating with dynamic languages, though. For example, you could use it enforce basic syntactic rules around allowed member/method names or the relative ordering of labelled and unlabelled parameters, etc.

Definitely. As others noted, it seems likely that compile-time evaluation of assertions could grow to address that niche.

Compile time evaluation of dynamic member lookup plus ˋ#errorˋ sounds amazing, can‘t wait. :slight_smile: