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

warnings on code snippets are distracting attention from purpose #917

Open
yannickmoy opened this issue Aug 2, 2023 · 0 comments
Open

Comments

@yannickmoy
Copy link
Collaborator

Looking at the messages from running builds on code snippets in the course "Introduction to Ada", it seems to me that code snippets should be reworked to avoid distracting warnings that do not correspond to the issue being illustrated by the code snippet.

As an example, take the chapter on Arrays. In the section on "Predefined array type: String", hitting Run on the first "greet" code snippet issues this warning:

greet.adb:4:04: warning: "Message" is not modified, could be declared constant [-gnatwk]

This is highlighted in red, pointing to something the user might consider important here. It is not. The constant should in fact be declared with "constant" keyword to avoid that warning.

Take the "main" example that follows. Hitting Run generates three warnings, again highlighted in red:

main.adb:1:09: warning: no entities of "Ada.Text_IO" are referenced [-gnatwu]
main.adb:1:19: warning: use clause for package "Text_IO" has no effect [-gnatwu]
main.adb:7:04: warning: constant "My_Array" is not referenced [-gnatwu]

This could be avoided for the first two lines by removing the useless reference to Ada.Text_IO (which looks like a good idea anyway as this is not used for the explanation of this code snippet), but that would not work for the last line. Here, given the incomplete nature of code snippets, where you may end up declaring entities that are not used (code ellipsis), I recommend to compile the code of this snippet and all others with the switch -gnatwU.

This is a general comment that applies to all the content on learn, but in particular to the content of the course "Introduction to Ada", since newcomers are more likely to get confused by such messages.

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

No branches or pull requests

1 participant