Closed arik-so closed 1 year ago
Hm good question, I think another frequent pattern are conversion constructors that follow the rust convention of from_X
. If they are not made constructors, I believe these would currently result in initX
, which should however likely rather be initWithX
?
Done in 4ee29b0dd8a0f4256f16684dd48adbd0284e6226.
Currently, any method within a type that produces the type itself is considered a constructor, provided its name isn't
clone
.Should we restrict that classification and make only methods constructors if their name is
new
?An interesting example is the
Retry
struct, whose sole initializing method is calledattempts
, not new. When it's a constructor, initialization just looks likeRetry(a: 3)
. If it weren't a constructor, it would readRetry.initWithAttempts(a: 3)
.On the other hand, some types like BackgroundProcessor have a constructor whose name is simply
default
and notnew
. Food for thought.