> Flavio S. Glock wrote:
> > * iterate
[...]
> > # assign a timezone to the spanset
> > $set->iterate( \&callback );
[...]
> >
> > If the callback returns undef, the span is
> > removed from the set.
Andrew Pimlott wrote:
[...]
> One, it's too easy for someone who only skims
> the documentation to miss it, and end up with a
> very subtle bug. Two, lots of functions return
> undef, so people are going to end up with ugly
> code like
>
> $set->iterate( sub { myfunc($_); 1 } );
The result would be: $set = [ 1 ]
because that's the _only_ returned value.
Accepting 'undef' in a map operation is ok,
but a Set cannot contain 'undef' !
A Set can either be empty, or contain valid
DateTimes/spans.
So we only have two options if we get an undef:
to die, or to discard the value.
> just to avoid the effect. I think if you want to
> be able to modify the set, you should provide
> different methods for that. ->map and ->grep
> come to mind.
People are already confused with lists vs. sets.
I think using map and grep would lead them to
think sets _are_ lists.
> I notice that this method with the same undef
> semantics already exists in Set, however it is
> marked experimental, so perhaps it can still
> change.
Yes.
- Flavio S. Glock