[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Extending apply
From: |
Ian Grant |
Subject: |
Extending apply |
Date: |
Sun, 21 Jan 2007 11:40:08 +0000 |
User-agent: |
KMail/1.9.1 |
Dear, happy guile-users
The scmutils package for SICM allows one to do things like apply arguments to
a vector which evaluates to a vector of results of applying the arguments to
each element in turn. It achieves this in MIT-scheme using this
kludgey-looking method. Here g:apply does the actual extended application. I
am not entirely sure about how the stack-frame methods work, but I guess it's
looking forward from the continuation of the top-level call to apply.
Has anyone done anything like this with guile using the evaluator trap options
or something?
I suppose an alternative would be to run a different REPL ... but maybe that
would be harder.
Any ideas gratefully accepted.
Best wishes
Ian
(define *enable-generic-apply* true)
(define inapplicable-object/operator
(condition-accessor condition-type:inapplicable-object 'DATUM))
(define (apply-extension-init)
(bind-default-condition-handler
(list condition-type:inapplicable-object)
(lambda (condition)
(if *enable-generic-apply*
((stack-frame->continuation
(stack-frame/next
(stack-frame/next
(stack-frame/next
(continuation->stack-frame
(condition/continuation condition))))))
(lambda args
(g:apply (inapplicable-object/operator condition) args)))))))
(define (once-only! thunk name)
(if (lexical-unbound? system-global-environment name)
(begin (thunk)
;; Create NAME in SGE
(eval `(define ,name #t) system-global-environment)
'done)
'already-done))
(once-only! apply-extension-init 'apply-extension-init)
- Extending apply,
Ian Grant <=