Godot-proposals: Allow implicit property typing with new properties

Created on 23 Nov 2020  路  6Comments  路  Source: godotengine/godot-proposals

Describe the project you are working on:
NetworkTest

Describe the problem or limitation you are having in your project:
Nothing but looking at the godot 4 properties makes me want to commit sudoku

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
currently I like the new properties the only issue with them is we have to do this..
var property: set(value): return value #<-value?

I suggest for a optional implicit value keyword when (value) is not supplied with autocompleate

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

#valid
var _property 
`var property:
    set(value): _property= value
    get: return _property
#also valid
var _property 
var property:
    set: _property = value
    get: return _property

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Its less typing so it would probably be used more then the current version and no

Is there a reason why this should be core and not an add-on in the asset library?:
properties are used quite often and having to type (value) for every one is an extra 7 characters and is honestly ugly in my opinion

gdscript

Most helpful comment

properties are used quite often and having to type (value) for every one is an extra 7 characters and is honestly ugly in my opinion

"Ugly" is subjective. Code is read more times than it's written so in general I prefer to improve readability even if you have to type a bit more.

All 6 comments

properties are used quite often and having to type (value) for every one is an extra 7 characters and is honestly ugly in my opinion

"Ugly" is subjective. Code is read more times than it's written so in general I prefer to improve readability even if you have to type a bit more.

Doesn't set(v): _property = v work? It's shorter.

@vnen Thats why the value keyword would be highlighted in that case

@KoBeWi
I mean it is shorter but I still think it looks ugly.
It misaligns the setter and getter which triggers my OCD really bad

Also if lambdas ever get added it would look more natural.

var _property 
var property:
    set: => _property=value
    get: => _property

opposed to

var _property 
var property:
    set(value): =>_property=value
    get: =>_property

It more of a preference issue and I think it should be optional

Godot and GDScript are explicit by design, I'm against this proposal.

Giving a name to the parameter is good. Whether you think it's ugly is not relevant, you have hundreds of functions with named parameters too and they don't seem to be a problem.

Also see #844 and the number of thumbs down on this comment in particular which gives a pretty good idea that people voted against this. So is there any point in repeating the discussion, knowing it would meet the same conclusion?

Why is having the option a bad thing?
It would be completely optional

Was this page helpful?
0 / 5 - 0 ratings