Closed blake-regalia closed 3 years ago
Not every callback function can be replaced with a match
. Using the methods in the right way is important. And, yes, all of the mentioned methods can be replaced with iterable<Quad>
, but we designed the DatasetCore
interface to have the bare minimum to build other stuff on top. The Dataset
interface should have convenient methods for functional programming. Here a simple example that would be way more complex using only iterable<Quad>
:
function greaterThan (value) {
return q => parseFloat(q.object.value) > value
}
if (dataset.match(subject, property).some(greaterThan(10)) {
}
I see your concerns, but removing methods that are useful in the proper context is not the solution. Having a primer document would be the better option.
I do believe that using iterables over callbacks provides much more flexibility in general, especially when the callback return types are void or boolean. I only wondered about trying to simplify the interface, but if these methods are useful to some then I'm happy to keep them.
I would suggest we remove these methods and instead promote the use of
iterable<Quad>
whenever possible. I also believe that Arrays are one dimensional and iterating a dataset one quad at a time has limited practicality. Quad datasets may have internal indexes that provide much better/faster means of testing for the presence of a triple, for example in the case ofsome
.I also wonder about
map
andreduce
; but let's see where this discussion goes.