Support for String multiplication by number to repeat string?

For clarity, I personally don’t like the last two much either.

  • I do actually use the large integers that way occasionally, but I would much rather have it be served by a proper integer literal, which is probably what the distant future holds.
  • When I work with bytes, I usually prefer 0x41 over A anyway.

Instead, I bring the issue up early because this sort of overloading with differing semantics has halted proposals in their tracks before. (See the SE‐0243 review for example.) You deserve to know how contentious such proposals can be and how much effort you would likely need to invest to actually carry it through to completion.

I should also clarify that it is more of a concern about the confusion caused for developers than it is what the compiler’s type checker is capable of when you make your types explicit.

If you do continue with the proposal, it would be worth considering whether it actually belongs on RangeReplaceableCollection instead of String, since that is the abstraction level the algorithm operates at.

1 Like