Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.std.c Subject: Re: conditional macro definition also for recursive conditionally limited expansion Date: Mon, 17 Jan 2022 07:51:06 -0800 Organization: A noiseless patient Spider Lines: 25 Message-ID: <86v8yis6mt.fsf@linuxsc.com> References: <723aa6f8-0994-4b1d-b2d2-59abe33906ban@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="15598caebf32ebbe97649a2f881af1fe"; logging-data="22856"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HktywKUu/h92qC8u1MU1AEHFR77ZdFzQ=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:yy50nbNO2MZTxvBy13uEdgtT08Q= sha1:RGK44nQsHHCg7j2KJderz+GgVlc= Xref: csiph.com comp.std.c:6423 Marco Munari writes: > I thought it could be nice to introduce condition inside macro > definition, to produce less jumping code (so compiler can output > bigger but more efficient code with concise definition) > > a syntax could be defined by adding an optional #defif (due to the > late time this could be introduced to C, that would be my preference > reminding to who would learn by seeing it that the if is part of the > macro definition) as > #define macro(#N,x) #defif (#N>0) macro(#N-1,?) #defelse ? > > usable with macro(5,x) > expansion parameter that i called #N need to be a constant provided > to the expansion engine, the # prefix I indicated here is not a > syntax necessity because it can be deduced by the fact that this > parameters appears in the #defif condition which also must be fully > valuable during preprocessing (just a bit more powerful > preprocessing) [...] It's an interesting idea. There are details that need to be explored and understood first. Also I think it would be better if expanded and generalized, perhaps along the lines of 'cond' in lisp, or alternatively with ?# :# as preprocessing if/else. Hmmm...