[sv-ec] initializing class properties

From: danielm <danielm_at_.....>
Date: Fri Jan 18 2008 - 06:59:36 PST
I haven't found an explicit LRM saying if class properties can be
initialized but LRM uses examples like:
class A ;

integer j = 5;

endclass

Is it allowed  somwhere in LRM or this is just a mistake?
 
IMHO allowing such code is problematic. Other mature languages like ie C++
do not allowed such initialization. In fact 'j' is dynamic doesn't exist at
the moment when it is initialized - because of that the contructor is proper
place for variable initializations. 'j is created when object is created by
constructor. Initialization is a reason why the constructor was introduced
into the language.
 
Allowing class properties to be initialized iallows not only such simple
examples as above but also more complicated cases where we initialize non
existing variable with other non existing  varialbe:
class A ;

    int i = 5;

    int j = i;

    A a = this;

endclass

 

All above is not neat coding sample - why LRM does not explicitly forbids
such codes.
 
DANiel

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Jan 18 12:56:34 2008

This archive was generated by hypermail 2.1.8 : Fri Jan 18 2008 - 12:57:03 PST