Luis, do you want me to mangle this into shape, or do you want comments to finish it yourself?
Assuming the latter.
I would mildly prefer this to be implement this as
(return-from open
(tagbody :restart
(let* ((pathname ...) ...)
(flet ((open-error (...) (%open-error ...additional args and defaults... (lambda (&key ...) ...set values based on keys... (go :restart))) ...body-of-open...))))
instead of a recursive call. Where %OPEN-ERROR would be an out of line function with a big RESTART-CASE in it, and all errors in OPEN going to it through OPEN-ERROR -- using :TEST clause in the RESTART-CASE to decide which restarts to activate.
While in the area, other useful restarts might be to switch to:
:IF-EXISTS :APPEND
:IF-DOES-NOT-EXIST :CREATE
and to return NIL instead of the stream, simply retry without doing anything else, USE-VALUE for a different pathname, and finally to create missing directories...
...but that might count as heroic effort. :)
However, if the error signaling and restarts are moved out of line, it would not clutter OPEN and such heroic effort can be later expanded much more easily.
Luis, do you want me to mangle this into shape, or do you want comments to finish it yourself?
Assuming the latter.
I would mildly prefer this to be implement this as
(return-from open
(%open- error ...additional args and defaults...
(lambda (&key ...)
... set values based on keys...
(go :restart)))
. ..body- of-open. ..))))
(tagbody :restart
(let* ((pathname ...) ...)
(flet ((open-error (...)
instead of a recursive call. Where %OPEN-ERROR would be an out of line function with a big RESTART-CASE in it, and all errors in OPEN going to it through OPEN-ERROR -- using :TEST clause in the RESTART-CASE to decide which restarts to activate.
While in the area, other useful restarts might be to switch to:
:IF-EXISTS :APPEND NOT-EXIST :CREATE
:IF-DOES-
and to return NIL instead of the stream, simply retry without doing anything else, USE-VALUE for a different pathname, and finally to create missing directories...
...but that might count as heroic effort. :)
However, if the error signaling and restarts are moved out of line, it would not clutter OPEN and such heroic effort can be later expanded much more easily.