A comment on python-ideas made me realize that the sage preparsing of
integer literals and ".." invalidates otherwise valid syntax:

sage: preparser(False)
sage: 1..conjugate()
1.0
sage: preparser(True)
sage: 1..conjugate()
...
SyntaxError: invalid syntax
sage: preparse("1..conjugate()")
'Integer(1)..conjugate()'
so strictly speaking, integer literal recognition is a little too
eager here.

There are workarounds:
sage: 1.0.conjugate()
1.00000000000000
sage: 1. .conjugate()
1.00000000000000

it really clashes with ellipsis, though:

sage: [1..conjugate()]
IndexError: tuple index out of range
sage: preparse("[1..conjugate()]")
'(ellipsis_range(Integer(1),Ellipsis,conjugate()))'

and the following are confusing corollaries

sage: preparse("[1...3.]")
'[1Ellipsis3.]'
sage: preparse("[1...3.]")
'[1Ellipsis3.]'
sage: preparse("[1....3.]")
'[1Ellipsis.gen(3).]'
sage: preparse("[1. ...3.]")
"[RealNumber('1.') Ellipsis3.]"
sage: preparse("[1. ...3.]")
"[RealNumber('1.') Ellipsis3.]"
sage: preparse("[1. ... 3.]")
"[RealNumber('1.') Ellipsis RealNumber('3.')]"

that miss the correctly parsed
sage: [1. .. 3.]
[1.00000000000000, 2.00000000000000, 3.00000000000000]

I'm not sure if this needs fixing, but it does highlight that whatever
the sage language is at the moment, it might be difficult to describe
it with a clean formal specification. I think that is an undesirable
state (mitigated by the fact that it at least doesn't affect our
library code).


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

Reply via email to