Mercerenies / gdlisp

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

yield as a first-class function #5

Closed Mercerenies closed 3 years ago

Mercerenies commented 3 years ago

Currently, we wrap yield in a GDLisp function and use call magic to delegate to the actual built-in. But honestly, does it even make sense to treat yield as a function? I mean, it explicitly depends on the call context, so converting it to a function sort of defeats the purpose. We can't eta abstract on it. Perhaps yield should be a built-in keyword like it is in GDScript, because right now, the behavior of #'yield is super bizarre.

Mercerenies commented 3 years ago

yield is now a special form and funcrefs cannot be constructed from it. If you want the old behavior (for some reason), you can explicitly use a lambda

(lambda (x y) (yield x y))

but I'm not sure why you would want to do that anyway.