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

Prepared handlers #14

Open
foxfriends opened this issue Nov 24, 2023 · 0 comments
Open

Prepared handlers #14

foxfriends opened this issue Nov 24, 2023 · 0 comments

Comments

@foxfriends
Copy link
Owner

foxfriends commented Nov 24, 2023

Rather than defining a regular function accepting a closure and then putting a handler inside it, dedicated syntax for preparing handlers around a deferred execution would be nice. It is just syntax sugar in the end, but needs two things:

  • a way to define such a prepared handler
  • a way to apply the prepared handler to the rest of the current sequence

Defining a prepared handler (no syntax yet, just use a regular proc-accepting-proc):

proc noop_logger!(body) {
  return with body!()
    when 'log(x) resume unit
    else yield
}

Applying a prepared handler:

proc no_log!() {
  use noop_logger
  yield 'log("hello")
}

Expands to:

proc no_log!() {
  noop_logger!(do() {
    yield 'log("hello")
  })
}
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

1 participant