GDScript: Disallow strings as comments - #121833
Conversation
|
I would love this, but let me tell you right off the bat: this is most definitely going to be controversial and indeed it warrants a proposal, with the same sentiments brought up here. If it were just up to me, I would still accept this and gather public feedback, personally. "Nowadays", because using them may make even less sense with the general improvements made to the editor:
|
|
Alright I opened a proposal about it: godotengine/godot-proposals#15279 Putting in draft for the time being. |
896c3dd to
285a65c
Compare
|
I'm not seeing any pushback on the proposal, so I'd say this is ready for review. |
Ivorforce
left a comment
There was a problem hiding this comment.
I approve of the change - standalone strings have no use-case for us and we should lean in to comments for documentation. Implementation wise I think this is the perfect way to handle it: Backwards compat kept but adding warnings.
Code looks good to me.
285a65c to
4e73889
Compare
|
Thanks! |
What problem(s) does this PR solve?
Additional information
GDScript does allow string literals as multiline comments to some extends. E.g. they are excepted in a top level context, in contrast to other literals.
This was introduced for 4.x with #72971. I think it made sense at the time, since it was in 3.x.
However it did surprise me that this was an (supposedly) intended thing, because:
All of this might be case for documentation. tl;dr However as outlined in #112523 the comment stripping that is offered by binary tokenization does not apply to string literals, so encouraging users to do this is a footgun. As such I think we should phase out this feature during 4.x.
In a scope context there is simply no good way to tell apart a user error and a "multi-line comment". And I'd rather warn users than keep an undocumented feature.
Note
I don't know how controversial this is. So if necessary I can open a proposal about it.