> This could all be avoided if before changing a variable to maxima we
> prepended it with _sage_var_ (say), and stripped those off when moving
> from maxima back to Sage.  This is worth considering...
>

I think we'll have to do something along these lines.

> Basically, right now, any time that one makes a symbolic variables
> that just *happens* to be the same as the name of a function defined
> in maxima's large global namespace, any symbolic calls to maxima
> involving that variable break.   One could imagine e.g., writing code
> that works and uses an innocent sounding variable like x2 (say),
> upgrading maxima in a few months, and finding that the code suddenly
> doesn't work in arbitrarily confusing ways (since x2 could be defined
> in Maxima to be something entirely weird/crazy like "factorial(k + 3*n
> - 1)/factorial(2*k + 6*n)").
>

Yep, this is definitely worrisome. Actually, thanks to the command
that RJF mentioned, it would be easy enough to check for collisions
when creating a variable -- however, this still doesn't solve the
issue that what variables are legal may change from one version of
maxima to another. (Heck, they could happen to pick _sage_var_x as a
variable in their namespace at some point ...)

Interestingly, though, this isn't what's happening in the example
below -- there's a second thing we have to worry about:

> sage: factorial = var('factorial')
> sage: factorial^3 + factorial/7 - 1
> factorial^3 + 1/7*factorial - 1
> sage: (factorial^3 + factorial/7 - 1).simplify()
> BOOM!
>

Here, the issue isn't that we're hitting the "factorial" in the maxima
namespace. It's that we're hitting factorial when we try to recreate a
sage symbolic expression from it. e.simplify() just does
SR(e._maxima_()), so let's do it in steps:

sage: factorial = var("factorial")
sage: e = factorial^3 + factorial/7 - 1
sage: e._maxima_()
factorial^3+factorial/7-1
sage: SR(e._maxima_())
BOOM!

> Thoughts?
>

I think we should rename variables when we move them over to maxima,
as you mentioned above, but also do a check when we first start a
maxima session to make sure that no entries that start with whatever
our prefix is pop up in their namespace. I think this will solve both
of the obvious issues -- but I'm sure there are more I'm not thinking
of. :)

-cc
-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to