Hello.

I like Sage a lot, but one thing prevents me from using it for math (I
use it for algorithms instead). That unfortunate issue is
var("..."). . . I'd like to elaborate on this issue and state a
possible suggestion (which may have been thought of already, but here
goes):

Problem:
The syntax of python is not conducive of symbolic manipulation (e.g.
holding arguments to functions in unevaluated form, etc.), so abstract
symbol objects needed to be created with the var("...") function.

e.g. a newbie symbolic calculation
w=var("w")
x=var("x")
y=var("y")
z=var("z")
expr = w/x + y/z
print expr(z=5) #substitution

# # # # #

I'd like to point out a few unfortunate issues with this:
1- it seems rather verbose

2- namespace collisions between math symbols and program variables
(see above)

e.g.
x = "important data"
# ...code...
# ...code...
x=var("x") # oops, accidentally overwrote a variable binding =(
plot(... something involving x...)
print x
=> var("x") # oops...

3- it's hard to tell if something is bound to a symbol, or to some
other object like a list

e.g.
x=var("x")
y=someVectorObject(2,3) # not sure if Sage supports automatic mapping
over lists of variables
x*y

4- it's cluttered to input a variable as an afterthought, e.g.
plot(var('x'),[var('x'),0,5])

5- if you stop needing a symbolic variable, you might forget to delete
the x=var("x") declaration, leading to the accumulation of junk...
e.g. if you want to plot something

6- changing a variable's name forces you to change the variable name
in an additional place

7- the additional verbosity and lines add to code clutter

# # # # #

Possible solution:
Since Sage is already preparsing code, it could do this:
expr = w./x. + y./z.
print expr(z=5) #substitution

I'm not necessarily suggesting using "." as the special symbol... just
something easy to hit and that doesn't conflict with reserved python
syntax. This would be similar to $x notation in various other
programming languages.

Alternatively, is there some %[input mode] which would be a better
workaround?

Best wishes,
Mats
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to