top | item 46215559

(no title)

bvrmn | 2 months ago

From typing perspective there is no sense to have Container[T].join() -> str for any T.

discuss

order

still_grokking|2 months ago

That's obviously the wrong signature.

The semantically correct one is "Container[T : Printable].join(): String"; T must implement the Printable concept, but Python lacks concepts (or type-classes as these are alternatively called).

But this all is irrelevant as this is anyway not the signature of `str.join()` in Python. It's `str.join(Iterable[str]) -> str` there. With sane design and syntax it would just become `Iterable[str].join(str)`.

mystifyingpoi|2 months ago

I agree, but from convenience perspective there is a lot of sense. Java Streams is actually a good example of a "correct" design, but not very convenient.

bvrmn|2 months ago

That's my point. Python has convenient and good type design with str.join ignored by other languages.

For example I'm lost which abstract class to inherit in Scala to obtain mkString for my custom container.