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

Return Hook #256

Open
robcxyz opened this issue Jan 1, 2024 · 0 comments
Open

Return Hook #256

robcxyz opened this issue Jan 1, 2024 · 0 comments
Labels
implemented proposal Proposal for changes in syntax / behaviour

Comments

@robcxyz
Copy link
Collaborator

robcxyz commented Jan 1, 2024

Return Hook

None

Overview

NOTE: See return-key for an additional macro for ergonomics.

Currently when a declarative hook is called with an exec, the entire context is parsed with a special field for returning the appropriate value (return) being used to specify what the result is of that parsing.

This proposal would add a hook for being able to escape parsing and return a specific value as the public context.

Examples

Normal parsing

foo: bar

return a key->: return {{foo}}

Would result in the value bar being returned in the public context.

Similarly with exec:

<-:

  exec:

    foo: bar

    return a key->: return {{foo}}

    something that: is ignored

Implementation

Context can be set within the hook. Need a way to send kill signal to parsing though since once the context is set, we need to be able to stop the parsing of the next key.

NOTE: Likely this kill signal approach would also enable a macro like approach for implementing return-key.

@robcxyz robcxyz changed the title tmp Return Hook Jan 1, 2024
@robcxyz robcxyz added proposal Proposal for changes in syntax / behaviour implemented labels Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implemented proposal Proposal for changes in syntax / behaviour
Projects
None yet
Development

No branches or pull requests

1 participant