Replies: 1 comment
-
There is a need for a proper entity to represent a type. But I think it should be done at the core level, not gdscript one. Because such representation will be really useful in implementing type parameters for other built-in types. And for arrays it will make it possible to have nested parameter types - |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There is a
GDScriptNativeClass
wrapper available in GDScript, you can obtain it as a first class value (var node_class = Node
), although it is not exposed, which creates some problems.At the same time, there is no such wrapper for built-in types (like
GDScriptBuiltInType
). In particular, this has resulted in theis_instance_of()
function usesTYPE_*
constants to denote a built-in type, andis_instance_of()
does not support typed arrays.I think we should fix this. For example, we can add a
GDScriptType
class (exposed inClassDB
) with API like this:GDScriptType
instances represent a type in GDScript. You can use the name of a built-in type, native type, or GDScript type like in type hints to getGDScriptType
instance:GDScriptType
is similar toGDScriptParser::DataType
, but can represent not only a static type, but also a runtime type. ProbablyGDScriptType
should be treated as a constant, you can't change it or create it dynamically (GDScriptType.new()
).GDScriptNativeClass
will no longer be needed.This will probably require quite a lot of changes and will break backwards compatibility a bit (for those who rely on something like
str(value).begins_with("<GDScriptNativeClass#")
), but I think that this will help us avoid many problems in the future and solve some of the existing ones.Another question we have to solve is how to distinguish the methods of the instance representing the type from the static methods of the type.
Beta Was this translation helpful? Give feedback.
All reactions