Hi, Tom. ________________________________ From: owner-sv-bc@server.eda.org [mailto:owner-sv-bc@server.eda.org] On Behalf Of Alsop, Thomas R Sent: Friday, August 03, 2007 9:06 PM To: sv-bc@server.eda.org Subject: [sv-bc] Clarification on space stripping for passed arguments in macros Just one clarification in this mantis item. Can we add an example of "White space before and after the arguments shall be stripped off" [SB] OK, I will alter at least one of the examples to show this. I thought I had done so, but maybe I forgot. 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" [SB] The second, because the arguments are the string literals, each of which is a single token. 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") [SB] No, it is not, because the second passes the quotation marks as well. Changing this would break back-compatibility. But what about calls like this: `D( msg1,msg2 ) Would this example be equivalent to this? `D(" msg1","msg2 ") [SB] No, for the same reason. Regards, Shalom 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 <http://www.mailscanner.info/> , and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Sat Aug 4 13:24:53 2007
This archive was generated by hypermail 2.1.8 : Sat Aug 04 2007 - 13:25:24 PDT