So, let me see if I understand your interpretation. The rule, as I understand you, boils down to: A call using default argument values is legal iff a macro substitution of the default expression has identical bindings to the bindings of the default expression in the context of the task or function declaration. If that is the contention, then (a) the wording is terrible, and (b) this seems like a overly restrictive and error prone restriction. Any incidental declarations could cause an otherwise valid function call to end up being invalid (consider packages, etc, etc). Why not either (i) restrict defaults to constant expressions as most languages do, or (ii) remove the restriction and define the default as being computed in the scope of the function's definition. For (ii), it could then be up to the compiler to determine if a "macro" like default substitution is valid or whether some other calling convention is required. In any case, you end up with more predictable semantics and no surprising errors. Gord. Mark Hartoog wrote: >>In this case there is no p1 visible at the point of compilation >>of function f. Is this legal? Is SV adopting dynamic scoping? :-) > > > The LRM says "The elements of the expression must be visible at the scope > of subroutine". In your example, 'p1' would be an unresolved identifier > in the scope of the subroutine, so this would be illegal. > > I think part of the confusion here is what the term "elements of the > expression" means. When you have an expression like 'p1', I think the > element of the expression is the object that the identifier 'p1' resolves > to in that scope. Other people seem to think that the element of > the expression is simply the identifier itself. Perhaps this needs to > be reworded to make clear what was meant. > > >>-----Original Message----- >>From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org]On Behalf Of Paul >>Graham >>Sent: Thursday, March 03, 2005 10:24 AM >>To: gordonv@model.com >>Cc: ieee1800@eda.org; sv-bc@eda.org >>Subject: Re: [sv-bc] Serious issue with default expressions for task and >>function arguments >> >> >> >>> The default_value is an expression. The expression is evaluated in >>> the scope of the caller each time the subroutine is called. The >>> elements of the expression must be visible at the scope of subroutine >> >>Here's another example: >> >>function f(integer x = p1); >> return x; >>endfunction >> >>module m1(...); >> parameter p1 = 1; >> assign q = f(); // q == 1 >>endmodule >> >>module m1(...); >> parameter p1 = 2; >> assign q = f(); // q == 2 >>endmodule >> >>In this case there is no p1 visible at the point of compilation >>of function f. Is this legal? Is SV adopting dynamic scoping? :-) >> >>Paul -- -------------------------------------------------------------------- Gordon Vreugdenhil, Staff Engineer 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.comReceived on Thu Mar 3 10:52:16 2005
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2005 - 10:52:24 PST