RE: [sv-ec] virtual methods with static lifetime

From: Rich, Dave <Dave_Rich_at_.....>
Date: Fri Apr 04 2008 - 01:06:31 PDT
Mantis 2035 already requests to deprecate all class methods with static
lifetimes, but there is no ambiguity here. You have created three static
class properties: B::f.i, C1::f.i, and C2::f.i, and only method calls
are virtual, Once the method has been chosen, normal name resolution
rules apply to select the class property.

 

So the results are as you suggest - not because i appears virtual, but
because disp is virtual.

 

Dave

 

 

________________________________

From: owner-sv-ec@server.eda.org [mailto:owner-sv-ec@server.eda.org] On
Behalf Of danielm
Sent: Friday, April 04, 2008 12:45 AM
To: sv-ec@server.eda.org
Subject: [sv-ec] virtual methods with static lifetime

 

LRM doesn't say a word about virtual methods with static lifetime
consider the below example:

 

module top;
        class B;
                virtual function   static void f(input int i);
                endfunction
        endclass

 

        class C1 extends B;
                function  static void f(input int i);
                endfunction
                function   void disp();
                        $display(f.i);
                endfunction

 

        endclass

 

        class C2 extends B;
                function   static void f(input int i);
                endfunction
                function   void disp();
                        $display(f.i);
                endfunction
        endclass

 

        C1 c1=new;
        C2 c2=new;
        B b;
        initial begin
                b=c1;
                b.f(1);//1 should be assigned to static input variable i
from C1 - polymorphyzm for variables????
                c1.disp(); //it should display 1????
                b=c2;                

                b.f(2); //1 should be assigned to static input variable
i from C2 - polymorphyzm for variables????
                c2.disp();//it should display 2????
        end
endmodule

 

This case introduce completely new feature - which we may call virtual
static variables. 

It is allowed on purpose - or IEEE just forget to forbid explicitly that
methods with static lifetime cannot be virtual.

 

(NOTE: please note that static virtual methods are explicitly forbidden
by LRM, and dynamic methods with static lifetime are different)

 

 

DANiel


-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is

believed to be clean. 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Apr 4 01:10:41 2008

This archive was generated by hypermail 2.1.8 : Fri Apr 04 2008 - 01:13:04 PDT