Fix leading qualifiers in use-import prefixes - #717
Conversation
|
Me, realizing I did not request @tshepang and @kirtchev-adacore to review 🙃 |
| @@ -1005,7 +1005,8 @@ Use Imports | |||
| SimplePath Renaming? | |||
|
|
|||
| CommonPathPrefix ::= | |||
There was a problem hiding this comment.
looks like this change is not needed since these mean same thing... SimplePath? means SimplePath is optional
| @@ -1018,35 +1019,28 @@ A :t:`use import` brings :t:`entities <entity>` :t:`in scope` within the | |||
| :t:`use import` resides. | |||
|
|
|||
| :dp:`fls_sxo1jb25pl8a` | |||
There was a problem hiding this comment.
I think we should not consider empty segments as what can be a common path prefix. This makes us adjust text elsewhere without adding clarity. To demo my suggestion, in ::foo::{self, b as foo, c::*}, ::foo is the common path prefix. Also, that is equivalent to ::{foo::{self, b as foo, c::*}} since the outer braces do not add any semantic meaning... they are simply discarded.
Following my suggestion also aligns us more with Reference... its definition of common prefix does not include anything with an empty segment.
|
|
||
| #. :dp:`fls_IPYvldMqduf4` | ||
| Start the :t:`import path prefix` as follows: | ||
| Make the given :t:`use import` the current :t:`use import`, and start the :t:`import path prefix` as follows: |
There was a problem hiding this comment.
This, coupled with "Make the :t:nesting import the current :t:use import.", is not correct, and is confusing.
Syntactically, a "use import" is just use ...; (see the grammar for UseImport). These two rules somewhat imply that the construction of the import path prefix spans across multiple use imports (and I mean multiple items), which is just not true.
| * :dp:`fls_irdKqoYzBM0M` | ||
| If the :t:`use import` is a :t:`nesting import` then start with the | ||
| :t:`[path segment]s` of the :t:`nesting import`'s :t:`common path prefix`. | ||
| If the :t:`nesting import` has a :t:`common path prefix`, prepend the :t:`common path prefix` to the :t:`import path prefix`. If the :t:`common path prefix` contains a :t:`path segment` and the :t:`import path prefix` was not empty, place a :t:`namespace qualifier` ``::`` between them. |
There was a problem hiding this comment.
I see what you are trying to do here, however this is becoming quite confusing. I think we have a higher-level problem with our approach. Perhaps going start-to-end is not the correct approach.
We basically want to identify the prefix that is supposed to resolve to something, and that something depends on the path segments involved, and the use of certain symbols and keywords. For example, in
use aaa::bbb::{self, ccc::*, ddd::{self, eee}};the prefixes of interest are
aaa::bbb::for the subsequentself,cccandddd,aaa::bbb::ccc::for the subsequent*,aaa::bbb::ccc::ddd::for the subsequentselfandeee.
Perhaps the correct approach is to define "import path prefix" in terms of a end-to-start order, relative to some path segment, *, or keyword.
What do you think?
Summary
::glob-import restrictions.Closes #711
Reference alignment