On Wednesday, February 28, 2018 at 2:42:26 PM UTC, Ralf Stephan wrote: > > It might not be necessary to (re)assign the global variable. Only if the > user wants to do operations with the polynomial he wants an x to be that > poly variable, and certainly not another x. So, the parser can do the part > of figuring out what x is meant, maybe by checking all generator names. > Example: > > sage: ....charpoly() > x + 1 > sage: _ - x > (parser sees underscore and operation, and an unassigned global, so it > checks the object referred by the underscore for variable names) >
I don't think this would be a job for the parser. You'd want x bound to something like "UniversalCoercingNamedGenerator('x')" which would be an object that happily coerces into any parent P via essentially P('x'), but it could do something more fancy. In order for 1+UniversalCoercingNamedGenerator('x') to work some more magic for finding common covering parents would be necessary. Mind you: you'd end up with a polynomial over ZZ then, not a symbolic expression. For that you'd need sin(1)+UniversalCoercingNamedGenerator('x')-sin(1)+1 It could be a fun exercise to write such an object, and I think it would be possible. However, I wouldn't be in favour of including it in sage. Its behaviour would be too magical to be reliable for a medium to expert level user, and a novice would probably be able to find all kinds of unexpected edge cases. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.