Mercerenies / gdlisp

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

Setters #33

Closed Mercerenies closed 3 years ago

Mercerenies commented 3 years ago

Currently, set (formerly setq; cbcd68a) works on literal symbols and on access-slot as a special case. My proposal is to expand it as follows.

First, (set a b) (where the first argument is a literal symbol) is still special-cased to assignment in the compiler.

Second, for now at least, (set (access-slot a b) c) is still special-cased to assignment to an instance variable.

Finally, (set (foo a b) c) is compiled to

(set-foo c a b)

which the user can implement as a function or a macro as desired.

If we do #32, we could also implement set-assign-slot to get rid of the second special-case above.

Mercerenies commented 3 years ago

b75acd9 implements this feature, as specified above.