katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
94 stars 6 forks source link

Generators #100

Open katsaii opened 1 year ago

katsaii commented 1 year ago

What is your feature request?

Implement generators through a yield keyword.

Please describe in detail how you expect this new feature to behave.

Catspeak code:

countdown = fun () {
  yield 1
  yield 2
  yield 3
}

GML code:

var counter = f.globals.countdown();

show_message(counter()); // 1
show_message(counter()); // 2
show_message(counter()); // 3
show_message(counter()); // undefined(?)
show_message(counter()); // undefined(?)