Related articles |
---|
Looking for volunteers for XL christophe@taodyne.com (Christophe de Dinechin) (2011-11-22) |
Re: Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-11-28) |
Re: Looking for volunteers for XL bc@freeuk.com (BartC) (2011-11-28) |
Re: Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-01) |
Re: Looking for volunteers for XL jgk@panix.com (2011-12-13) |
Re: macros, was Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-13) |
Re: macros, was Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-14) |
Re: macros, was Looking for volunteers for XL jgk@panix.com (2011-12-15) |
Re: macros, was Looking for volunteers for XL kaz@kylheku.com (Kaz Kylheku) (2011-12-16) |
From: | Kaz Kylheku <kaz@kylheku.com> |
Newsgroups: | comp.compilers |
Date: | Wed, 14 Dec 2011 19:00:09 +0000 (UTC) |
Organization: | A noiseless patient Spider |
References: | 11-11-048 11-11-061 11-11-064 11-12-002 11-12-017 11-12-018 |
Keywords: | macros, comment |
Posted-Date: | 16 Dec 2011 00:47:33 EST |
On 2011-12-13, Kaz Kylheku <kaz@kylheku.com> wrote:
> Real macros let you do that: make robust languages that make heavy, dense use
> of those macros, not only some syntactic sugar that is to be sprinkled very
> sparingly.
> [Seems to me that what you really want here is in-line functions. Macros are
> useful for other stuff, too. -John]
Inline functions don't always fit the bill.
For instance, try this exercise:
Implement the operator or2(A, B) which does this:
1. A is evaluated. If A is nonzero, then the value of A is returned.
2. Otherwise, B is evaluated and its value is returned.
You cannot write this as an inline function or as a non-kludgy macro in C.
Yet this or2 is not some esoteric macro either: it's a simple operator that
is only a tiny semantic modification to C's || and ?: operators.
Both arguments to the macro are expressions! It doesn't reinterpret their
syntax in any way; it just arranges for their evaluation.
[Yeah, you need inline functions with call by name and reference variables.
Yuck. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.