home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,897 of 33,346   
   Dave Abrahams to All   
   Re: Are MACROS good and can the compiler   
   08 Feb 12 23:27:07   
   
   From: dave@boostpro.com   
      
   on Mon Feb 06 2012, "Andre Kaufmann"  wrote:   
      
   > "Dave Abrahams"  wrote in news:m2wr9m93o8.fsf@pluto.luannocracy.com...   
   >   
   >>[...]   
   >   
   >>Macros, like any useful language feature, are neither good nor bad.   
   >   
   > Perhaps macros would be part of the language   
   > and not of the preprocessor   
      
   The preprocessor is part of the language, technically speaking.   
      
   > they wouldn't be that evil. At least I think there are more downsides   
   > regarding macros than advantages.   
      
   Maybe.  The general tradeoff doesn't really matter, because they're part   
   of the language.  There are some things you can only do reasonably with   
   macros.  If the question is, "should I use macros," the answer has to be   
   "sometimes."   
      
   >>> I also found that automatic code generation can often be a better   
   >>> alternative to complicated macros.   
   >>   
   >> [...] My experience writing Boost.Python led me to the opposite   
   >> conclusion. I   
   >   
   >>1. Before the change, my users couldn't figure out how to run the   
   >      [...]   
   >   
   > You solved this problem by using macros, but perhaps there might have   
   > been another solution to make it easier for users to tweak and execute   
   > the code generator.   
      
   Maybe, that's pure speculation.   
      
   > But generally I agree - for a library writer it's perhaps easier to   
   > ship macros / templates than code generators.   
      
   Perhaps.  But my point wasn't about what's easier for me.  It's about   
   what serves my users well.   
      
   >>2. The scripts were actually harder to maintain than the   
   >   
   > Yes, that's true. But I think it depends on how the code is   
   > generated. If it's mainly data (enumerations, constants etc. small   
   > helper functions) and not code it's easier to maintain such code with   
   > code generation than macros or templates (IMHO).   
      
   Maybe.   
      
   >> Nobody should put macros in the "global namespace" in header files.   
   >   
   > Agreed - but sometimes "generated" code must be used in header files   
   > too, which would imply to use macros in header files too if macros are   
   > used instead of code generation.   
      
   Yes, macros generally must appear in header files; just not in the   
   "global macro namespace," i.e. they should use sufficiently unique   
   prefixes.   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca