Naming: Rename imperative verb functions that do not modify an object #12094
psychicteeth
started this conversation in
Engine Core
Replies: 2 comments 9 replies
-
This would break compatibility and couldn't be done in a minor version |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why would it break compatibility? The old functions are still there, deprecated |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Rect2.expand
does not expand theRect2
on which it is called, it returns a copy of the expanded rect.Vector2.normalized
, by comparison, being in the perfect tense, does what you might expect it to - it returns a normalized version of theVector2
.Functions that are named in the imperfect tense (i.e. infinitive without "to") are implicitly imperative and should operate on the object.
In the case of
Rect2.expand
, this should be deprecated and two new functions,expand_to(point: Vector2)
andexpanded_to(point: Vector2)
should be created, withexpand
being deprecated toexpanded_to
. This should be applied to all such functions and become standard naming.Beta Was this translation helpful? Give feedback.
All reactions