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 33,002 of 33,346   
   DeMarcus to All   
   Re: What does null mean?   
   25 Apr 13 16:36:37   
   
   From: demarcus_at_hotmail_com@tellus.orb.dotsrc.org   
      
   >> But when you really must have a pointer in the constructor it's much   
   >> easier and explicit to read:   
   >> CameraMan cm( ANGLE_MISSING );   
   >   
   > One possibly better choice here would be to provide a default ctor for   
   > the cases where the angle is missing, like   
   >   
   > CameraMan cm;   
   >   
   > Of course this requires that the missing angle is not a variable that   
   > may have nullptr as value, but this is not part of the use cases you   
   > describe.   
   >   
      
   Yes it is a possibility to have a constructor that skips the angle   
   parameter, but in cases where it's very unusual that the angle is   
   missing, an explicit notification would make the programmer much more   
   observant on that fact.   
      
   > Or provide a function that decides what to do in such a case   
   >   
   > CameraMan cm( GetDefaultAngle() );   
   >   
   >   
      
   This also solves the problem I'm trying to solve, I just suggested the   
   symbolic constant for the efficiency.   
      
   > My general point is that in cases where the meaning of nullptr when used   
   > as that isn't obvious, chances are that it's being abused as a special   
   > value -- and I don't like special values in general, not just with   
   > pointers. (For example, imagine an interface where an integer argument   
   > can have meaningful positive values and the negative values -1, -2 and   
   > -3 are 'overloaded' to trigger special behavior. Shudder.)   
   >   
      
   I completely agree. That's actually another investigation I'm working on   
   how to solve that situation in a clean way. First time I realized the   
   complexity of it was at a time when I had to store measured values.   
   Except from a decimal value I also needed to store whether it had been   
   measured at all (0.0 is not a good value to store when the value is   
   missing), if the signal of the measure was too weak to be within   
   operational range, and (after some statistics calculations) if the   
   measure was an outlier.   
      
      
   Best regards,   
   Daniel   
      
      
   --   
         [ 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