Re: [sv-bc] Serious issue with default expressions for task and function arguments

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Thu Mar 03 2005 - 12:48:44 PST
Mark Hartoog wrote:
> In addition to the possibilities mentioned by Gord, you could also outlaw
> the use of non-constant default values on all hierarchical or interface
> function/task calls. You might still have some confusion for the case:
> 
> module A();
> parameter p = 1;
> function int foo(int x = p);
>    return x;
> endfunction
> 
> initial
> begin
>    int p = 2;
>    $display(foo());
> end
> 
> endmodule
> 
> Is this legal? If so, what value is displayed? 


In my version of reality, of course it is legal.  The "p"
in the default value binds to A.p.  The value displayed is "1".
There is no confusion here just as there is no confusion if
you have:

   module A();
   parameter p = 1;
   function int foo;
      return p;
   endfunction

   initial
   begin
      int p = 2;
      $display(foo());
   end
   endmodule


Obviously, one expects "p" in "foo" to be the parameter.  This
is clear and is the case in virtually any language.  Why should
the name binding of a default parameter value be any different?

The arguments over static versus dynamic name binding are decades
old.  Is there something distinct about this context that leads
one to disregard that history?

Gord.
-- 
--------------------------------------------------------------------
Gordon Vreugdenhil,  Staff Engineer               503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
Received on Thu Mar 3 12:48:48 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2005 - 12:48:59 PST