SeedV / SeedLang

An embeddable and visualizable scripting engine for .Net and Unity.
https://seedv.github.io/SeedLang/
Apache License 2.0
9 stars 1 forks source link

Support Stop() during the runtime of a SeedLang script #188

Closed wixette closed 2 years ago

wixette commented 2 years ago

Example case

The sorting example of SeedLang runs SeedPython scripts such as bubble_sort.py. It usually costs a rather long time (say, a few minutes) to run the code and play animations for each operation.

There will be two buttons on the UI of the sorting example: "Run" and "Stop". The user uses the "Run" button to start tunning a program. When the program is running and the visualization animations are being played, the user shall be able to click the "Stop" button to cancel the demonstration. - For doing this, the SeedLang engine may need to provide a Stop() interface.

Possible solutions

  1. SeedLang.Engine provides an interface Stop() for client code to call. Typically the client code will prefer calling this interface in the SingleStep event's On() callback.

  2. Enable the SingleStep event to receive a return value from the client code, to indicate if the rest execution of the program should be continued or not.

wixette commented 2 years ago

Another example case

There are cases where the visualizer figures out that some semantic aspects of the current program cannot be visualized. For example, the sorting example app might limit the maximum length of the data array (under sorting) to 10, and limit the maximum number of each data item to 10. When the visualizer finds that the program defines a data array that exceeds the limit, the visualizer will report the issue, stops the program and wait for the user to update the code.

A Stop() interface is needed in this case too.