Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!unido!iaoobelix!wagner From: wagner@iaoobelix.UUCP Newsgroups: comp.lang.c Subject: Re: Re: A Deficiency of the C Preprocess - (nf) Message-ID: <6700003@iaoobelix.UUCP> Date: Sat, 27-Dec-86 06:50:00 EST Article-I.D.: iaoobeli.6700003 Posted: Sat Dec 27 06:50:00 1986 Date-Received: Sun, 28-Dec-86 02:38:23 EST References: <484@csun.UUCP> Lines: 43 Nf-ID: #R:csun:-48400:iaoobelix:6700003:000:2228 Nf-From: iaoobelix!wagner Dec 27 12:50:00 1986 /***** iaoobelix:comp.lang.c / csun!aeusemrs / 1:54 am Dec 23, 1986*/ Subject: Re: A Deficiency of the C Preprocessor > Clayton, if you are running Unix System V, all of your problems > are solved; there is another preprocessor called 'm4' that will > do what you want, and then some. (This might also be true of other systems.) ... > Mike Stump Sure, you can use M4 to get these repetitions. Yet, it is impos- sible to use iterative or (essentially) recursive macro expan- sions for a C program preprocessor. The best idea would be to write a small LISP or PROLOG program to parse your C code and to build up a syntactic structure (lists or trees) what shouln't be too sophisticated. Then, use full LISP or PROLOG for the manipu- lation of your programs and generate from the resulting struc- tures a new C program. Of course, you can write source code op- timizers, lint-like programs, bug finders and a lot of other nice programs in such an environment... But: The main intention of the C preprocessor is not to provide a full programming language for macro rewrites as you can find it e.g. in LISP. Cpp (and also M4) is a small (!), useful instrument for simple 1:1 substitutions not requiring any recursion or iteration, since source code EXPANSIONS (i.e. transformations en- larging the amount of code by an unknown factor) of the kind men- tioned in the original note do not necessarily improve a program's efficiency by producting a huge block of constant data. A small loop WILL consume some run-time but if the initializer is so large that a simple iteration over all the elements will amount to more than half a second, you won't do this initializa- tion by means of source code expansion anyway! BTW: Even if cpp supported constant time repetitions, this does NOT require knowledge about data structures since it is just a textual replacement ( gets replaced by ... ). And if you are going to implement this kind of iteration, please use a syntax like DUP(n, form) or DUP(n, form, delim). Juergen Wagner, (USENET) ...!unido!iaoobel!wagner wagner@iaoobel.UUCP Fraunhofer Institute IAO, Stuttgart