Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua versions? #3

Open
bbarker opened this issue Jul 8, 2020 · 5 comments
Open

Lua versions? #3

bbarker opened this issue Jul 8, 2020 · 5 comments

Comments

@bbarker
Copy link
Contributor

bbarker commented Jul 8, 2020

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?

@opyapeus
Copy link
Owner

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
Copy link
Owner

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.

@bbarker
Copy link
Contributor Author

bbarker commented Sep 17, 2020

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
Copy link
Contributor Author

bbarker commented Sep 19, 2020

@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
Copy link
Contributor Author

bbarker commented Sep 19, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants