¿©·¯ºÐÀÌ Áñ°Ü »ç¿ëÇÏ´Â ¾î¼Àºí·¯¿¡¼ Áö¿øÇÏ´Â ¸ÅÅ©·Î°¡ ¹«¾ùÀ̵ç, ¿©·¯ºÐÀÌ ÁÖ·Î »ç¿ëÇÏ´Â ¾ð¾î°¡ ¹«¾ùÀ̵çÁö°£¿¡ (½ÉÁöÀÇ C ÀÏ °æ¿ì¿¡µµ) ±× ¾ð¾î°¡ ¿©·¯ºÐÀÌ »ý°¢Çϱ⿡ ÃæºÐÈ÷ expressive(¸ðµç °ÍÀ» Ç¥ÇöÇÒ ¼ö ÀÖ´Â) ÇÏÁö ¾Ê´Ù¸é, ¿©·¯ºÐÀº ¿©·¯ºÐÀÇ ¼Ò½º ÆÄÀÏÀ» ¿ÜºÎÀÇ ÇÊÅ͸¦ Åë°úÇØ¼ Àç»ý¼º(?)µÇ°Ô ÇÒ ¼ö ÀÖÀ¸¸ç, Makefile ¿¡¼ ´ÙÀ½¿¡ º¸¿©Áö´Â °Í°ú °°Àº °£´ÜÇÑ ±ÔÄ¢¸¸ Ãß°¡ ÇÔÀ¸·Î¼ ±×·¸°Ô ÇÒ ¼ö ÀÖ´Ù.
%.s: %.S other_dependencies $(FILTER) $(FILTER_OPTIONS) < $< > $@ |
CPP ´Â ½ÇÀº ±×¸® Ç¥ÇöÀûÀÌÁö ¸øÇÏ´Ù(is truly not very expressive), ÇÏÁö¸¸, °£´ÜÇÑ ÀÏÀ» Çϱâ À§Çؼ´Â CPP ·Îµµ ÃæºÐÇÏ´Ù. CPP ´Â Ç¥ÁØÀ̸ç, GCC ¿¡ ÀÇÇØ¼ Åõ¸íÇÏ°Ô È£ÃâµÇ¾îÁø´Ù.
CPP ÀÇ ÇѰ迡 ´ëÇÑ ¿¹¸¦ µéÀÚ¸é, ¿©·¯ºÐÀº ¿©·¯ºÐÀÇ °´Ã¼°¡ ¼±¾ðµÇ¾î¼, »ç¿ëÇÒ ¶§, ±× °´Ã¼°¡ À¯È¿ÇÑ ºÎºÐÀÇ ¸¶Áö¸·¿¡ ÀÚµ¿À¸·Î ¼Ò¸êÀÚ(destructor) °¡ È£ÃâµÇ°Ô ÇÏ´Â ±â´ÉÀ» ±¸ÇöÇÒ ¼ö´Â ¾ø´Ù.
As an example of its limitations, you can't declare objects so that destructors are automatically called at the end of the declaring block; you don't have diversions or scoping, etc.
CPP ´Â ´ëºÎºÐÀÇ C ÄÄÆÄÀÏ·¯ ÆÐŰÁöµé¿¡ Æ÷ÇԵǾî ÀÖ´Ù. ±×·¯³ª, Ưº°È÷ ¶Ù¾î³ª°Å³ª ÇÏÁöµµ ¾Ê´Ù.
M4 ´Â ¿©·¯ºÐ¿¡°Ô ¸Å¿ì ÈǸ¢Çϰí, °·ÂÇÑ ¸ÅÅ©·Î ÇÁ·Î¼¼½Ì µµ±¸°¡ µÇ¾î ÁÙ °ÍÀÌ´Ù. °Ô´Ù°¡ Turing °ú °°Àº ¾ð¾î¸¦ Áö¿øÇϰí, Àç±Í, Á¤±Ô Ç¥Çö½Ä µîµµ Áö¿øÇÑ´Ù. ¿©·¯ºÐÀº CPP ·Î ÇÏÁö ¸øÇß´ø ¸ðµç °ÍÀ» M4 ¸¦ °¡Áö°í ÇÒ ¼ö ÀÖ°Ô µÉ °ÍÀÌ´Ù.
M4 gives you the full power of macroprocessing, with a Turing equivalent language, recursion, regular expressions, etc. You can do with it everything that CPP cannot.
m4 ¸¦ »ç¿ëÇÑ ¸ÅÅ©·Î ÇÁ·Î±×·¡¹ÖÀÇ ¿¹Á¦¸¦ ±¸Çϱ⸦ ¿øÇÑ´Ù¸é, macro4th (this4th - ftp://ftp.forth.org/pub/Forth/Compilers/native/unix/this4th.tar.gz) ³ª the Tunes 0.0.0.25 sources(ftp://ftp.tunes.org/pub/tunes/obsolete/dist/tunes.0.0.0/tunes.0.0.0.25.src.zip) À» ÂüÁ¶Çϱ⠹ٶõ´Ù.
±×·¯³ª, However, its disfunctional quoting and unquoting semantics force you to use explicit continuation-passing tail-recursive macro style if you want to do advanced macro programming (which is remindful of TeX -- BTW, has anyone tried to use TeX as a macroprocessor for anything else than typesetting ?). This is NOT worse than CPP that does not allow quoting and recursion anyway.
±¸ÇØ¾ß ÇÒ M4 ÀÇ ¹öÁ¯Àº GNU m4 1.4 ȤÀº ±× ÀÌ»óÀÇ ¹öÁ¯ÀÌ´Ù. °¡Àå ¸¹Àº ±â´É°ú °¡Àå ÀûÀº ¹ö±× ȤÀº Á¦ÇÑÀ» °¡Áö°í ÀÖ´Â ¹öÁ¯À̱⠶§¹®ÀÌ´Ù. m4 ´Â ¼È°èµÉ ¶§, °£ÆíÇÑ »ç¿ëÀ» ¸ñÀûÀ¸·Î ¼³°èµÇ°í, ºü¸¥ ¼Óµµ¸¦ ¸ñÇ¥·Î ÇØ¼ ¼³°èµÇÁö ¾Ê¾Ò±â ¶§¹®¿¡, ¹«¾ùÀ» ÇϵçÁö Á».. ´À¸®´Ù. ±×·¯³ª, ¾î¼Àºí¸® ÇÁ·Î±×·¥À» ¸¸µé¶§¿¡´Â º° ¹®Á¦°¡ µÇÁö ¾Ê´Â´Ù. ¾î¼Àºí¸®·Î ¸î¹é¸¸ ¶óÀÎÀ̳ª µÇ´Â ¾çÀ» ÄÚµùÇÒ °ÍÀΰ¡? ±×·¸Áö ¾Ê´Ù.
¿©·¯ºÐÀº perl À̳ª awk, sed µîÀ» °¡Áö°íµµ ¿©·¯ºÐ ÀÚ½ÅÀÇ °£´ÜÇÑ ¸ÅÅ©·Î È®Àå ÇÊÅ͸¦ ¸¸µé ¼ö ÀÖ´Ù. ¿ÀÈ÷·Á °£´ÜÇÑ °ÍÀº ÀÌ·¯ÇÑ ÅøÀ» °¡Áö°í ¸¸µå´Â °ÍÀÌ ´õ ³ªÀ»Áöµµ ¸ð¸¥´Ù. ±×·¯³ª. ¸ÅÅ©·Î ÇÁ·Î¼¼½ÌÀ̶õ ¸»Àº "the hard way(Á» ´õ Èûµç ¹æ¹ý?)" ¶ó´Â ´µ¾Ó½º¸¦ dz±ä´Ù. You can write your own simple macro-expansion filter with the usual tools: perl, awk, sed, etc. It can be made rather quickly, and you control everything. But, of course, power in macroprocessing implies "the hard way".