godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

Document GDScript "when" and clarify pattern guard docs

Open tetrapod00 opened this issue 1 year ago • 1 comments

Fixes https://github.com/godotengine/godot-docs/issues/9786.

Adds an entry for "when" to the table, which links to "match".


As for potential confusion about "pattern guards" vs "guard expressions":

  • In the docs, both phrases only appear on this page.
  • The engine itself has some errors that mention a "pattern guard" with an "expression". The phrase "guard expression" does not appear anywhere in engine error messages.
  • The class reference never mentions "guard expressions" or "pattern guards".

So my impression is that you can create a match statement with a "pattern guard" which has an "expression". And you might call that expression a "guard expression", as the current docs section does. But these seem to be terms that are only implicitly defined in a one place in user-facing content, or perhaps terms from another language that are borrowed directly.

I changed the section header from "Pattern guards" to "Pattern guard expressions" so it can be found with ctrl+f both ways. Not too attached to that change.


I mainly use C#, so a review from a GDScript expert would be appreciated.

tetrapod00 avatar Aug 20 '24 00:08 tetrapod00

As a new-ish Godot user, I agree that a single term should be used consistently in the documentation. Prevents confusion in us new-comers.

MajorGonzo avatar Aug 22 '24 19:08 MajorGonzo

Thanks, merged. And thanks dalexeev for reviewing :)

mhilbrunner avatar Aug 29 '24 19:08 mhilbrunner

Cherry-picked to 4.3 in https://github.com/godotengine/godot-docs/pull/10038.

mhilbrunner avatar Oct 04 '24 02:10 mhilbrunner