Hacker News new | ask | show | jobs
by merb 1986 days ago
> C# to add loads and loads of syntactic sugar

well some is necessary. example: init-only-Setter, was impossible to do before. You could not write the same Code, without it. No matter what you did.

using declarations where also necessary to increase readability.

and nullable reference types also were important!

1 comments

You could use an explicit private readonly field and a property getter, or even just a public readonly field. I would argue its only sugar.
Are you referring to the init only setters?

If so, it isn’t just sugar, they added a new hook for it in the internals, rather than just relabelling a technique to accomplish a similar (but not equal) end.

It doesn't scale that well, as you need ctor parameters for every property, so API additions may also be breaking changes.
well that would be different to instantiate tough. it would be Class(1, 2, 3) instead of Class { Value1=1, Value2=2, Value3=3, }

actually record types are more syntactic sugar around what you said than initonly, which opens up a new way of writing code