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

Dart Static Metaprogramming (macros) for common automation #511

Open
mkorbel1 opened this issue Sep 18, 2024 · 0 comments
Open

Dart Static Metaprogramming (macros) for common automation #511

mkorbel1 opened this issue Sep 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mkorbel1
Copy link
Contributor

Motivation

There are some things in ROHD that can be a bit verbose/redundant. For example, a simple port whose variable name and String port name are the same, and which needs a public getter, could required this kind of boilerplate:

Logic get _myPort => input('myPort');

MyClass({Logic myPort}) {
  myPort = addInput('myPort', myPort);
  // ...
}

Note the word "myPort" is written 6 times, when the intent is really "add an input port named myPort".

Dart's static metaprogramming feature (upcoming, currently experimental) could potentially help automate a lot of this so that a simple annotation, something like input('myPort') could generate all the boilerplate.

A similar strategy could apply for ports on modules and interfaces, and perhaps many other places where things are a bit verbose in the "simple common" case.

The APIs themselves are very flexible, offering more capabilities than the simple case, which is why there is repetition in simple cases.

Desired solution

Implement static metaprogramming features in ROHD to handle the simple cases, while keeping the existing APIs for less simple cases (and backwards compatibility, or for those who don't want to use the new features).

Alternatives considered

No response

Additional details

Information on Dart's static metaprogramming features:
dart-lang/language#1482
https://github.com/dart-lang/language/blob/main/working/macros/feature-specification.md
https://dart.dev/language/macros

@mkorbel1 mkorbel1 added the enhancement New feature or request label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant