Skip to content

Slightly fix the example files #267

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

Merged
merged 8 commits into from
Feb 24, 2023
Merged

Slightly fix the example files #267

merged 8 commits into from
Feb 24, 2023

Conversation

chykon
Copy link
Contributor

@chykon chykon commented Feb 13, 2023

Description & Motivation

Examples should be given special attention, as the quality of the examples can both attract and repel new users from the project.

This set of changes proposes:

  • Remove ignore_for_file: avoid_print from examples, import dart:io and use stdout.writeln('string') instead of print('string'). Subjectively, ignoring the rules of the linter in the examples does not look very nice.
  • Ignore *.sv files, because the fir_filter.dart example creates a rtl.sv file (maybe in the future there will be more examples that save the generated SystemVerilog to a file).
  • Slightly tweak comments to match Effective Dart (dots, capital letters, etc).
  • In the fir_filter.dart file, the declaration code and comments have been slightly rearranged to make the example more consistent.
  • Other minor changes.

Related Issue(s)

No.

Testing

The only more or less significant change in the code is the use of the stdout.writeln('string') function instead of print('string'). You can check the functionality by running the examples.

Backwards-compatibility

Is this a breaking change that will not be backwards-compatible? If yes, how so?

Unfortunately, since the dart:io library is now used, it becomes impossible to compile examples in JS to run in browsers, but this should not be a problem since ROHD itself also uses the dart:io library.

Documentation

Does the change require any updates to documentation? If so, where? Are they included?

README.md contains the code from example.dart, but since README.md is under revision, it is better to make changes in the new version of README.md.

@mkorbel1
Copy link
Contributor

Remove ignore_for_file: avoid_print from examples, import dart:io and use stdout.writeln('string') instead of print('string'). Subjectively, ignoring the rules of the linter in the examples does not look very nice.

I feel like using stdout.writeln instead of print is just another way of avoiding the lint check, plus might make it look more annoying to print to the console. Java's System.out.println is intimidating to new users compared to the print of Python, and I think stdout.writeln is a step in the wrong direction. Perhaps a comment explaining the lint disable motivation would offer two benefits:

  • Teach how easy it is to configure/disable lints (something annoying in many hardware dev stacks)
  • Explain that print is easy, but the motivation for having the lint there in the first place.

@chykon
Copy link
Contributor Author

chykon commented Feb 14, 2023

Doesn't it seem that the explanatory comment is excessively big?

@mkorbel1
Copy link
Contributor

Doesn't it seem that the explanatory comment is excessively big?

Haha it does seem a bit large... brings a lot of attention to it which could distract from the actual example.

Maybe something closer to this (not necessarily exactly this) would be better?
"Though we usually avoid them, for this example, allow print messages (disable lint)."

Copy link
Contributor

@mkorbel1 mkorbel1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change on the copyright

Copy link
Contributor

@mkorbel1 mkorbel1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@mkorbel1 mkorbel1 merged commit 693e821 into intel:main Feb 24, 2023
@chykon chykon deleted the fix-examples branch February 24, 2023 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants