error handling - Using the [Take New] restart in SBCL -


when try re-define package in sbcl in such way causes name conflicts, name-conflict error restarts

 0: [keep-old] keep symbols accessible foo (shadowing others).  1: [take-new] make newly exposed symbols accessible in foo, uninterning old ones.  2: [resolve-conflict] resolve conflict.  3: [retry] retry slime repl evaluation request.  4: [*abort] return slime's top level.  5: [abort] abort thread (#<thread "new-repl-thread" running {10060e47b3}>) 

i'd write automatically invoke take-new restart,

(force (defpackage :foo (:use :cl :bar :baz :mumble))) 

the result of should same calling defpackage, followed manually invoking take-new restart. problem is,

cl-user> (handler-case           (defpackage :foo (:use :cl :bar :baz :mumble))        (error (e) (compute-restarts e))) (#<restart swank::retry {1006dc40f3}> #<restart abort {10068007e3}>  #<restart abort {10060c7f93}>) cl-user>  

i don't seem have access particular restart. confirmed when try invoke it:

cl-user> (handler-case           (defpackage :foo (:use :cl :bar :baz :mumble))        (name-conflict (e) (invoke-restart 'take-new)))  no restart take-new active.    [condition of type sb-int:simple-control-error]  restarts:  0: [retry] retry slime repl evaluation request.  1: [*abort] return slime's top level.  2: [abort] abort thread (#<thread "new-repl-thread" running {10060e47b3}>) 

any ideas?

handler-case exits scope of restarts before transfers control handler; need handler-bind. 2 other differences between constructs handler-bind has different syntax (demonstrated below), , handler-bind doesn't transfer control -- is, handler-bind handler return value needs explicitly transfer control, e.g. return-from or invoke-restart.

something following should work:

(handler-bind ((sb-ext:name-conflict                 (lambda (c)                   (when (find-restart 'sb-impl::take-new c)                     (invoke-restart 'sb-impl::take-new)))))   (defpackage :foo (:use :mumble))) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -