Джерело:
Common Lisp Tips
Дата публікації:
27/02/2013 04:13
Постійна адреса новини:
http://www.vsinovyny.com/8323837
27/02/2013 04:13 // Common Lisp Tips
I have some code that reads data from a config file. If there’s a problem loading, I’d like the opportunity to fix it, outside of Lisp, and retry loading. It’s easy to do that with with-simple-restart and loop:
(loop
(with-simple-restart (try-again "Try again")
(return
(progn
(setf *config* (load-config-file))))
If any error occurs during load-config-file, I can either fix up the file and choose the try-again restart, or give up and use an abort restart.
(Thanks to Frode Vatvedt Fjeld for the concise idiom.)
| « |
Наступна новина з архіву The optional arguments of deftype |
Попередня новина з архіву Semicolon style |
» | |
|
|
||||