[sv-bc] Clarification on space stripping for passed arguments in macros

From: Alsop, Thomas R <thomas.r.alsop_at_.....>
Date: Fri Aug 03 2007 - 11:06:03 PDT
Just one clarification in this mantis item.  Can we add an example of
"White space before and after the arguments shall be stripped off"  What
happens for example of I do this:

 

`D(" msg1","msg2 ")

 

Note the white space in the arguments.  

 

Do I get this? 

prints "startmsg1msg2end"

 

Or this?

prints "start msg1msg2 end"

 

This leads to another question about using quotations to pass the
argument.  Do we ever expect anyone to want to actually pass a string
with a space prefix or suffix?  In which case it would be nice to let
them do this by explicitly using quotations and making this "space
stripping" enhancement only apply to non-quoted arguments.  So perhaps
this can be clarified as well.  If I have a macro call like this:

 

`D(msg1,msg2)

 

I assume this is the same as this:

 

`D("msg1","msg2")

 

But what about calls like this:

 

`D( msg1,msg2 )

 

Would this example be equivalent to this?

 

`D(" msg1","msg2 ")

 

Thanks, -Tom

 

 

Mantis 1957

A macro actual argument may be empty

In P1800-2008/D3a. Section 21.5.1, 

CHANGE

To use a macro defined with arguments, the name of the text macro shall
be followed by a list of actual arguments in parentheses, separated by
commas. White space shall be allowed between the text macro name and the
left parenthesis. The number of actual arguments shall match the number
of formal arguments.

TO

To use a macro defined with arguments, the name of the text macro shall
be followed by a list of actual arguments in parentheses, separated by
commas. White space shall be allowed between the text macro name and the
left parenthesis. White space before and after the arguments shall be
stripped off before argument substitution into the macro text. 

 

The number of actual arguments shall match the number of formal
arguments. However,  an actual argument may be empty or white space
only, in which case the formal argument is substituted by nothing.
Commas must still be used to maintain the correct number of arguments.

 

Example:

`define D(x,y) initial $display("start", x , y, "end");

 

`D("msg1","msg2") // prints "startmsg1msg2end"

`D("msg1", )      // prints "startmsg1 end"

`D(,"msg2")       // prints "start msg2end"

`D(,)             // prints "start  end"

`D("msg1")        // illegal, only one argument

`D()              // illegal, only one empty argument

 

 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Aug 3 11:06:39 2007

This archive was generated by hypermail 2.1.8 : Fri Aug 03 2007 - 11:06:50 PDT