in reply to Re^3: undef==defined sometimes? (body question)
in thread undef==defined sometimes?
The function was *supposed* to return a list and only returned undef as an error condition (which wasn't the same as returning an empty list). The undef was reserved for 'illegal operations', like an attempt to compare two strings where one string was undefined. Otherwise, if nothing was found, but no error occurred, it returned a list of size 0 ("()").
If I didn't explicitly return a value, wouldn't the results of whatever the last calculation be returned, essentially returning "left-overs" by accident? I'd rather return 'undef' and have consistently wrong behavior rather than random behavior -- at least if it is consistently wrong, I'm more likely to notice a problem. :-)
-l
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: undef==defined sometimes? (body question)
by ikegami (Patriarch) on May 03, 2008 at 11:29 UTC |