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

Migrate to error return value instead of exceptions #237

Open
giann opened this issue Nov 6, 2023 · 0 comments
Open

Migrate to error return value instead of exceptions #237

giann opened this issue Nov 6, 2023 · 0 comments
Labels
language Issue related to the language proposal Something we consider doing
Milestone

Comments

@giann
Copy link
Collaborator

giann commented Nov 6, 2023

  • We already have an available tag for errors in Value
  • The parsing and type checking would not be impacted
  • We could get rid of setjmp/longjmp
  • Throwing and returning becomes the same thing
  • try/catch would need to be removed
  • Introduce try to be explicit when we propagate errors. This new keyword is required because we will have to implement a new bytecode that returns if an error is raised.
var another = try couldFail(); | return the error if fails
var again = couldFail() catch defaultValue; | default if fails
  • New syntax to handle error based on its type to make up for the removed try/catch
var value = couldFail() catch {
   Unexpected -> defaultValue,
   else -> panic("you lost me")
}
  • Additionally for this to be really useful we would need Blocks #105 so we could write
var value = couldFail() catch {
   Unexpected -> do {
       | ... some complex things

       break newValue;
   },
   else -> panic("you lost me")
}
@giann giann added language Issue related to the language proposal Something we consider doing labels Nov 6, 2023
@giann giann added this to the 0.5.0 milestone Nov 6, 2023
@giann giann modified the milestones: 0.5.0, 0.4.0 Jan 16, 2024
@giann giann modified the milestones: 0.4.0, 0.5.0 May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language Issue related to the language proposal Something we consider doing
Projects
None yet
Development

No branches or pull requests

1 participant