zubr icon indicating copy to clipboard operation
zubr copied to clipboard

Core/Array: reset

Open nkkollaw opened this issue 6 years ago • 6 comments

nkkollaw avatar Aug 02 '17 17:08 nkkollaw

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 avatar Aug 07 '17 00:08 nkkollaw

@nkkollaw I don't see any other option that sticking to the reference

ddziaduch avatar Aug 07 '17 06:08 ddziaduch

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.

radmen avatar Aug 16 '17 19:08 radmen

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.

nkkollaw avatar Aug 16 '17 20:08 nkkollaw

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).

Petah avatar Aug 16 '17 22:08 Petah

Definitely. I meant that if you take that aspect away, the function doesn't make much sense.

nkkollaw avatar Aug 16 '17 23:08 nkkollaw