โ† All Picat Flashcard Decks

Picat Exception Handling and Debugging Flashcards

6 cards from real Picat practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Picat Exception Handling and Debugging flashcards as text
  1. Which construct catches exceptions in Picat?

    Answer: catch(Goal, Error, Handler)

    `catch(Goal, Error, Handler)` executes Goal and runs Handler if a matching exception is raised.

  2. How do you raise an exception in Picat?

    Answer: throw(Error)

    `throw(Error)` raises an exception carrying the given error term in Picat.

  3. What is the standard ISO format for a type error term in Picat?

    Answer: error(type_error(Type, Value), _)

    ISO standard errors in Picat use `error(type_error(Type, Culprit), Context)` as the thrown term.

  4. Which error type is thrown when a predicate requires an instantiated argument but receives a variable?

    Answer: instantiation_error

    `instantiation_error` is thrown when a predicate receives an insufficiently instantiated (unbound) argument.

  5. What happens if no `catch` clause matches a thrown exception in Picat?

    Answer: The exception propagates up the call stack

    An unmatched exception continues propagating up the call stack until a matching catch or the top level is reached.

  6. How can you write a catch clause that matches any exception regardless of type in Picat?

    Answer: catch(Goal, _, Handler)

    Using `_` as the error pattern in `catch/3` acts as a wildcard matching any exception term.