FW: [sv-bc] Mantis 1571: Add default values for macro arguments

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Tue Oct 10 2006 - 06:28:43 PDT
  

Resend.

Comments?

Shalom

 

________________________________

From: owner-sv-bc@server.eda.org [mailto:owner-sv-bc@server.eda.org] On
Behalf Of Bresticker, Shalom
Sent: Sunday, September 17, 2006 2:53 PM
To: sv-bc@server.eda-stds.org
Cc: Korchemny, Dmitry
Subject: [sv-bc] Mantis 1571: Add default values for macro arguments

 

This is a draft proposal for Mantis 1571, to add default values for
macro arguments.

The obvious advantage of default values for macro arguments is not
having to specify them, making their usage shorter and more readable.

A second advantage is being able to change the default by a single
change instead of having to change the argument value in every usage of
the macro.

Syntax change:

Change the syntax in Syntax 19-2 in 1364-2005 from 

list_of_formal_arguments ::= 
    formal_argument_identifier { , formal_argument_identifier }

formal_argument_identifier ::= 
    simple_identifier

to 

list_of_formal_arguments ::= 
    formal_argument { , formal_argument }

formal_argument ::= 
    simple_identifier [ = default_value ]

(Note that the default value does not have to be an expression
syntactically. This is noted in Mantis 1333.) 

Add the following text:

A formal macro argument may have a default value. If a default value is
not explicitly specified, then the macro argument is considered to have
a null default value. The default value is substituted for the formal
argument if no corresponding actual argument is specified. If fewer
actual arguments are specified than the number of formal arguments, then
the default values are substituted for the additional formal arguments.
It shall be an error to specify more actual arguments than the number of
formal arguments in the macro.

Examples:

`define MACRO(a=5,b="B",c) $display(  a ,, b ,, c ) ; // c has no
explicit default, implicit null default

`MACRO ( , 2, 3 )  // argument a omitted

`MACRO ( 1 , , 3 ) // argument b omitted

`MACRO ( , 2, ) // arguments a and c omitted

`MACRO ( 1 )  // arguments b and c omitted

`MACRO () // all three arguments omitted

 

Shalom

Shalom Bresticker

Intel Jerusalem LAD DA

+972 2 589-6852

+972 54 721-1033

I don't represent Intel 

 



image001.gif
Received on Tue Oct 10 06:29:31 2006

This archive was generated by hypermail 2.1.8 : Tue Oct 10 2006 - 06:29:40 PDT