Skip to content

Conversation

pjljvandelaar
Copy link

Dear Gprbuild developers,

Since Ada2012 the if expression is supported.
Using the if expression in many cases improves the readability of the code.

Greetings,
Pierre

P.S. When you see no if expression in the change, the code is simplified even further to improve readability.

Problem detected and solved by Rejuvenation-Ada crate
vote for Rejuvenation-Ada as The 2022 Ada Crate Of The Year

end Optional_Index_Of;

function Others_Allowed_For
(Attribute : Attribute_Node_Id) return Boolean
is
begin
if Attribute = Empty_Attribute then
return False;
Copy link
Author

Choose a reason for hiding this comment

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

Example where if expression is even simplified away!


else
if Match (S_Name, I_Regexp) then
Copy link
Author

Choose a reason for hiding this comment

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

Another example where if expression is simplified even further

@@ -2341,11 +2328,7 @@ package body Scanner is

begin
if Chr = CR then
if Source (P + 1) = LF then
Copy link
Author

Choose a reason for hiding this comment

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

Example where the condition is really limited to what it effects: only 2 or 1!

@pjljvandelaar
Copy link
Author

After this pull request, you might want to change some functions into expression functions to make the code even more readable!

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.

1 participant