Closed Mercerenies closed 1 year ago
This issue seems to be localized to names which double as built-in primitive type names. For the purposes of this issue, we shall focus on the following type names. If more pseudo-constructor objects are found, we will discuss them in another issue.
Null
, Bool
, Int
, Float
, String
, Vector2
, Rect2
, Vector3
, Transform2D
, Plane
, Quat
, AABB
, Basis
, Transform
, Color
, NodePath
, RID
, Object
, Dictionary
, Array
, PoolByteArray
, PoolIntArray
, PoolRealArray
, PoolStringArray
, PoolVector2Array
, PoolVector3Array
, PoolColorArray
I've split these into two categories. For those which only have a constructor, we will simply provide the corresponding constructor function as a function. GDLisp is a Lisp-2, so that sort of overloading is perfectly acceptable. For the ones that need constants, we'll make a subclass for the PrimitiveType
instance for those types which defines the appropriate constants. See the notes at the bottom for the special cases.
Constructor Only
NodePath
Bool
Int
Float
String
(See notes)Rect2
AABB
RID
Dictionary
(See notes)Array
PoolColorArray
PoolByteArray
PoolIntArray
PoolRealArray
PoolStringArray
PoolVector2Array
PoolVector3Array
Constructor and Constants
Vector2
Vector3
Transform2D
Plane
Quat
Basis
Transform
Color
Miscellaneous
Null
(See notes)Object
(See notes)Special Notes:
Null
- This object does not have a runtime presence outside of its TYPE_NIL
constant. No constructor, constants, or static functions, so I don't believe we need to take any action at all here.String
- We need to look into the difference between String
(the constructor) and str
(the built-in function). I'll likely provide both, for consistency with GDScript, but I may make a recommendation to avoid one or the other.Dictionary
- There seems to be a constructor that's not documented anywhere. It takes one argument and seems to be a shallow copy of an existing dictionary.Object
- I will be opening a follow-up issue for further discussion on this one.9e1af16 takes care of all of the constructor-only calls. For now, we compile String
to literally String
. I recommend using str
, as it's strictly more general (and vararg, for some reason), but I support both.
See #106 for the Object-specific issue.
Some names, like
NodePath
, are valid as type names and as function names but not as first-class values.In some cases (
Vector2
, in particular), you can call fields on the pseudo-object, such asVector2.LEFT
, butVector2
on its own isn't meaningful. Consider how to make sense of all of this for built-in types that exhibit this behavior.Constructor Only
NodePath
Bool
Int
Float
String
(See notes)Rect2
AABB
RID
Dictionary
(See notes)Array
PoolColorArray
PoolByteArray
PoolIntArray
PoolRealArray
PoolStringArray
PoolVector2Array
PoolVector3Array
Constructor and Constants
Vector2
Vector3
Transform2D
Plane
Quat
Basis
Transform
Color
Miscellaneous
Null
(See notes)Object
(See notes)