From: Nick C. <ni...@cl...> - 2003-01-25 16:34:05
|
On Fri, Jan 24, 2003 at 08:16:11PM -0500, Wizard wrote: > > I would have thought it would be better to have a single method that > > returns 1 if it's true or 0 if it's false. > > Yeah, you're probably right. I just kinda like code that looks like: > if( $cfg->is_false( 'Threading' ) ) {... > > rather than: > if( !$cfg->state( 'Threading' ) ) { ... I was thinking more of: unless ( $cfg->is_true( 'Threading' ) ) {... > > It seems more readable. I really didn't think about it being a problem if it > failed to match either, but that's because I was writing it ;-). How about > is_true and I'll check inverse values? i.e., > return undef if !/^[Yy]|[Tt]|[Oo]n|[1]/ > and !/^[Nn]|[Ff]|[Oo]ff|[0]/; > That way the application can choose to die or offer alternative execution > paths. Yes, that would work, since undef is false. > The other option being as you stated, dying inside the module. I > never really liked that though, because it limits what the programmer can do > without editing the module. The programmer can trap the die with an eval, but I was thinking of configuration values that must be either true or false. For instance, if the config file says: Threading=onion and it's supposed to be true/false/yes/no then dieing with some sort of helpful error message might be better than either treating it as true or treating it as false. Just a thought. -- Nick |