dynamically created symbol



Robert,

Your with_local_context macro looks good... I was just suggesting that
Maxima provide different primitives than the current ones (esp. as you
point out that supcontext quotes but newcontext doesn't).

                -s

On Tue, Jul 3, 2012 at 1:22 AM, Robert Dodier <robert.dodier at gmail.com>wrote:

> On 2012-07-02, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
>
> > newcontext/supcontext do evaluate their arguments -- try e.g.
> > newcontext(gensym("ctx")) -- but the whole thing is silly.
>
> newcontext does indeed evaluate its argument, but supcontext quotes its.
> I don't see a reason for supcontext to quote ... seems reasonable and
> harmless to have it evaluate.
>
> > Sometimes you need to name contexts, but often anonymous contexts are
> fine.
> >  It looks like in most cases, all you want is something like
> > with_local_context( ... ).  Of course, this can be written as a Maxima
> > macro (::=) using supcontext, but if the most common use case is
> anonymous
> > contexts, Maxima should support them directly.
>
> How about this:
>
> load (unwind_protect); /* from share -- tnx Barton W */
> with_local_context ([e]) ::= buildq ([e], block ([foo : gensym ()],
>   apply (supcontext, [foo]), unwind_protect (block (splice (e)),
>   killcontext (foo))));
>
> macroexpand (with_local_context (assume (a > 0, b > a), integrate (1/x,
> x, a, b)));
>  => block([foo:gensym()],apply(supcontext,[foo]), unwind_protect(block
>   (assume(a > 0,b > a),integrate(1/x,x,a,b)), killcontext(foo)))
>
> with_local_context (assume (a > 0, b > a), integrate (1/x, x, a, b));
>  => log(b) - log(a)
>
> facts ();
>  => []
>
> contexts;
>  => [initial, global]
>
>
> best
>
> Robert Dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>