Mercerenies / gdlisp

Lisp on the Godot platform
GNU General Public License v3.0
140 stars 1 forks source link

Deal with pseudo-constructors #65

Closed Mercerenies closed 1 year ago

Mercerenies commented 2 years ago

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 as Vector2.LEFT, but Vector2 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

Constructor and Constants

Miscellaneous

Mercerenies commented 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

Mercerenies commented 1 year ago

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

Constructor and Constants

Miscellaneous

Special Notes:

Mercerenies commented 1 year ago

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.

Mercerenies commented 1 year ago

See #106 for the Object-specific issue.

Mercerenies commented 1 year ago

106 closed by 78efc66, which resolves this issue.