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

Handle expression syntax #601

Open
TimWhiting opened this issue Oct 24, 2024 Discussed in #599 · 1 comment
Open

Handle expression syntax #601

TimWhiting opened this issue Oct 24, 2024 Discussed in #599 · 1 comment

Comments

@TimWhiting
Copy link
Collaborator

Discussed in #599

Originally posted by chtenb October 24, 2024

pub effect yield<a>
  ctl yield(elem : a) : ()
  
pub fun fin/take(it : () -> <yield<a>|e> (), n : int) : <yield<a>|e> ()
  var count := 0
  override handle it
    ctl yield(elem)
      if count < n then
        yield(elem) // Forward the yield to our new yield function
        count := count + 1
        resume(())
      else
        ()

According to the compiler, this syntax is invalid

repro.kk(7, 3): parse error: invalid syntax
  unexpected "override"
  expecting ";", "inline", "noinline", "tail", "fip", "fbip", "fun", "val", "var", "with", (basic) expression, "return" or "}"

But if I'm not mistaken, the syntax spec in the book says this should work: https://koka-lang.github.io/koka/doc/book.html#sec-handler-expressions
Which of the two is right?

@TimWhiting
Copy link
Collaborator Author

Even surrounding it by () like the grammar wants still has this error.

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

No branches or pull requests

1 participant