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

Add Environment::runWithStringResults to enable better Lua console REPL #246

Closed
wants to merge 1 commit into from

Conversation

GinjaNinja32
Copy link
Contributor

There may be a better design here - happy to adjust if you have suggestions.

@daid
Copy link
Owner

daid commented Sep 6, 2024

Not a fan of so much extra code which is mostly duplicated with minor variations. I think the only thing you currently cannot do yet is the MULTIRET, the rest is sort of doable outside of SP changes.

@GinjaNinja32
Copy link
Contributor Author

hmm. Might be able to merge the two paths into one with something like

Result<void> runStrings(code, name, callback) {
    return runImpl(code, name, [](firstResult) {
        // string code
    });
}
Result<T> runResult(code, name) {
    return runImpl(code, name, [](firstResult) {
        if (lua_gettop(L) < firstResult) {
            // no returned value, convert as if nil
        } else {
            // convert index `firstResult` as normal
        }
        // pop?
    });
}
Result<T> runImpl(code, name, std::function<Result<T>(int firstResult)> handleResults) {
    // MULTRET code through L86
    return handleResults(top - 1);
}

@daid
Copy link
Owner

daid commented Sep 11, 2024

daid/EmptyEpsilon@183db32
5ff9371
This is my attempt in the ECS branch.

@GinjaNinja32
Copy link
Contributor Author

that implementation looks good and does what I wanted from this 👍

@GinjaNinja32 GinjaNinja32 deleted the ECS-console branch October 21, 2024 22:44
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

Successfully merging this pull request may close these issues.

2 participants