Created
February 13, 2017 19:57
-
-
Save jemc/0dddeb44f635480ad50db7190a228a37 to your computer and use it in GitHub Desktop.
A pattern for dealing with unreachable conditions in Pony.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Unreachable | |
new create(value: (Stringable | None) = None, loc: SourceLoc = __loc) => | |
@printf[I32]( | |
"ABORT: Unreachable condition at %s:%zu (in %s method)\n".cstring(), | |
loc.file().cstring(), loc.line(), loc.method().cstring()) | |
if value isnt None then | |
@printf[I32]("%s\n".cstring(), value.string().cstring()) | |
end | |
@exit[None](I32(1)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun apply(): I32 => | |
match x | |
| let x': Foo => handle_foo(x') | |
| let x': Bar => handle_bar(x') | |
| let x': Baz => handle_baz(x') | |
else Unreachable(x); 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment