zubr
zubr copied to clipboard
Core/Array: reset
As discussed, this function needs its parameter to be passed by reference.
What to do, considering that we're trying to avoid that? I think this is a gotcha but we'd have to do by reference.
@nkkollaw I don't see any other option that sticking to the reference
What to do, considering that we're trying to avoid that? I think this is a gotcha but we'd have to do by reference.
The question is more general - should the wrapper function be pure? If so it means that some native functions (like reset()
, key()
, current()
) will be broken "by design".
If the answer is no - I wouldn't bother with passing variables as references.
In this case, the only purpose of the functions is to modify the element passed, so it kind of makes sense.
Implementing without passing by reference wouldn't work IMO.
I would definitely add it to the documentation as a gotcha, but I think we should make ot work like the original.
the only purpose of the functions is to modify the element passed
Its not always the only purpose. For example end
also returns the last element of the array (as well as setting the pointer to the end).
Definitely. I meant that if you take that aspect away, the function doesn't make much sense.