
;; "/home/kend/Ex-examples.scm" (translated)

(begin
  ($::: (smalltalkAt: 'Object)
        'newSubclassName:iVars:cVars:
        'ExceptionExample
        nil
        nil)
  ($:: (smalltalkAt: 'ExceptionExample)
       'addSelector:withMethod:
       'workingStuff
       (lambda (self)
         (call/cc
           (lambda (return)
             (let ((innerClosure nil))
               (let ((%%val%%
                       (lambda (ex) ($: ex 'return: 'thwartedBadly))))
                 (set! innerClosure %%val%%)
                 %%val%%)
               (return
                 ($: self
                     'breakStuffWithInnerClosure:
                     innerClosure)))))))
  ($:: (smalltalkAt: 'ExceptionExample)
       'addSelector:withMethod:
       'breakStuffWithInnerClosure:
       (lambda (self innerClosure)
         (call/cc
           (lambda (return)
             (let ((answer nil))
               (let ((%%val%%
                       ($: self
                           'protectedStuffToBreakWithInnerClosure:
                           innerClosure)))
                 (set! answer %%val%%)
                 %%val%%)
               ($: ($: answer '= 'outer)
                   'ifTrue:
                   (lambda () (return 'workedWrong)))
               ($: ($: answer '= 'thwartedBadly)
                   'ifTrue:
                   (lambda () (return 'thwartedProperly)))
               (return answer))))))
  ($:: (smalltalkAt: 'ExceptionExample)
       'addSelector:withMethod:
       'breakingStuff
       (lambda (self)
         (call/cc
           (lambda (return)
             (let ((innerClosure nil))
               (let ((%%val%% (lambda (ex) (return 'thwartedBadly))))
                 (set! innerClosure %%val%%)
                 %%val%%)
               (return
                 ($: self
                     'breakStuffWithInnerClosure:
                     innerClosure)))))))
  ($:: (smalltalkAt: 'ExceptionExample)
       'addSelector:withMethod:
       'protectedStuffToBreakWithInnerClosure:
       (lambda (self innerClosure)
         ($:: (lambda () ($: 3 '/ 0) 'didNotFailAsItShould)
              'on:do:
              (smalltalkAt: 'ZeroDivide)
              (lambda (ex)
                ($: innerClosure 'value: ex)
                ($: ex 'return: 'outer))))))

;;   -- e o f ---    ;;
