I can't support this proposal. A couple of quick concerns/questions: 1) what is the point of argc unless you have compile time loops and conditionals? I know that some people want that as well, but such a change is going to require a complete overhaul of the macro system. 2) I don't particularly like having the indexing operations be indistinguishable from expansion text. I am worried about the implications of when and how one deals with composition, etc. With: `define B [0] Q`B what does Q[0] mean? What if I token-pasted the [0]? etc. 3) If you have: `define F(V...) `G(V) does the "V" expand to multiple arguments to G or is it a single argument including the commas? I have general uneasiness with other interactions that I'd have to think about further before having specifics but at this point I can't support this proposal. I think this needs to wait for the next PAR. Gord. Bresticker, Shalom wrote: > Mantis 1566 is a request to allow a variable number of arguments to > tasks/functions, macros, etc. It is on our list. > > Attached is a proposal for variable number of arguments to macros. > <<1566_D4_macros.V2.htm>> > Thanks, > Shalom > > Shalom Bresticker > Intel Jerusalem LAD DA > +972 2 589-6582 > +972 54 721-1033 > > --------------------------------------------------------------------- > Intel Israel (74) Limited > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies. > > > -- > This message has been scanned for viruses and > dangerous content by *MailScanner* <http://www.mailscanner.info/>, and is > believed to be clean. > ------------------------------------------------------------------------ > > Mantis 1566-macros > > P1800-2008/D4 > > Add variable number arguments to text macros > > The proposal is based on Mantis 1571 > > In Section 21.5.1 > > CHANGE > > Change the syntax in Syntax 21-2 from (FROM MANTIS 1571) > > list_of_formal_arguments ::= > formal_argument { , formal_argument } > formal_argument ::= > simple_identifier [ *=* default_text ] > > TO > > list_of_formal_arguments ::= > formal_argument { , formal_argument } [ , last_format_argument ] > formal_argument ::= > simple_identifier [ = default_text ] > last_format_argument ::= > simple_identifier ... [ = default_text ] > > > CHANGE (TEXT FROM MANTIS 1571) > > > > If formal arguments are used, the list of formal argument names shall be > enclosed in parentheses following > > the name of the macro. The formal argument names shall be > /simple_identifiers/, separated by commas and > > optionally whitespace. The left parenthesis shall follow the text macro > name immediately, with no space in between. > > > > A formal macro argument may have a default. A default is specified by > appending an = token after the formal argument name, followed by the > default text. The default text is substituted for the formal argument if > no corresponding actual argument is specified. > > The default text may be explicitly specified to be empty by adding an = > token after the formal argument name, followed by a comma (or a right > parenthesis if it is the last argument in the argument list.) > > > TO > > > > If formal arguments are used, the list of formal argument names shall be > enclosed in parentheses following > > the name of the macro. The formal argument names shall be > /simple_identifiers/, separated by commas and > > optionally whitespace. The left parenthesis shall follow the text macro > name immediately, with no space in between. > > > A formal macro argument may have a default. A default is specified by > appending an = token after the formal argument name, followed by the > default text. The default text is substituted for the formal argument if > no corresponding actual argument is specified. > > The default text may be explicitly specified to be empty by adding an = > token after the formal argument name, followed by a comma (or a right > parenthesis if it is the last argument in the argument list.) > > The last argument in the list of formal argument names may be followed > by an ellipsis (...) and is then called a /multiple argument/. In that > case, a list of actual arguments, separated by commas, may be specified > in the argument list in the text macro call. The list of actual > arguments, including the commas, shall be subsituted for the formal > multiple argument in the macro text. A default may be specified for a > formal multiple argument as well, after the ellipsis. Such a default may > itself be a multiple argument list. > > Within the scope of the macro text, the predefined macro `__ARGC__ > designates the number of arguments specified in the multiple argument > list (or of the default if the default was used). A particular member of > the multiple argument list may be specified by appending a simple > non-negative integer constant index within square brackets to the > multiple argument list name. The arguments in the multiple argument list > are numbered from 0 to `__ARGC__ -1 . It shall be an error to specify a > number beyond the end of the list. > > > > CHANGE > > > > It shall be an error to specify more actual arguments than the number of > formal arguments. (FROM Mantis 1571) > > TO > > It shall be an error to specify more actual arguments than the number of > formal arguments unless the last formal argument is a multiple argument. > > > > > > CHANGE (TEXT FROM Mantis 1571) > > > > Example without defaults: > > > > ... > > > > Example with defaults: > > ... > > TO (ADD NEW EXAMPLES AFTER OTHER EXAMPLES) > > Example without defaults: > > > > ... > > > > `define MUTEX(name, V...) name: assert($onehot0{V}) > > `MUTEX (one_driver, a,b,c); > > // expands to "one_driver: assert($onehot0{a,b,c}); > > > > `define HEAD(Q...) Q[0] > > `HEAD(3,1,4,15) // evaluates to 3 > > Example with defaults: > > `define MUTEX(name, V...=a,b) name: assert($onehot0{V}) > > `MUTEX (one_driver); > > // expands to "one_driver: assert($onehot0{a,b}); > > > -- -------------------------------------------------------------------- Gordon Vreugdenhil 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Mon Dec 17 08:07:14 2007
This archive was generated by hypermail 2.1.8 : Mon Dec 17 2007 - 08:07:23 PST