-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Records: expose named/optional fields through an extension getter instead of a static method #1275
Comments
You can tear off extension methods too, so I don't think this would buy us anything. |
But we can make it a getter, which afaik you can't tear off? (sorry I wasn't super clear about that part) |
Ah, right. I could be wrong, but I don't think that buys us much in terms of optimization affordances. |
The thinking is that we would know exactly where all the invocations of this method are, and could potentially optimize away all the metadata required to power this feature when it isn't used. You could still definitely circumvent this though by calling these getters on something typed |
This was probably considered, but it might be nice to expose these static methods:
Instead as an extension on the Record class:
This would be easier use,
myRecord.positionalFields
vsRecord.positionalFields(myRecord)
, and it would prevent grabbing a tearoff of these methods.One bonus of preventing a tearoff is that the compilers should be able to easily know exactly where and how these getters are invoked (and on what record types), and potentially optimize/treeshake better with that knowledge.
The text was updated successfully, but these errors were encountered: