On 31-07-2013 08:49, Robert Dodier wrote:
> To return to plot2d, where we started a day or two ago, at this point
> I'm inclined to say trying to use a constant should trigger a complaint.
> (Actually COERCE-FLOAT-FUN should probably just use MSETQ to assign
> a value -- that will trigger any complaints which assignment triggers.
> There may be other kinds of forbidden assignments detected by MSETQ.)
> Let the user enclose plot2d in a lexical environment if they want to
> use a symbol which already has special properties. We'll want to create
> a lexical environment for general use. As a proof of concept, consider
> blex. [http://www.math.utexas.edu/pipermail/maxima/2012/029643.html]
That's better. Now I'm inclined to agree with you :)
If a user mistakenly uses a plot range such as [1,0,2] it will trigger
an error. The same should happen with a range like [%pi,0,2]; plot2d
and plot3d should check that %pi is bound to a constant and should
reject that range. If the user consciously wants to use %pi for his own
variable, then the plot command should be inside an environment where
%pi is no longer bound to a constant and no error will be triggered.
The ranges given to plot commands are checked by the function
check-range in plot.lisp, which uses the following test:
(and ($listp range)
(setq tem (cdr range))
(or (symbolp (car tem)) ($subvarp (car tem)))
(numberp (setq a ($float (meval* (second tem)))))
(numberp (setq b ($float (meval* (third tem)))))
(< a b))
It would be very easy to add the condition that (car tem) cannot be
bound to a constant, if we agree on this behavior.
Regards,
Jaime