VHDL Issue Number: 2122 Language_Version VHDL-2002 Classification Language Modeling Enhancement or Deficiency Summary Protected method has implied object parameter? Relevant_LRM_Sections 3.5.1 Protected type declarations 2.4.2 Signatures Related_Issues Key_Words_and_Phrases protected type method signature overload resolution Authors_Name James Unterburger Authors_Phone_Number 503-685-0860 Authors_Fax_Number Authors_Email_Address jamesu@model.com Authors_Affiliation Mentor Graphics Authors_Address1 8005 SW Boeckman Rd. Authors_Address2 Wilsonville, OR 97070 Authors_Address3 Current Status: Submitted Superseded By: ------------------------ Date Submitted: 7 September 2007 Date Analyzed: 8 October 2007 Author of Analysis: Peter Ashenden Revision Number: 1 Date Last Revised: 8 October 2007 Description of Problem ---------------------- In discussing methods, the text states "In addition to the (implied) object of the protected type operated on by the subprogram, additional parameters may be explicitly specified in the formal parameter list of the subprogram declaration of the subprogram". The word "additional" suggests that the protected type object to be operated on is somehow an implied formal to the subprogram. Also, the fact that nested protected types are legal suggests that there are actually N implied objects being operated on where N is the nesting level of where the method is. Do the implied objects/formals come into play for overloaded subprogram resolution? Do their (protected) type names appear in the signature of the subprogram? In the following example, which "foo" is called when elaborating the "v2" object? package pkg is function foo(x : string := "PKG") return string; type prot is protected function foo(x : string := "PROT") return string; end protected; end; package body pkg is type prot is protected body constant v : string(1 to 5) := "Hello"; function foo(x : string := "PROT") return string is begin return v & x; end; variable v2 : string(1 to 5) := foo; variable ccc : string(1 to 10) := foo'path_name; end protected body; function foo(x : string := "PKG") return string is begin return "PKG " & x; end; end; Proposed Resolution ------------------- VASG-ISAC Analysis & Rationale ------------------------------ The submitter is makes a reasonable interpretation of the text of 3.5.1 as implying that the object of the protected type is a parameter of a method. However, that is not the intention. The object of the protected type is accessible to the subprogram by virtue of being the enclosing declarative region in the elaborated design hierarchy. In other words, the object is part of the closure of the subprogram. There is no need to treat the object as an implicit parameter. The text in 3.5.1 should be amended to avoid the interpretation made by the submitter. Given that an object of a protected type is not to be considered as a parameter of the protected type's methods, the protected type does not occur in the parameter type profiles of the methods, nor does it appear in a matching signature for any of the methods. Only the explicitly listed parameter types occur in the parameter type profile and signature for a method. If the text of 3.5.1 is amended to avoid mention of implicit parameters, there is no need to amend the text of 2.3 or 2.3.2. In the submitter's example, the function foo declared immediately within the package and the function foo declared as a method of the protected type are homographs. Hence, within the scope of the method, the function declared in the package is hidden. That includes the declaration of v2, so the method foo is called when elaborating v2. VASG-ISAC Recommendation for IEEE Std 1076-2002 ----------------------------------------------- Interpret the second sentence in the second paragraph of page 51 in 3.5.1 as though the text "(implied)" and "additional" were deleted. VASG-ISAC Recommendation for Future Revisions --------------------------------------------- In the second paragraph of page 51 in 3.5.1, delete the text "(implied)" and "additional", so that the sentence reads: In addition to the object of the protected type operated on by the subprogram, parameters may be explicitly specified in the formal parameter list of the subprogram declaration of the subprogram.