Okay, so maybe we should open this to other options: should we get rid of 
preparsing "\" into "BackslashOperator"?

For what it's worth, I removed the line defining `_backslash_` in 
binary_tree.py and and I only say one doctest failure in any obvious places 
(combinat and thematic_tutorials). So it's not even used much. Same for 
matroids.

I think that using \ to escape characters in strings still works, but 
line-continuation does not: in Sage, these fail:

    sage: a = 3 + \

and

    sage: \

whereas in pure Python, such backslashes would be treated as 
line-continuations. It should be possible to fix this while keeping the 
current preparser behavior for "\" in the middle of a line. Or as Nils 
proposes, getting rid of the current preparser behavior should also solve 
it.

On Wednesday, September 27, 2023 at 2:44:19 PM UTC-7 Nils Bruin wrote:

> I'm quite strongly against because it collides with a well-established 
> meaning of `\` in python: escape character. It's used to avoid command 
> termination by newline in things like formulas (as "\<newline", which gets 
> parsed as whitespace rather than command termination outside of brackets).
>
> I'm in fact rather shocked that `\` in sage already doesn't work as it's 
> supposed to in python but instead gets substituted as "BackslashOperator()".
>
> Searching the codebase currently only shows "_backslash_" implemented on 
> matroid, matrix, and binary_tree, so extinguishing it should be doable. We 
> should definitely not entrench its use further.
>
> If you want to write your denominator first, you can already do ~2 * 3 . I 
> think that's already sufficiently perverse that we don't need another way 
> to spell that.
> On Wednesday, 27 September 2023 at 12:16:57 UTC-7 David Joyner wrote:
>
>> On Wed, Sep 27, 2023 at 2:32 PM John H Palmieri <jhpalm...@gmail.com> 
>> wrote:
>>
>>> The github issue #36060 (https://github.com/sagemath/sage/issues/36060) 
>>> proposes adding a backslash operator for Sage integers, so that "2 \ 3" 
>>> will return the same as "3 / 2". Do you support this?
>>>
>>>
>> I'm not for or against. However, I don't see the problem that 
>> implementing this "\" is going to solve. The ticket suggests that users 
>> will naturally type 2\3 instead of 3/2, if I am reading between the lines 
>> correctly. 
>>  
>>
>>> BackslashOperator is defined in "sage/misc/misc.py", and the preparser 
>>> converts "A \ b" to the appropriate Python code. The docstring for 
>>> BackslashOperator says "Implements Matlab-style backslash operator for 
>>> solving systems A \ b". 
>>>
>>> It seems pretty innocuous to me — in fact I don't care much either way — 
>>> but since Sage integers are so ubiquitous, it seems like a good idea to ask 
>>> before implementing it.
>>>
>>> -- 
>>> John
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "sage-devel" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to sage-devel+...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/sage-devel/3f157aa4-74cd-4c5c-bc76-f198c6417432n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/sage-devel/3f157aa4-74cd-4c5c-bc76-f198c6417432n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/941e7314-5f78-454a-9017-fe752c630233n%40googlegroups.com.

Reply via email to