Inconsistency when using previously defined variables as arguments to functions



Thomas,

I agree that in a case like

     i:1$
     limit(1/i,i,inf);

you might want i to be locally interpreted as a local formal variable.
 That is simple enough -- write limit( '(1/i), 'i, inf).

But what if you have something like this:

     all_limits( expr, vars ) := makelist( [var, limit(expr,var,inf)],
var, vars) $

    all_limits( x/(x+y),[x,y]);
         =>  [[x,1],[y,0]]

Clearly in that case, you *don't* want var to be treated as a local
formal variable.  Since Maxima is designed to be user-extensible --
not just a symbolic desk calculator -- it is very important to be able
to do this sort of thing.

As for 'sum' inconsistently treating the variable as a formal
argument, this was a "convenience feature" added a few years ago.
This presumably makes the system easier to use in some cases, but it
makes it much more complicated to use in other cases.  I am opposed to
such convenience features, which only lead to confusion down the road
(I use a programming system called R, which is full of such "do what I
mean" features which trip me up constantly...).

I don't think we've figured out yet how to solve for this problem
globally.  Some systems treat all symbols as formal until they are
explicitly evaluated -- this would make interactive use simpler in
many cases, but make programming messier.

               -s

On Wed, Jan 26, 2011 at 06:06, thomas <thomas at geogebra.org> wrote:
> Hi there!
>
> Some commands, such as "limit" or "sum" take a "target"-variable as an
> argument. E.g. for limit or sum, this is the 2nd argument. However, there is
> an inconsistency in the way maxima behaves when this variable was previously
> defined:
>
>
> $ maxima
> Maxima 5.23.2 http://maxima.sourceforge.net
> using Lisp SBCL 1.0.40.0.debian
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) i:1;
> (%o1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1
> (%i2) limit(1/i, i, infinity);
>
> limit: second argument must be a variable, not a constant; found: 1
> ?-- an error. To debug this try: debugmode(true);
> (%i3) sum(1/i, i, 1, 2);
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3
> (%o3) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2
>
>
> Since the 2nd argument in these commands is basically "local" to the
> command, it is my understanding that "sum" behaves correctly in this case,
> while "limit" (and others like "diff") should somehow be fixed. At least
> that is my understanding. Would this be possible/feasible?
>
> If that's not the case: is there some way to work around this? I've tried
> using local and a block, but that didn't seem to work out :( Any advice?
>
> Cheers
>
> Thomas
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>