On Tuesday, 9 April 2013 at 16:36:09 UTC, Andrei Alexandrescu wrote:
On 4/9/13 12:27 PM, deadalnix wrote:
On Tuesday, 9 April 2013 at 16:22:08 UTC, Andrei Alexandrescu wrote:
How do you address construction of immutable objects?


In general, the first assignement of a field in a constructor must be
handled as a declaration, not as an assignement. It solve
const/immutable construction issues as well as avoiding unecessary
copy/destruction as Ali pointed in a recent post.

The magic only happens in the constructor, so it can still be considered
as a regular function seen from the outside.

Right. This part I agree with. All I'm saying is that constructors are typechecked differently from other functions, so they must be distinguished somehow. Probably we're in violent agreement, or if not: are you suggesting a change?


Constructor used to create lvalues, and so behave differently. I'm not sure what is the expected behavior at the end, but I think indeed that we envision the same thing here.

BTW, what do you mean by different typechecking rules ? How is it different than the code snippet posted above ?

Reply via email to