Is this legal?
with Standard.Ada;
procedure Foo is
begin
null;
end Foo;
Is this legal?
with Standard.Ada;
procedure Foo is
begin
null;
end Foo;
If there is a user defined package Standard with child unit Ada, then yes, of course.
The fully expanded name of this package Standard woult be Ada.Standard.
Thou shalt not name an Ada unit Standard.
God forbid, that blashpemy.
But what would you say about this:
with Ada;
package W renames Standard.Ada;
(The question is about the extent of the rule that all top-level packages are children of the package Standard.)
Excuse me for writing nonsense. Such a package’s full name would be Standard.Standard, but I doubt this could be written. (Any library unit’s X full name is Standard.X.)
Since a user defined package Standard is not visible, declaring W should be well defined. (I did not ask the compiler.)
I did. GNAT rejects with Standard.Ada, but accepts rename Standard.Ada.
The argument of with is library_unit_name. The argument of rename is package_name.
My theory is that the name of a library item must be in “canonical” form. The package Standard is a library item without a library item name, yet it has a package name.
ObjectAda rejects with Standard.Ada with
LRM:10.1.2(4), Standard not found in Library, Ignoring With
(the reference is to the Ada-12 ARM). The renaming is fine, of course.
This is covered by 10.1.6 Environment-Level Visibility Rules:
within a nonlimited_with_clause, the only declarations that are visible are those that are explicit library_items of the environment, and the only declarations that are directly visible are those that are explicit root library_items of the environment
and 10.1.1 Compilation Units - Library Units:
The root library units are the children of the predefined library package Standard.