Mercerenies / gdlisp

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

Unquote Splice #37

Closed Mercerenies closed 3 years ago

Mercerenies commented 3 years ago

We have quasiquoting (backtick) and unquoting (comma). We need unquoting spliced (,@).

Assuming the variable lst contains the list (2 3), we should get the following results. The first is already working. The second is the subject of this issue

`(a ,lst d) ==> (a (b c) d)
`(a ,@lst d) ==> (a b c d)

It is an error to use ,@ on a value which is not a list. (or, possibly, a vector; we may choose to allow vectors).

Mercerenies commented 3 years ago

86b4a0b (lists) and fb207c8 (arrays) implement this functionality. The chosen syntax is ,.lst, not .@lst (I want to leave @ open so we might use it for decorators or annotations or something in the future, whereas . at the start of a variable name is already not meaningful). The syntax desugars to unquote-spliced, similar to how , desugars to unquote.

Currently, we can unquote spliced into lists and arrays. We cannot unquote spliced into vectors, nor can we unquote spliced directly into a quasiquote (i.e. `,. is always invalid). Currently, we cannot unquote spliced into dictionary literals { ... } but that may change in the future (see #38).