Am Fri, 13 May 2011 18:19:24 +0200 (CEST) schrieb mar...@stack.nl (Marco van de Voort):
> > We often have enumerated types, with arrays of strings or other > > associated information, that must be kept in sync (array dimension > > and content). Macros with parameters would allow to create these > > tightly coupled declarations from a single piece of text, acting as > > a table from which the enum can be created from column 1, a name > > array from column 1 or 2, a list of procedure pointers from column > > 3, etc. > > This is general case for generating source code, not for macros. > > Why? It is not distributed throughout the source. This can be > localized in a single includefile which can be generated easily from > whatever coherent source you have, including a designtime solution in > lazarus that allows you to edit it comfortable in table form. There are two different use cases in the compiler sources: 1. { !! Be sure to keep these in sync with ones in rtl/inc/varianth.inc } varempty = 0; varnull = 1; { keep this in sync with TIntfFlag in rtl/objpas/typinfo.pp } TCompilerIntfFlag = (ifHasGuid,ifDispInterface,ifDispatch,ifHasStrGUID); 2. { possible types for symtable entries } tsymtyp = (abstractsym, staticvarsym,localvarsym,paravarsym,fieldvarsym, SymTypeName : array[tsymtyp] of string[12] = ( 'abstractsym','globalvar','localvar','paravar','fieldvar', { definition contains the informations about a type } tdeftyp = (abstractdef, arraydef,recorddef,pointerdef,orddef, typName : array[tdeftyp] of string[12] = ( 'abstractdef','arraydef','recorddef','pointerdef','orddef', The first are spread over the source and not well solvable by the use of macros. An include will do it better. The second ones and you can believe me there are a planty more of such examples, are easy solveable by macros. Moreover they are not even marked to be kept in sync in the compiler sources. A macro processor is the simplest way to generate such pieces of source code. If it is that simple doing it another way you say, why can I find in the compiler sources more then one example of this. Because of a lack of capability to do it the easy way. Regards Jörg _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel