Quantcast
Channel: PTC Community : Popular Discussions - Creo Elements/Direct
Viewing all articles
Browse latest Browse all 2965

How to do exception handling in CE/D Lisp?

$
0
0

As part of my Creo Elements/Direct customization, I am trying to do some basic exception handling in Lisp. For Common Lisp, the internet seems to recommend using the handler-case macro. When I run

(do-symbols (s (find-package "lisp"))

  (display s))

in the Creo input line, handler-case is indeed listed. But when I try to run code that uses it I always get "LISP error: The function HANDLER-CASE is undefined." Am I missing something or is there some other method of doing exception handling that is preferred?

 

If you'd like a toy example to test with, here's a divider that instead of throwing an arith-error (e.g. on divide-by-zero), returns nil instead. Putting this into the input line defines the function fine, but calling it results in the "function undefined" error. I tried replacing handler-case with lisp::handler-case and a few others with no luck.

(defun my-safe-divider (a b)

  (handler-case (/ a b)

    (arith-error nil)))

 

Any help appreciated,

Rich Kinder


Viewing all articles
Browse latest Browse all 2965

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>