Entomy / Ada-Improvements

Repository of Ada language improvement ideas
GNU General Public License v3.0
4 stars 0 forks source link

Orthogonal block terminators #21

Open Entomy opened 5 years ago

Entomy commented 5 years ago

Ada does:

In most cases:

if True then
end if;

Terminating with the same keyword that introduced the block

but also:

package Example is
end Example;

or

package Example is
end;

Terminating with the name of the block, or just end

It should be:

end <introducing keyword> (<name>);

Rationale: Lack of orthogonality confuses programmers, as they have to remember when a different syntax is used, and what that syntax is. Furthermore, it can (and in this case does) complicate parsing.

The <introducing keyword> should be mandatory, as it makes matching substantially easier, even if using advanced Regex engines. The <name> should stay optional, as it's not required for parsing, and in small code snippets is easily matched by a human, but allows for explicit naming in more complicated sources.