Skip to content

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

Closed
@eernstg

Description

@eernstg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    patternsIssues related to pattern matching.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions