On 2011-11-15, BartC <> wrote:
> "Kaz Kylheku" <> wrote in message
> news:...
>> On 2011-11-15, BartC <> wrote:
>
>>> I just happen to think that #if 0 is a ugly way of doing this (with a few
>>> problems of it's own), while nested comments is an elegant way.
>>
>> I showed several times how a simple macro can do it this way within
>> one line:
>>
>> #define IGN(...) /* C99 variadic */
>>
>> some_function(10, 20, IGN(30, ) );
>>
>> Nests and everything:
>>
>> IGN( IGN ( ... ) IGN ( IGN ( ... ) ) )
>
> I didn't believe it, but it seems to work...
Why didn't you believe it? I often test stuff before posting!
>> balanced parentheses. I could live with that.
>
> I called mine COM() (why IGN?), and it means comments can be written like
> this:
Because, sigh, it's not commenting! It's for ignoring program tokens.
IGN comes from the Common Lisp habit: #+IGN expr causes expr to be
ignored, assuming the symbol :IGN is not in the platform *features* list.
I've never seen Lisp's #+ or #- used for commenting; that is ridiculous.
(Lisp people: don't shoot me, I know this kludge is frowned upon by some,
and I don't use it myself, but rather #+(and) expr.)
> But, both have similar problems in that either ( and ), or /* and */, must
> be balanced, so from that point of view, what would be the difference?
> Of course, nested COM() (or whatever it might be called) exists now, and
> nested /**/ doesn't. But the argument against nested /**/ *was* that stray
> /* or */ sequences would trip it up, in the same way that extra ( or ) might
> cause a problem in the macro.
The differences is that the stuff inside IGN(...) is preprocessor tokens, not
an arbitrary comment. It syntactically has to be a valid macro call! So it is
not messed up by the following:
IGN( char lparen = '('; )
On the other and it is messed up by this:
if (!x)
foo(); IGN(Don't foo if x is true!)
Do you still want to call it COM?