You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pico8 uses Lua as its scripting language, which allows overloading functions on the number of arguments it takes.
For example, Pico8's spr function can be called in the following ways:
1.spr(n, x, y)
2.spr(n, x, y, w)
3.spr(n, x, y, w, h)
4.spr(n, x, y, w, h, flip_x)
5.spr(n, x, y, w, h, flip_x, flip_y)
We need to decide various things:
Do we expose all 5 versions? We could, for example, only expose the most general one (5) and have the user write their shorthands.
If we do expose all 5, how do we name them?
We could also just have a general version with Option<T> arguments and expose that instead:
Is the purpose of the Option<T> just to be able to put none without having to know the default for the specific variable? That doesn't sound bad if you wanted to make it as easy as possible, but since this is Rust people may as well just find out what their function is doing right?
I dislike exposing all versions as the naming is not going to be obvious, but having another print function that automatically adds 8 to y each time you call it would probably be really convenient as that removes some overhead.
Description
Pico8 uses Lua as its scripting language, which allows overloading functions on the number of arguments it takes.
For example, Pico8's
spr
function can be called in the following ways:We need to decide various things:
Option<T>
arguments and expose that instead:IMO that's pretty ugly, and not much more convenient than having non-optional arguments (and have the user pass in the defaults).
We need to make sure that whatever approach we choose works for all of the Pico8 API functions.
The text was updated successfully, but these errors were encountered: