HaxeFoundation / haxe-evolution

Repository for maintaining proposal for changes to the Haxe programming language
111 stars 58 forks source link

Replace "null" access modifier with "this" #64

Closed posxposy closed 4 years ago

posxposy commented 5 years ago

It's a bit confusing to use null as a private access modifier. this is much more understandable and gives as a context about who can modify the current field.

Example:

public var data(default, this):Bool;

Rendered version

Thanks!

ncannasse commented 5 years ago

We could go for this, as long as null is still accepted and does not generate a deprecation warning. We could replace null by this in official documentation (and still state that null is no longer the spec, although accepted for backward compatibility)

kLabz commented 5 years ago

Why this over private or protected?

posxposy commented 5 years ago

Why this over private or protected?

private in Haxe may be confusing because private field can be modified by child classes. While null access means "truly private" when only the owner can modify that field.

protected in other world is mean the same what private in Haxe do, so it is may be confusing too :)

nadako commented 5 years ago

private in Haxe may be confusing because private field can be modified by child classes. While null access means "truly private" when only the owner can modify that field.

I don't think that's true. But @ncannasse had some other argument against private. Something about mixing visibility and access modifiers.

posxposy commented 5 years ago

I don't think that's true.

Oh damn :D

Simn commented 5 years ago

I'm against making such small changes to property syntax. It already is a mess and allowing more keywords only makes it even more of a mess. I also don't find this more intuitive than null, so in both cases it's a matter of remembering the right keyword.

I would leave the current property syntax alone and focus on introducing an entirely different alternative akin to C#.

Simn commented 5 years ago

... which I just noticed is also being suggested in #63.

Simn commented 4 years ago

This has been rejected by votes from @ncannasse, @nadako, @RealyUniqueName, @jdonaldson and @simn for the reasons previously stated.

63 is unaffected by this decision.