On Aug 21, 7:45 pm, Chris Seberino <cseber...@gmail.com> wrote:
> In other words, have a regex like "\w\s\(" that replaces the
> whitespace with "*" giving
> "\w\*\(".
> Is this feasible?  I'm trying to think if there are any hidden gotchas
> I don't know about.

One gotcha would be someone wanting to spell out an expression with
spaces:

 a / ( b + c )

or logical expressions:

( x >-10 and x < -5 ) or ( x > 5 and x < 10 )

It might also mess up non-mathematical expressions such as a list of
tuples:

 [ ("apple", 10.3), ("cherry", 5.7) ]

One solution could be to simply forbid such use of whitespace in
combination with that level of implicit_multiplication. However,
"...)or(..." really looks quite unattractive to me. The python grammar
declares a well-defined, finite set of tokens that can arise in such
infix notation, so I suspect that you can recognize locally from a
string whether "<TOKEN><whitespace>(" would get parsed as a call, but
it's going to have quite a list of exceptions to check for.

The proposed feature by itself would not be strictly more aggressive
than "level 10", which does ")(" :-> ")*(". It is possible to
implement the proposed feature so that ")(" is left alone but ") (" :-
> ")*(".
In this way it would at least still be possible to obtain "f(x)(y)",
at the cost of having to write "(a+b) (c+d)" to trigger implicit
multiplication [currently at level 10,  one would need to write
"f.__call__(x).__call__(y)"], so perhaps we need vector-valued
implicit_multiplication levels.

I wouldn't use it but since it's not in the way if you don't want it,
I don't mind either.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to