Open igotfr opened 3 years ago
In the Savi compiler I have adopted this approach, with the small change that it uses the @
prefix to designate the concept of this.
(everywhere it appears - not just in this particular feature).
:class Point
:var x F64
:var y F64
:new create(@x, @y)
So I endorse the "Alternative 1" approach above :+1:,
though I'd also like to make the this.
syntax be less verbose (probably in a separate RFC so as not to bog this one down in that controversy).
I'm not a fan of "Alternative 2" because it would make it more difficult to find the full list of the type's fields - especially if there are multiple constructors involved and not all of the fields appear as parameters in every constructor's signature.
Kotlin and Scala are additional examples which have adopted a feature like this, specifically closer to alternative 2 (and for Kotlin there is the primary constructor mechanism which makes this the norm and follows the presented constructor version)
Alternative 1, like Dart:
Alternative 2, like Python, Typescript