Replies: 5 comments 17 replies
-
One thing I've thought a lot about for the trait system is the naming convention for traits. To fit the English-like readability of the rest of GDScript, I propose PascalCase adjectives. For example, a trait that allows a node to be interacted with could be called if some_node is Shootable:
some_node.on_shot() # on_shot() is a method on the Shootable trait I know C# uses the if some_node is TShootable:
some_node.on_shot() This looks a bit weirder to me personally, though, so I think I'd prefer the first option. Of course, if anyone has other ideas, please express those as well! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I see there are no VM changes in godotengine/godot#107227. Is the goal for it to be a runtime feature, or like Python's |
Beta Was this translation helpful? Give feedback.
-
I was thinking of unifying them all under a single word class_name CustomClass
has CustomTraits1, CustomTraits2
if CustomClass has CustomTraits1: # don't mix `is` with classes?
pass Or perhaps, the original class_name CustomClass
uses CustomTraits1, CustomTraits2
if CustomClass uses CustomTraits1:
pass |
Beta Was this translation helpful? Give feedback.
-
With the current implementation of traits, is it possible to statically type/type check for traits ? var foo : Movable if foo uses Movable:
foo.move() Also if yes, would the second example enable autocompletion for Movable properties and methods like the following would ? if foo is MyClass:
foo.method_of_myclass() #this will be autocompleted in the editor |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Here you can discuss various aspects of the trait system. Please use separate branches for different topics:
implements
vsuses
, traits vs interfaces, etc.Beta Was this translation helpful? Give feedback.
All reactions