|
From: Leo B. <Leo...@um...> - 2026-01-09 15:15:44
|
On Thu, Jan 08 2026, Robert Dodier <rob...@gm...> wrote:
> On Thu, Jan 8, 2026 at 3:18 PM Stavros Macrakis <mac...@gm...> wrote:
>
>> As Fateman points out, no common programming languages support subscripted formal variables, for all the good reasons you give.
>
> That's a pretty weak argument, isn't it? There's already all kinds of
> stuff in Maxima that doesn't exist in other languages; that's kind of
> the point of having different languages.
>
> There may be other reasons against non-symbols as arguments, but
> simple popularity or lack of it isn't one of them.
>
>> If it's just the name that is wanted, users can use other conventions if their variables have conventional names, e.g., phi_x, phi_y, phi_z.
>
> Maxima already allows nonatomic expressions to be used as variables in
> various contexts, which makes it an unpleasant surprise that it
> doesn't extend to formal arguments.
When I read EHM's post, it seemed clear to me that the issue was the
*display* of the variables. The issue of using a subscripted variable is
a red herring, I think.
For example, using imaxima, one can do:
#+begin_example
(%i2) A[k] := block([s:concat('A,'_,k)], apply(texput,[s,printf(false,"{~a^{~a}}",'A,k)]),s);
(\%o2) A_{k}:=\mathbf{block}\;\left(\left[ s:\mathrm{concat}\left(\mbox{{}'{}}A , \linebreak[0]\mbox{{}'{}}\_ , \linebreak[0]k\right) \right] , \linebreak[0]\mathrm{apply}\left(\mathrm{texput} , \linebreak[0]\left[ s , \linebreak[0]\mathrm{printf}\left(\mathbf{false} , \linebreak[0]\verb|{~a^{~a}}| , \linebreak[0]\mbox{{}'{}}A , \linebreak[0]k\right) \right] \right) , \linebreak[0]s\right)
(%i3) define(foo(A[r],A[z]),A[r]+A[z]);
(\%o3) \mathrm{foo}\left({A^{r}} , \linebreak[0]{A^{z}}\right):={A^{z}}+{A^{r}}
#+end_example
|