psimp icon indicating copy to clipboard operation
psimp copied to clipboard

Lua versions?

Open bbarker opened this issue 5 years ago • 5 comments

I've been wanting to do PureScript addons for Wow for some time; WoW uses a subset of Lua 5.1; refrence ist here. I wonder what the best way is to support multiple versions of Lua?

bbarker avatar Jul 08 '20 22:07 bbarker

I didn't even think about supporting multiple versions, but the example code worked with version 5.1. Since Lua code generation in this library uses only simple syntax so far, it may be okay if you don't care too much about it. (optimistic)

opyapeus avatar Jul 14 '20 02:07 opyapeus

I'm thinking a bit about making a binding for PICO-8 (which uses a subset of Lua too). I think it can be realized by writing a fair amount of FFI.

opyapeus avatar Jul 14 '20 02:07 opyapeus

A binding to PICO-8 would be great! good luck. My first haskell project was an attempt to make something like the pico-8, but got stumped with some SDL issues. Making a PureScript wrapper instead would sidestep that class of issues.

That sounds promising regarding using the simple subset being likely to work across versions. I've not been in a good place to try it yet but still hope to do so at some point in the coming months.

bbarker avatar Sep 17 '20 03:09 bbarker

@opyapeus Got around to trying this out with luatex and world-of-warcraft. I think the latter has a few more issues that need to be resolved, but possibly not in this repo. The current blocker for me relates to wow's Lua not having require. Probably the way to go is to implement require in a Lua library that is added to WoW projects, though I don't yet know enough Lua to know quite how to do this yet.

Also, for anyone interested, my notes are currently at https://gist.github.com/bbarker/e22650106109c78cca6361b4ce50d24c until I get something more substantial (and working) available.

bbarker avatar Sep 19 '20 14:09 bbarker

So far, I'm not sure implementing require is the best way to go, other than maybe having it implemented as a no-op function so that it could be left in the code. Instead, I wonder if it might be possible to have an option to make global aliases so that everything is just exported with the correct namespacing. For example, in Effect_Console.

Instead of having just

return {
    log = log,
    logShow = logShow,
    warn = warn,
    warnShow = warnShow,
    error = error,
    errorShow = errorShow,
    info = info,
    infoShow = infoShow,
    time = time,
    timeLog = timeLog,
    timeEnd = timeEnd,
    clear = clear
}

We could do something like:

local Console = {
    log = log,
    logShow = logShow,
    warn = warn,
    warnShow = warnShow,
    error = error,
    errorShow = errorShow,
    info = info,
    infoShow = infoShow,
    time = time,
    timeLog = timeLog,
    timeEnd = timeEnd,
    clear = clear
}
Effect.Console = Console;
return Console

Effect, a top-level namespace, would then be global. That said, I haven't tested this exactly, but something along these lines seems like it might be compatible with the existing solution. I'll try to give it a try sometime soon, but feedback is welcome.

bbarker avatar Sep 19 '20 19:09 bbarker