I believe the answer to your question has to be yes, but the LRM does not support that answer. 'this' is not defined in the scope containing the declaration of the method. That rule was created to keep you from doing things like: function void foo(int A=x, int B=A); int x = bar(); endfunction The rules for determining the order of evaluation would be too complex at the very least. However, if you have: class A; int x; function void foo(int x=x); ... endfunction It's semantically clear that the x on the RHS refers to this.x, regardless of what identifier is on the LHS because the RHS is evaluated in the context of the scope containing the declaration of foo, not inside of foo. There is an erratum somewhere here. Dave > -----Original Message----- > From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of > Michael Burns > Sent: Thursday, March 30, 2006 3:53 PM > To: sv-ec@eda.org > Subject: [sv-ec] "this" as default argument > > > Hi folks, > > Is it the intent of the committee that "this" should be a valid default > argument value for class methods? For example, > > class Foo; > ... > > task mytask(Foo f = this); > ... > endtask > endclass > > The 1800 standard seems to suggest this (12.4.3, "The default_value is > an expression. The expression is evaluated in the scope containing the > subroutine declaration each time a call using the default is made"), but > section 7.10 makes it a little less clear ("The this keyword shall only > be used within nonstatic class methods") - does use as a default value > in the method's arg list count as being "within" the method? > > --Mike Burns > Freescale SemiconductorReceived on Thu Mar 30 18:18:25 2006
This archive was generated by hypermail 2.1.8 : Thu Mar 30 2006 - 18:18:43 PST