equal
deleted
inserted
replaced
306 program, the code generator complains (since in most cases this is |
306 program, the code generator complains (since in most cases this is |
307 indeed an error). But such constants can also be thought |
307 indeed an error). But such constants can also be thought |
308 of as function definitions which always fail, |
308 of as function definitions which always fail, |
309 since there is never a successful pattern match on the left hand |
309 since there is never a successful pattern match on the left hand |
310 side. In order to categorise a constant into that category |
310 side. In order to categorise a constant into that category |
311 explicitly, use @{command_def "code_abort"}: |
311 explicitly, use the @{attribute code} attribute with |
312 *} |
312 @{text abort}: |
313 |
313 *} |
314 code_abort %quote empty_queue |
314 |
|
315 declare %quote [[code abort: empty_queue]] |
315 |
316 |
316 text {* |
317 text {* |
317 \noindent Then the code generator will just insert an error or |
318 \noindent Then the code generator will just insert an error or |
318 exception at the appropriate position: |
319 exception at the appropriate position: |
319 *} |
320 *} |
322 @{code_stmts strict_dequeue' (consts) empty_queue strict_dequeue' (Haskell)} |
323 @{code_stmts strict_dequeue' (consts) empty_queue strict_dequeue' (Haskell)} |
323 *} |
324 *} |
324 |
325 |
325 text {* |
326 text {* |
326 \noindent This feature however is rarely needed in practice. Note |
327 \noindent This feature however is rarely needed in practice. Note |
327 also that the HOL default setup already declares @{const undefined} |
328 also that the HOL default setup already declares @{const undefined}, |
328 as @{command "code_abort"}, which is most likely to be used in such |
329 which is most likely to be used in such situations, as |
329 situations. |
330 @{text "code abort"}. |
330 *} |
331 *} |
331 |
332 |
332 |
333 |
333 subsection {* If something goes utterly wrong \label{sec:utterly_wrong} *} |
334 subsection {* If something goes utterly wrong \label{sec:utterly_wrong} *} |
334 |
335 |