Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!nerds-end From: Kaz Kylheku Newsgroups: comp.compilers Subject: Re: macros, was Looking for volunteers for XL Date: Wed, 14 Dec 2011 19:00:09 +0000 (UTC) Organization: A noiseless patient Spider Lines: 25 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <11-12-022@comp.compilers> References: <11-11-048@comp.compilers> <11-11-061@comp.compilers> <11-11-064@comp.compilers> <11-12-002@comp.compilers> <11-12-017@comp.compilers> <11-12-018@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1324014453 18579 64.57.183.58 (16 Dec 2011 05:47:33 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 16 Dec 2011 05:47:33 +0000 (UTC) Keywords: macros, comment Posted-Date: 16 Dec 2011 00:47:33 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: x330-a1.tempe.blueboxinc.net comp.compilers:394 On 2011-12-13, Kaz Kylheku 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]