lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Niccolo Medici <niccolomedici@gmail.com> wrote:

> On 1/25/15, Paige DePol <lual@serfnet.org> wrote:
>> Niccolo Medici <niccolomedici@gmail.com> wrote:
>> 
>>> lauxlib.h has:
>>> 
>>> #define luaL_optstring(L,n,d)  (luaL_optlstring(L, (n), (d), NULL))
>>> #define luaL_typename(L,i)     lua_typename(L, lua_type(L,(i)))
>>> 
>>> Why are there "(n)" / "(d)" / "(i)" instead of "n" / "d" / "i"? There
>>> are commas around these letters so there shouldn't be a potential
>>> precedence problem there, or am I wrong?
> [...]
>> I can explain this best with a simple example:
>> 
>> #define ackoop(a)  a * 20
>> 
>> ackoop(5 + 7)
>> 
>> This would expand to:
>> 
>> 5 + 7 * 20
> 
> Yes, I know about *that*. But the macros I'm talking about look like
> function calls. A comma (,) has the lowest precedence in C. So why do
> we need the parentheses? Let me modify your example:

Sorry, it was late and I was just heading to bed, I missed the part of your original post that mentioned the macro parameter were separated by commas... I thought you were just asking a general question about bracketed macro parameters! ;)

~pmd