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

Exception handling via a condition system : possible? #111

Open
ghost opened this issue Feb 15, 2022 · 2 comments
Open

Exception handling via a condition system : possible? #111

ghost opened this issue Feb 15, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 15, 2022

Is it possible for a Forth to have a Common Lisp like "condition handling" system?
More about "condition handling"; https://en.wikibooks.org/wiki/Common_Lisp/Advanced_topics/Condition_System

@MitchBradley
Copy link

The Forth systems that I used to provide in 80s and 90s - with names like ForthMacs, Sun Forth, and Open Firmware - all had exception handling of that ilk. I'm sure there are other Forth systems with such capabilities.

@ruv
Copy link
Contributor

ruv commented Feb 22, 2022

Is it possible for a Forth to have a Common Lisp like "condition handling" system?

Yes. The standard exception handling mechanism can do what the restart-case function does in Lisp.

: prompt-for-new-file ( -- sd.filename )
  s" Input new file name: " type pad dup 80 accept
;
: read-points-file ( sd.filename -- )
  ['] (read-points-file) catch dup 0= if exit then 2drop
  prompt-for-new-file recurse
;

Of course, some syntactic sugar can be also defined.

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

2 participants