An un-keyed `pop(Table): tuple[K,V]` more similar to `HashSet.pop` is mentioned
in the PR commentary linked above. (I would personally just use the
already-defined iterator than b3liever's inline expansion, but eh. Either way.)
Totally suitable for another PR. I just wanted to keep the above
Lol good point, I shouldn't post here when I had too little sleep.
Why mpop, the caller takes ownership of the result and must assign it or
discard it.
But then we also need `mpop` "for consistency", it never ends...
Well I think a pop proc would look like this instead:
proc pop*[A, B](t: var Table[A, B]): (A, B) =
if len(t) == 0:
raise newException(KeyError, "pop(): dictionary is empty")
for h in countdown(high(t.data), 0):
if isFilled(t.data[h].hcode):
Ok. Just to close the loop on this thread I believe this accommodates all
expressed views:
[https://github.com/nim-lang/Nim/pull/12678](https://github.com/nim-lang/Nim/pull/12678)
(except maybe one week pre-release implies backward compatibility forever view
or the if one-table has a proc, all
As proc name overloading is one of the ways to offer genericity in Nim code,
selecting the right name is important, particularly for data structures that
share similar behaviours. Some languages have symbol renaming or aliasing, like
Eiffel, to handle such cases of semantic similarity.
+1 for
@mratsim \- it's not just you. Formatting looks pretty garbled.
@araq \- sensible to me to duplicate/alias rather than deprecate. Pretty
low-cost.
+1.
Is it me or the apis.rst has a completely broken format on Github?
[https://github.com/nim-lang/Nim/blob/devel/doc/apis.rst](https://github.com/nim-lang/Nim/blob/devel/doc/apis.rst)
+1 for pop.
I don't mind `pop` instead of `take` (though "take" is the better word IMO) but
I'm personally quite tired of "X is inconsistent with Y so let's deprecate X
because nobody ever got tired of applying random changes to existing codebases".
Before we leave things as just `take` in `Table`-land for very long/a full
release cycle and having to worry about backward compatibility, I thought this
warranted a much wider discussion than a comment thread in a closed pull
request:
>
12 matches
Mail list logo