HaxeFoundation / HaxeFoundation/haxe
`default get` / `default set` for properties
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
While we might add https://github.com/HaxeFoundation/haxe-evolution/pull/96 in 5.0 (?), current property syntax could be enhanced with a new modifier which would be equivalent to `public var propertyWithField:T { get; set; }`:
```haxe
public var propertyWithField(default get, default set):T;
```
This would be equivalent to:
```haxe
@:isVar
public var propertyWithField(get, set):T;
function get_propertyWithField():T return propertyWithField;
function set_propertyWithField(val:T):T return propertyWithField = val;
```
Which allows child classes to override getter/setter.
---
Also while we're at it, maybe `init` like [in C#](https://learn.microsoft.com/en-us/dotnet/csharp/properties#init-only) would be a nice addition now that we have `final` fields with similar behavior :thinking:
Contributor guide
Research direction
Start by reviewing the current property syntax and haxe-evolution pull request #96, which the issue references. Done means defining and implementing the proposed `default get` and `default set` behavior, with a decision on whether C#-style `init` belongs in the same change.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100