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 32,718 of 33,346   
   goran.pusic@googlemail.com to Peter Schneider   
   Re: Singletons   
   11 Dec 12 05:31:06   
   
   On Thursday, December 6, 2012 8:04:48 AM UTC+1, Peter Schneider wrote:   
   > Hi,   
   >   
   >   
   >   
   > On 04.12.2012 12:40, g.............@googlemail.com wrote:   
   >   
   >   
   >   
   > > There is no such thing as "global state",   
   >   
   > > except in simplest of programs.   
   >   
   >   
   >   
   > A bold statement. Can you briefly elaborate? I'd say   
   >   
   > that almost *all* C++ programs have global state:   
      
   Yeah, that was intentionally bold ;-).   
      
   It looks like you and I have a different definition of a "global state".   
   This discussion is about singletons, and (no surprise there) it had led to   
   global variables. And those make me shudder, and you, too, I think ;-).   
      
   How about this: yes, there is global state, however, a given point in code   
   is using only a part of it. My argument is: we should pass that part into   
   said code; when we have "global" variables, code invariantly gets lazy and   
   uses part of the state from parameters, and a part from globals. That   
   results in messier than necessary situations.   
      
   Goran.   
      
      
   --   
         [ 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