Skip to content
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: static methods similar to reflection may be expensive #1277

Closed
eernstg opened this issue Oct 30, 2020 · 1 comment
Closed

Records: static methods similar to reflection may be expensive #1277

eernstg opened this issue Oct 30, 2020 · 1 comment
Labels
patterns Issues related to pattern matching.

Comments

@eernstg
Copy link
Member

eernstg commented Oct 30, 2020

Cf. https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md.

The support for reflection-ish operations on Record may be expensive:

If a large program uses many records with named fields and contains any invocation of Record.namedFields(r) where the static type of r is dynamic or Record, it will probably be necessary to preserve the names of all named fields in records in the program (as symbols, or possibly strings, cf. #1276).

Similarly, every record would need to have run-time information about the number of positional fields if the program contains an invocation of Record.positionalFields(r), but that's probably not so expensive.

It's easily getting similar to operations that otherwise require 'dart:mirrors'. We might want to leave out those two static methods, or we might provide them in a separate library (say, 'dart:records', maybe as extension getters on Record). However, it looks like this wouldn't be hard to do, because nothing else in the design depends on those methods.

@eernstg eernstg added the patterns Issues related to pattern matching. label Oct 30, 2020
@eernstg eernstg changed the title Records: Records: static methods similar to reflection may be expensive Oct 30, 2020
@munificent
Copy link
Member

The support for reflection-ish operations on Record may be expensive:

Yes, I share this concern. I put these into the proposal since other languages seem to support it, but I'm definitely not attached to them.

We could move them to a separate library like you suggest but part of my motivation for making them static methods is that even if they are right in core, we can still statically detect whether they are used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patterns Issues related to pattern matching.
Projects
None yet
Development

No branches or pull requests

2 participants