[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Load_tmpl() minimal clean-up patch.


Greg Marr wrote
> At 08:41 AM 4/9/2004, Emanuele Zeppieri wrote:
> >3.
> >In the boolean expression:
> >
> >$extra_params[$x] eq 'path' and
> >ref $extra_params[$x+1]     and
> >ref $extra_params[$x+1] eq 'ARRAY'
> >
> >the 2nd predicate is /implied/ by the 3rd, so it's unnecessary and can
> >be removed (redundancy often decrease legibility, it does not 
> >increase it.)
> 
> I'm not 100% sure, but I'd say it's not as much implied as it is a 
> prerequisite.  Before you check to see if what is returned by ref is 
> 'ARRAY', you make sure that ref really returns something first.  I 
> don't know if it's even possible, but if ref returns undef, then 
> you'll get a warning about using an uninitialized value when you 
> compare it to 'ARRAY'.

90% of the time this would be the case, but ref actually returns the null
string if it isn't a reference. This would not be equivalent to undef and
would the make the 2nd test redundant. Although, in the majority of cases you
do need to check whether a sub/operator/etc returns something that is defined
before you test it. I hate it when I get about 100 'using an uninitialized
value' in my error logs.

Michael Peters
Venzia

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.