I had the following comments on Dave's latest proposal for mantis 1308. 1. Overriding a virtual method Page 1, 1st paragraph, 3rd sentence: I still don't like this sentence. Both Gordon and I have previously suggested different ways to phrase this section. I have tried to refine my previous suggestion a bit more and now suggest the following. From: "A virtual method shall override a method in all of its base (parent) classes, whereas a non-virtual method shall only override a method in that class and its descendants." To: "The implementation of a virtual method shall override any implementations of that same virtual method that were made within any of its parent class whenever an object of that subclass is accessed through a handle to the defining subclass or a handle to any of its base classes. The implementation of a non-virtual method may only override that method within the subclass in which it is defined and shall not affect its parent classes." 2. Typos - Example on page 1 From: $display("A is ",A); To: $display("A is %d",A); From: endfuncion : printA To: endfunction : printA From: $display("B is ",B); To: $display("B is %d",B); From: endfuntcion : printB To: endfunction : printB From: endclass : BasePacket To: endclass : My_Packet 3. Example on page 1 It would be best to rework this example to make it a bit more clear what happens when a virtual method is overridden. The way that it is currently shown, there is no change in behavior between the two implementations. It is good to show how the values of A and B are displayed but there should also be some different behavior exhibited by the methods in the BasePacket and My_Packet classes. The example in section 7.13 shows one way to have an overridden method exhibit a difference in behavior (i.e. one negates the value returned and the other doesn't). Below I show a way to modify the calls to $display() to make the example more clear. From: class BasePacket; int A = 1; int B = 2; function void printA; $display("A is %d",A); endfunction : printA virtual function void printB; $display("B is %d",B); endfunction : printB endclass : BasePacket class My_Packet extends BasePacket; int A = 3; int B = 4; function void printA; $display("A is %d",A); endfunction : printA virtual function void printB; $display("B is %d",B); endfunction : printB endclass : My_Packet To: class BasePacket; int A = 1; int B = 2; function void printA; $display("A is %d",A); endfunction : printA virtual function void printB; $display("B is %d",B); endfunction : printB endclass : BasePacket class My_Packet extends BasePacket; int A = 3; int B = 4; function void printA; $display("MyPacket::A is %d",A); <---- changed here endfunction : printA virtual function void printB; $display("My_Packet::B is %d",B); <---- changed here endfunction : printB endclass : My_Packet 4. Results from example on page 1 This example uses an overridden property. This makes the example interesting (possibly more interesting than what Dave intended). Sub-clause 7.13 describes overridden members. 3rd paragraph: LinkedPacket lp = new; Packet p = lp; In this case, references to p access the methods and class properties of the Packet class. So, for example, if class properties and methods in LinkedPacket are overridden, these overridden members referred to through p get the original members in the packet class. From p, new and all overridden members in LinkedPacket are now hidden. If all of that is true then what is the correct value for the line marked below? For this case a virtual method was redefined in a subclass and a property was also overridden by that same subclass definition. If we now access that overridden property through a handle to the base class using the virtual method, which value of that overridden property should be used? We need to be explicit about what should be returned in this case and not just rely on an example to define the desired semantics. What is shown below appears to be in contradiction with 7.13. BasePacket p1 = new; My_Packet p2 = new; initial begin p1.printA; // displays 'A is 1' p1.printB; // displays 'B is 2' p1 = p2; p1.printA; // displays 'A is 1' p1.printB; // displays 'B is 4' <----- is this correct? p2.printA; // displays 'A is 3' p2.printB; // displays 'B is 4' 5. Typos page 2 From: In the that To: In that From: having a method body.. To: having a method body. 6. Sub-clause 7.20 The version of the LRM that I am looking at has this as 7.19. I don't understand why you have changed it to 7.20 7. Typos page 3 From: as show below To: as shown below 8. Sub-clause 7.13 This may be beyond the scope of this mantis item, but since we are looking at this section of the document, I would like to add a couple of lines to the example in this section. The existing example remains the same, just add two extra statements to the end. From: LinkedPacket lp = new; Packet p = lp; j = p.i; // j=1, not 2 j = p.get(); // j=1, not -1 or -2 To: LinkedPacket lp = new; Packet p = lp; j = p.i; // j=1, not 2 j = p.get(); // j=1, not -1 or -2 j = lp.i; // j=2 <---- added this j = lp.get(); // j=-2 <---- added this Neil Rich, Dave wrote On 03/02/06 18:57,: > New proposal has been uploaded to mantis 1308 to reflect changes to > “pure virtual” syntax and to match C++ as stated below. > > > -- --------------------------------------------------------------------- Neil Korpusik Tel: 408-720-4852 Senior Staff Engineer Fax: 408-720-4850 Frontend Technologies - ASICs & Processors (FTAP) Sun Microsystems email: neil.korpusik@sun.com ---------------------------------------------------------------------Received on Fri Mar 3 18:47:01 2006
This archive was generated by hypermail 2.1.8 : Fri Mar 03 2006 - 18:48:27 PST