Scope, assumptions, asksign, context. Was Re: Bug in Maxima 5.30.0
Subject: Scope, assumptions, asksign, context. Was Re: Bug in Maxima 5.30.0
From: Robert Dodier
Date: Thu, 5 Sep 2013 17:50:11 +0000 (UTC)
On 2013-09-04, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> Quick partial answer: take a look at the R functions environment,
> parent.env, parent.frame, ....
> For an example of a difficult-to-solve problem, see this email
> chain<https://groups.google.com/forum/#!topic/manipulatr/Jr7S_1GX5Yk>
> where I reported a bug in the plyr package.
Well, the problem that's reported there is pretty specific to R, right?
because of the frame business -- Maxima doesn't have anything like that.
To give us something to talk about, here is a quick n dirty
implementation of with_posval. I don't pretend this is anywhere near a
finished product.
best
Robert Dodier
PS.
$ cat with_posval.lisp
;; copyright 2013 by Robert Dodier
;; I release this work under terms of the GNU General Public License
(defmspec $with_posval (foo)
(let
((expr (second foo))
(vars (meval (third foo)))
(ctxt-name (gensym)))
(unwind-protect
(progn
(mfuncall '$supcontext ctxt-name)
(assume-positive (rest vars))
(meval expr))
(mfuncall '$killcontext ctxt-name))))
(defun assume-positive (vars)
(mapcar #'(lambda (x) (mfuncall '$assume `((mgreaterp) ,x 0))) vars))