Re: Is it ok to use "zero-but-true"?
On Thu, 20 Jan 2005 [EMAIL PROTECTED] wrote: DT::Set count() currently returns "undef" on error, and "0" for empty sets. Should it return "zero-but-true" (0e0) for empty sets? No, this is just confusing. What do you mean by "on error"? Do you mean when a set is possibly infinite, and therefore uncountable? In thise case undef is right, because the value truly is unknown. If it's an actual input error, it should throw an exception. -dave /*=== VegGuide.Orgwww.BookIRead.com Your guide to all that's veg. My book blog ===*/
Re: Is it ok to use "zero-but-true"?
On 2005-01-20 [EMAIL PROTECTED] wrote: >DT::Set count() currently returns "undef" on error, and "0" for empty >sets. >Should it return "zero-but-true" (0e0) for empty sets? I use 0e0 (or '0 but true') in lots of cases where an empty set is a valid return value, where zero is a valid index, and where zero is a valid input datum not the same as that datum being "empty", all cases where truth tests alone aren't sufficient to distinguish a real zero from '', undef, etc. But I've wondered: is zbt one of those charming Perlisms that, for all its utility, might fall by the wayside or be shown to harbor potential for serious errors? >Such that you could write: > $count = $set->count or die "can't count"; >instead of: > $count = $set->count; die "can't count" unless defined $count; I say this is an improvement, pending enlightenment on the above question. As always, Flavio, thanks for your good work. - Bruce __bruce__van_allen__santa_cruz__ca__
Is it ok to use "zero-but-true"?
DT::Set count() currently returns "undef" on error, and "0" for empty sets. Should it return "zero-but-true" (0e0) for empty sets? Such that you could write: $count = $set->count or die "can't count"; instead of: $count = $set->count; die "can't count" unless defined $count; - Flavio S. Glock -- DT::Set POD --- =item * count Returns a count of C objects in the set. .. when C operates on large recurrence sets, it will return at most approximately C<200>. For larger sets, and for I sets, C will return C. Please note that this is explicitly not a scalar zero, since a zero count is a valid return value for empty sets! .. -
Re: Bug: DT::Event::Recurrence Modifies Params
Yitzchak wrote: > > YMMV, but I find something like this more clear: > > @args = sort { ($a < 0) <=> ($b < 0) || $a <=> $b } @args; > > (literally, sort first by positive/negative, then by value). > Very nice - thanks! Actually, I'm planning to rewrite this part of the program, because it can't handle overflow cases like this one: monthly ( days => [ 30, -20 ] ) - Flavio S. Glock