Far, Far prefer this.
itâs fine to have named functions for âalternativeâ/âspecial caseâ/âcomplexâ constructors, but Iâve always found ::new() to be redundant, unnecessary ugliness that stabs me in the eye.
I used tuple-structs for vector maths purely because I dislike the idiomatic Vec3::new(x,y,z) convention. This proposed convention would allow you to move back & forth more easily. This is the kind of pointless refactoring issue weâre trying to escape from C++. âif you reverse this choice later, you have to change calling conventions âŠâ
You can currently write struct Foo{} fn Foo()->Foo{} , and it is unambiguous both at call & definition site, hence still easy to search for. (grep struct Foo{ vs struct Foo( vs fn Foo vs Foo( vs Foo{ )
Donât âThrow out the baby with the bathwaterâ when comparing to C++: C++âs system is difficult because of many combined factors: header files, everything is overloaded, there are hidden conversions, and its hard to distinguish a definition from a use in a single line. Rustsâ lack of headers & simpler grammar (especially introducing types with â:â ) cut through many problems.
box Foo::new() also looks very redundant.
itsâ also repurposing of the word ânewâ compared to other languages which might cause confusion for people creating cross-langauge C wrappers.would people expect extern âCâ Foo_new() to really be a function that allocates and initialises, returning Foo* ? opposite is Foo_delete(Foo*) ? Rust doesnât exist in isolation.
Are there any details in language support, for example does use foo::Bar get all symbols âBarâ from foo (both the struct and the fn,if you make one)