fusionlanguage / fut

Fusion programming language. Transpiling to C, C++, C#, D, Java, JavaScript, Python, Swift, TypeScript and OpenCL C.
https://fusion-lang.org
GNU General Public License v3.0
1.75k stars 55 forks source link

syntactic sugar for getters/setters #159

Open iAndyHD3 opened 4 months ago

iAndyHD3 commented 4 months ago

since public fields are not allowed, this means one is forced to write setters and getters for every single member. Doing so is a lot of work, especially with structures with many fields.

Suggestion: syntactig sugar for getters/setters, perhaps something similar to c#?

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
}
pfusik commented 4 months ago

What do you mean by "a lot of work" ? If it's a few dozen fields, it's a one-time investment of a few minutes.

I consider introducing C#-style properties to Fusion. The goal is not to reduce how much you type, but ability to emit code that feels natural to the target language. And especially for C# you'd want properties.