Poll: deprecate backslash operator

190 views
Skip to first unread message

John H Palmieri

unread,
Sep 30, 2023, 5:47:44 PM9/30/23
to sage-devel
I asked this already but with a different subject heading, so people may have missed it.

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".

This is not used much: for matrices, matroids, and a tiny bit (at least in the Sage library) for binary trees. Should we deprecate it?

Arguments for deprecation: the less we rely on the preparser, the better (at least as far as easing a transition between Python and Sage, for instance). The backslash operator is not in wide use in Sage. Currently its implementation breaks the standard Python use of "\" as a line-continuation marker.

Arguments against deprecation: it provides a convenient shorthand, and people may be familiar with it from Matlab or other systems.

Michael Orlitzky

unread,
Sep 30, 2023, 6:58:17 PM9/30/23
to sage-...@googlegroups.com
On Sat, 2023-09-30 at 14:47 -0700, John H Palmieri wrote:
>
> This is not used much: for matrices, matroids, and a tiny bit (at least in
> the Sage library) for binary trees. Should we deprecate it?

Deprecate it, it's a big WTF for most people.

Dima Pasechnik

unread,
Sep 30, 2023, 7:02:27 PM9/30/23
to sage-...@googlegroups.com
deprecate!
> --
> 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/a0659b81-f50f-4b59-91ed-42650409435an%40googlegroups.com.

William Stein

unread,
Sep 30, 2023, 7:51:23 PM9/30/23
to sage-...@googlegroups.com
Again, as the person who added it to Sage in the first place: deprecate.

William
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAAWYfq2-TSvMc8CC%2BeTrRK7YZXiCs9xxpxVKzZTa7MhVNwe9pg%40mail.gmail.com.



--
William (http://wstein.org)

Nils Bruin

unread,
Sep 30, 2023, 11:17:33 PM9/30/23
to sage-devel
Deprecate please.

John Cremona

unread,
Oct 1, 2023, 4:26:51 AM10/1/23
to SAGE devel
Deprecate

On Sun, 1 Oct 2023, 04:17 Nils Bruin, <nbr...@sfu.ca> wrote:
Deprecate please.

--
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.

Eric Gourgoulhon

unread,
Oct 1, 2023, 4:39:27 AM10/1/23
to sage-devel
+1 for deprecation

Eric;

Ricardo Buring

unread,
Oct 1, 2023, 6:59:39 AM10/1/23
to sage-devel
Deprecate the pre-parsing of \
    the backslash operator please.

kcrisman

unread,
Oct 2, 2023, 6:42:38 AM10/2/23
to sage-devel
Though I am sympathetic to the pro-deprecation arguments and recognize they will win, I vote do not deprecate, as mission includes Matlab, and for backwards compatibility.  As an example, the first edition of the AMS-published "Sage for Undergraduates" used the backslash operator in a number of examples (comparing it explicitly with other solving methods for linear systems), so I presume the second edition has maintained that (though I don't personally own it and can't verify immediately; a related website does not seem to have all code examples).

John H Palmieri

unread,
Oct 4, 2023, 12:59:47 AM10/4/23
to sage-devel
The votes are overwhelmingly in favor of deprecating. I have opened https://github.com/sagemath/sage/pull/36394 for this.

John H Palmieri

unread,
Oct 4, 2023, 1:01:54 AM10/4/23
to sage-devel
By the way, see https://github.com/sagemath/sage/issues/36194 for a bug related to the preparser and "\".

Thierry Dumont

unread,
Oct 4, 2023, 1:41:36 PM10/4/23
to sage-devel
In "Computational Mathematics with SageMath" we have some backslash...

So, if we deprecate it, we will have problems with the doctests
asociated,... and with the book.

I don't like the backslash for solving linear systems, but even Julia
has adopted it, probably for Matlab users...

t.d.

Le 01/10/2023 à 05:17, Nils Bruin a écrit :
> Deprecate please.
>
> --
> 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
> <mailto:sage-devel+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/699f7d70-4222-4f64-8ce4-e606478377a9n%40googlegroups.com <https://groups.google.com/d/msgid/sage-devel/699f7d70-4222-4f64-8ce4-e606478377a9n%40googlegroups.com?utm_medium=email&utm_source=footer>.

John Cremona

unread,
Oct 4, 2023, 3:26:01 PM10/4/23
to SAGE devel
I assume that deprecation means that for a year or so people can still use the backslash but will see a deprecation warning. This could last for quite a long time, so existing code would not immediately break.

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/90aec6f5-e47d-4981-941b-a7e909bcf518%40math.univ-lyon1.fr.

John H Palmieri

unread,
Oct 4, 2023, 4:34:46 PM10/4/23
to sage-devel
Right. According to the Sage Developer's Guide, "Deprecated code can only be removed one year after the first stable release in which it appeared," so it will work for at least a year, and then someone would have to take further action to remove it completely.

Nils Bruin

unread,
Oct 4, 2023, 5:43:38 PM10/4/23
to sage-devel
On Wednesday, 4 October 2023 at 10:41:36 UTC-7 Thierry Dumont wrote:
In "Computational Mathematics with SageMath" we have some backslash...

Indeed, I found on page 43 the example:

sage: 123 + \
....: 345
468

which does not work presently. The first mention of "\" as an operator is on page 162, where it's given as a shorthand for solve_right in a table (with "/" as a shorthand of solve_left)
It also occurs on p168 (sect. 8.2.2) [twice] , p281, p283 (with explanation), p302 (in a summary table). Even in the sections where it is used, `\` is used much more often as a line continuation .

As far as the book is concerned, I think certainly fixing "\" to work as line continuation is definitely more important for its correctness, since that's used in much more places in the book (and also in all the chapters where `\` is used as an operator). In all the places except the summary table on p302, I saw the alternative solve_right spelling explicitly mentioned. So impact of deprecating the notation is rather limited. You could just add it to an errata/updates list.
 

Emmanuel Charpentier

unread,
Oct 8, 2023, 12:24:24 PM10/8/23
to sage-devel
BTW :the changes and  advances made in Sage since the last edition of this book may warrant a revision, possibly a new edition. If only for the installation procedures (Conda installation, WSL on Windows, Github replacing Trac, etc...) and the interfaces (Jupyter replacing the Sage notebook, emacs as an alternative to command line, etc...).

Thierry Dumont

unread,
Oct 8, 2023, 5:24:07 PM10/8/23
to sage-...@googlegroups.com


Le 08/10/2023 à 18:24, Emmanuel Charpentier a écrit :
> BTW :the changes and  advances made in Sage since the last edition of
> this book may warrant a revision, possibly a new edition. If only for
> the installation procedures (Conda installation, WSL on Windows, Github
> replacing Trac, etc...) and the interfaces (Jupyter replacing the Sage
> notebook, emacs as an alternative to command line, etc...).
>
Yes, for sure... It would be great. We just need manpower, time, and so
on :-)

> Le mercredi 4 octobre 2023 à 23:43:38 UTC+2, Nils Bruin a écrit :
>
> On Wednesday, 4 October 2023 at 10:41:36 UTC-7 Thierry Dumont wrote:
>
> In "Computational Mathematics with SageMath" we have some
> backslash...
>
>
> Indeed, I found on page 43 the example:
>
> sage: 123 + \
> ....: 345
> 468
>
> which does not work presently. The first mention of "\" as an
> operator is on page 162, where it's given as a shorthand for
> solve_right in a table (with "/" as a shorthand of solve_left)
> It also occurs on p168 (sect. 8.2.2) [twice] , p281, p283 (with
> explanation), p302 (in a summary table). Even in the sections where
> it is used, `\` is used much more often as a line continuation .
>
> As far as the book is concerned, I think certainly fixing "\" to
> work as line continuation is definitely more important for its
> correctness, since that's used in much more places in the book (and
> also in all the chapters where `\` is used as an operator). In all
> the places except the summary table on p302, I saw the alternative
> solve_right spelling explicitly mentioned. So impact of deprecating
> the notation is rather limited. You could just add it to an
> errata/updates list.
>
> --
> 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
> <mailto:sage-devel+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/f507ef0e-37a9-4306-846d-73e519a96723n%40googlegroups.com <https://groups.google.com/d/msgid/sage-devel/f507ef0e-37a9-4306-846d-73e519a96723n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Max Alekseyev

unread,
Feb 28, 2024, 7:39:32 AMFeb 28
to sage-devel
Here is another bug apparently related to the preparser and "\":

Regards,
Max
Reply all
Reply to author
Forward
0 new messages