Re: [Fwd: Re: [sv-bc] P1800-2008 draft 4 pg 526]

From: Coffin, Eric <eric_coffin_at_.....>
Date: Tue Mar 04 2008 - 15:55:25 PST
Greg,

If the macro use "`sna(ke+1)" expands to "666 + 69 + 69 + ke+1 + ke+"1 
then the identifier "foo" must be treated inconsistently within the 
macro body.  This expansion implies that within the macro body foo is 
both a macro formal and a name of a macro.  This seems overly complex.  
Moreover, this interpretation would prevent our ability to write macros 
that expand to different macros such as MACRO_1 in this example:

`define MACRO_1(a) `a
`define MACRO_2 two
`define MACRO_3 three

module A;
reg `MACRO_1(MACRO_2);
reg `MACRO_1(MACRO_3);
endmodule

If we treat all occurrences of "foo" within the body of "sna" as a 
formal, we need not worry about the context of an identifier within a 
macro body.  Identifiers within the body of macro are always formals if 
they match the name of a formal.  "666 + 42+1 + 42+1 + ke+1 + ke+1" 
seems logical to me for the expansion of 'sna(ke+1).

-Eric

Greg Jaxon wrote:
> Coffin, Eric wrote:
>
>   
>> Greg,
>>
>> How about another option:
>>
>> d) 666 + 42 + 42 + ke + ke
>>
>> Wouldn't that make more sense if the use of 'foo' and '\foo' were first 
>> substituted with ke and then the body were further expanded?
>>
>> -Eric
>>     
>
> Yes, that's actually what I meant to write for (b), sorry.  It's the next most
> sensible answer once escaped names are made secure.  The power for a macro
> to invoke an actual argument as a macro looks nice in such a small example.
> Expanding `sna(ke+1) as  666 + 42+1 + 42+1 + ke+1 + ke+1  looks less
> appealing than           666 + 69 + 69 + ke+1 + ke+1 .
>
> My related question about the "tokenness" of `identifier also sets up
> the question of whether getting ` and ke together in this example doesn't
> perhaps require token gluing.  If not, then can I:
>
> `     define foo tasking4it
>       always begin `
>          foo( arg1, arg2 );
>       end
>
>       task tasking4it( a, b );
>         ...
>       endtask
>
> ?
>
> Greg
> Greg Jaxon wrote:
>   
>>  `define \foo(3)  666
>>  `define sna(foo) `\foo(3)  + `\foo  + `foo + \foo  + foo
>>  `define foo 69
>>  `define ke 42
>>
>> Does  `sna(ke)  expands to:
>>
>>   a)  666 + 69 + 69 + ke + ke
>>   b)  `\ke(3) + `42 + `42 + 42 + 42       // with errors of course
>>   c)  `\ke(3) + `\ke  + `42 + \ke  + 42   // also errors
>>
>>
>>   
>>     
>
>
>   

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Mar 4 15:55:58 2008

This archive was generated by hypermail 2.1.8 : Tue Mar 04 2008 - 15:56:17 PST