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

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Sun Sep 17 2006 - 04:53:28 PDT
  

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 Sun Sep 17 04:55:34 2006

This archive was generated by hypermail 2.1.8 : Sun Sep 17 2006 - 04:56:00 PDT