Replies: 1 comment 3 replies
-
+1 conceptually, but I'm not sure what practical value we'd get out of that. Swift, for reference, has three different levels of types: "trivial register types", "pointer sized values managed by arc" and "general things". The reason for the middle thing is that Swift doesn't always instantiate generics like Mojo/Rust do, owned object pointers are very common, and knowing the size of something allows a bunch of optimizations. What would "knowing something is register passable" enable in practice? I'm not sure you example is the best motivation. We don't have conditional conformance yet (e.g. array is copyable if all members are) so we can't do your example quite yet. Even when we can, it isn't actually an optimization - after instantiation, Optional will get converted to a nice representation if T is register passable. |
Beta Was this translation helpful? Give feedback.
-
Right now register passable types are defined using a decorator:
@register_passable("trivial")
. However, if instead we had a marker traitRegisterPassable
, we would have cleaner options for composition. The main benefit would be clear with wrapper and container types likeOptional
andVariant
. Ideally this would look something like (bikeshed syntax for extensions):That way, if a type is register passable, or in the case of
Variant
all types within it are, then the container itself can be marked that way as well.Beta Was this translation helpful? Give feedback.
All reactions