Mercerenies / gdlisp

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

Strings vs Symbols #28

Closed Mercerenies closed 2 years ago

Mercerenies commented 3 years ago

Here's another nasty one that's probably worth bringing up.

Should strings and symbols be synonymous? Right now, Symbol as a class behaves oddly. For one, it's literally just a wrapped string, so it's no more efficient than actual strings. For another, default == fails on it, and it can't be used as a hash key in any meaningful way.

In Godot 4.x, we're going to rid ourselves of the Symbol class and compile to StringName anyway.

But on the flipside, macros need to be able to distinguish between strings and symbols, so we would still need some way of identifying them separately. Worth exploring further.

Mercerenies commented 2 years ago

See #94

Mercerenies commented 2 years ago

Symbol is still a wrapped string in this version of GDLisp. However, intern returns a globally-indexed symbol from a global table, so = works on symbols as intended, since two symbols with the same name will always (by the semantics of intern) be the same exact object.