(j3.2006) Component etc. names

Malcolm Cohen malcolm
Tue Apr 24 22:04:57 EDT 2012




TL;DR - scoping is covered by the scoping rules 16.3.1, and answers all of these 
"questions".  C514 has nothing to do with any of these questions.




Van Snyder claimed:
>C514 says no entity declared within a type definition shall have the
>same name as another entity declared within the same type definition.

No, that is not what C514 says.  It says ***NOTHING*** about "declared in"!!!!!

>I cannot find a constraint that says a type parameter, data component,
>or procedure component declared in a type extension shall not have the
>same name as an entity in its parent type, or the same name as its
>parent type.  C514 doesn't cover this because an extension type is a
>different scoping unit from its parent.

C514 does not cover multiple entities in the same scoping unit either.  That is 
the job of the scoping rules!

Let's actually read C514 shall we:

"C514 ***An entity*** shall not be explicitly given an attribute more than once 
in a scoping unit."
(emphasis mine)

So only in the case where we have *one entity* does C514 come into play.  So you 
cannot declare the type of a type parameter twice for example.  In no way does 
it prohibit having a type parameter with the same name as a component with the 
same name as a type-bound procedure; these prohibitions are done by the scoping 
rules, in particular 16.3.1p3.

>I cannot find a constraint that a procedure binding in a type extension
>shall not have the same name as a type parameter, data component, or
>procedure component of its parent type, or the same name as its parent
>type.  C514 doesn't cover this either, for the same reason.

No, it doesn't cover it in any case as explained above.  16.3.1p3 is the scoping 
rule that prohibits multiple entities with the same name.

>Is the <final-procedure-stmt> a declaration of an entity?

Yes, it declares several "entities"; it implicitly declares that a module 
procedure exists with the identifier of <final-subroutine-name> and it 
explicitly declares a final procedure binding to that module procedure (note 
this entity does not have any identifier).

>  Does C514
>prohibit a <binding-name> in a <type-bound-proc-binding> to be the same
>as a <final-subroutine-name>?

A <final-subroutine-name> is the name of a module procedure in the same module 
(this is explicitly stated).  Go look at the scoping rules - you will see that 
final procedures do not appear in the list.

>Can I have
>
>  type :: T
>  contains
>    procedure :: Final
>    final :: Final
>  end type T
...
>Apparently, neither one is possible.  C456 requires the passed-object
>dummy argument to be polymorphic, while C480 requires the argument of a
>final subroutine NOT to be polymorphic.

C456 does not even require there to BE a passed-object dummy argument.  If there 
is none, there is no requirement on it.

>How about
...
>Does C514 prohibit either one of these?

Obviously not.  I don't know why someone would be reading C514 when they want to 
know the scope of an identifier.

Cheers,
-- 
................................Malcolm Cohen, Nihon NAG, Tokyo. 




More information about the J3 mailing list