Open michaelficarra opened 11 years ago
:+1:
So one think that I think is odd is that it relies on returning null
to signal that a producer is done. I'd rather see an "official" done
sentinel integrated into Underscore first. It seems like a legitimate addition -- with debate.
I'd rather see an "official" done sentinel
Something like:
_.DONE = new Object();
_.isDone = function (value) { return value === _.DONE; };
???
If so, I wonder whether the exact same scheme should be ported to the trampoline function and to the functional iterators? They currently return undefined
, mostly because I abhor business logic ever passing undefined
around deliberately and it feels a little like working with an array.
If we don't use a sentinel, I urge us to consider returning undefined
instead of null
.
I would definitely want to change the trampoline to use _.DONE
and it makes sense to do so for the iterators too. Good call.
Is there an underscore issue for the _.DONE sentinel? If not, should I open one up over there?
I've never seen one, but DONE is still useful.
A case for it was made in documentcloud/underscore#696, but it was deemed unworthy of core underscore. It seems perfect for underscore-contrib. We can use prelude-ls's implementation (without the auto-currying).