core icon indicating copy to clipboard operation
core copied to clipboard

inconsistent naming: `Array::length` and `Array::rev`

Open lijunchen opened this issue 1 year ago • 6 comments

The current API design of the Array type is inconsistent in its method naming conventions. It provides both a length and a rev method. For better consistency and clarity, the naming should be standardized to use either:

  • len and rev - following a shorter, more succinct naming convention.
  • length and reverse - using more descriptive, complete names.

lijunchen avatar Sep 11 '24 02:09 lijunchen

As well as Map.size(), which is neither len nor length

qazxcdswe123 avatar Sep 11 '24 09:09 qazxcdswe123

@qazxcdswe123 shall we all call it len and deprecate the old API?

bobzhang avatar Sep 13 '24 03:09 bobzhang

I second len, but I think as long as the naming is consistent, it wouldn't matter too much.

glyh avatar Sep 13 '24 03:09 glyh

@qazxcdswe123 shall we all call it len and deprecate the old API?

image

According to grep, most of the current API use length so maybe just stick with length?


image

And we also have lots of size

qazxcdswe123 avatar Sep 13 '24 06:09 qazxcdswe123

also need to consider rev_each, rev_eachi etc.

lijunchen avatar Sep 13 '24 06:09 lijunchen

Update: we now decide to

  • unify to len (for length and size), aligning with Rust, and
  • keep length for the time being and deprecate size as size has fewer occurences (only for map and set). We will provide migration tool for length in the future

peter-jerry-ye avatar Apr 18 '25 07:04 peter-jerry-ye