On Tue, 26 Aug 2025 at 11:06, Rolf Turner <rolfturner at posteo.net> wrote:> > > > On more than one occasion I have got myself into trouble by > fumble-fingering and typing "**" when I intended to type "*". > Unfortunately the expression produced is syntactically correct and the > consequent incorrect results were difficult (for me) to disentangle. > > I would be much happier if the "**" operator were simply not allowed, > and threw an error. It seems to me that the existence of the "**" > operator is an archaism, probably deriving from Fortran. > > The documentation, obtained from ?Arithmetic, says at one point: > > > ** is translated in the parser to ^, but this was undocumented for > > many years. It appears as an index entry in Becker et al. (1988), > > pointing to the help for Deprecated but is not actually mentioned on > > that page. Even though it had been deprecated in S for 20 years, it > > was still accepted in R in 2008. > > It seems still be accepted in R in 2025. > > Would there be any mileage in asking R Core to deprecate "**", or > better still make it defunct? Can there be any rational basis for > keeping "**" around?Not a rational basis perhaps, but when I teach R to our newbie students who all want to learn Python, I have fun pointing out that ** is the official way to exponentiate in Python, and ^ does something quite crazy. So keeping ** around in R might make it a tad bit more welcoming to Pythonistas. Best, -Deepayan> cheers, > > Rolf Turner > > -- > Honorary Research Fellow > Department of Statistics > University of Auckland > Stats. Dep't. (secretaries) phone: > +64-9-373-7599 ext. 89622 > Home phone: +64-9-480-4619 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Rolf et al., While removing the ** syntax may fell attractive, removing it will cause legacy program to abend. This is not what one wants from a programming language. It might be better to add code to the parser that produces a wanting message that the ** syntax is not optimal and should be replaced with ^, but which allow legacy programs to run, albeit with a warning message. This will allow old programs to keep running and will prevent Rolf's fumbling finger from fatal flaws. Your thoughts? John John David Sorkin M.D., Ph.D. Professor of Medicine, University of Maryland School of Medicine; Associate Director for Biostatistics and Informatics, Baltimore VA Medical Center Geriatrics Research, Education, and Clinical Center; PI Biostatistics and Informatics Core, University of Maryland School of Medicine Claude D. Pepper Older Americans Independence Center; Senior Statistician University of Maryland Center for Vascular Research; Division of Gerontology and Paliative Care, 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 Cell phone 443-418-5382 ________________________________________ From: R-help <r-help-bounces at r-project.org> on behalf of Deepayan Sarkar <deepayan.sarkar at gmail.com> Sent: Tuesday, August 26, 2025 11:55 AM To: Rolf Turner Cc: r-help at r-project.org Subject: Re: [R] The "**" exponentiation operator. On Tue, 26 Aug 2025 at 11:06, Rolf Turner <rolfturner at posteo.net> wrote:> > > > On more than one occasion I have got myself into trouble by > fumble-fingering and typing "**" when I intended to type "*". > Unfortunately the expression produced is syntactically correct and the > consequent incorrect results were difficult (for me) to disentangle. > > I would be much happier if the "**" operator were simply not allowed, > and threw an error. It seems to me that the existence of the "**" > operator is an archaism, probably deriving from Fortran. > > The documentation, obtained from ?Arithmetic, says at one point: > > > ** is translated in the parser to ^, but this was undocumented for > > many years. It appears as an index entry in Becker et al. (1988), > > pointing to the help for Deprecated but is not actually mentioned on > > that page. Even though it had been deprecated in S for 20 years, it > > was still accepted in R in 2008. > > It seems still be accepted in R in 2025. > > Would there be any mileage in asking R Core to deprecate "**", or > better still make it defunct? Can there be any rational basis for > keeping "**" around?Not a rational basis perhaps, but when I teach R to our newbie students who all want to learn Python, I have fun pointing out that ** is the official way to exponentiate in Python, and ^ does something quite crazy. So keeping ** around in R might make it a tad bit more welcoming to Pythonistas. Best, -Deepayan> cheers, > > Rolf Turner > > -- > Honorary Research Fellow > Department of Statistics > University of Auckland > Stats. Dep't. (secretaries) phone: > +64-9-373-7599 ext. 89622 > Home phone: +64-9-480-4619 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.r-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
@vi@e@gross m@iii@g oii gm@ii@com
2025-Aug-26 18:52 UTC
[R] The "**" exponentiation operator.
Deepak, It is hard to expect different languages to satisfy the same rules but clearly radical changes make the learning curve for people who are multilingual to be harder. Note how the = operator in R also can be used as a normal assignment statement even if officially we are urged to use <- and -> and occasionally the longer variants of <<- and ->> as another example where Rolf might accidentally place a variable in an unintended place. As I mentioned, there is tremendous overloading in both formal languages and mini-languages like regular expressions. The latter uses ^ to match at the beginning and * to accept zero or more of the previous one pattern. But try to write an equation in one of the TeX formatting languages, and it means what follows is a superscript. When studying a new language, it is important for people to realize that they should not assume much is the same, not even something like what a parenthesis does. Functions with the same name, may be very different. Even within a language like R, new functionality may use different symbols. Consider that @ is now used to access slots in newer objects instead of period. This may cause subtle mistakes. Realistically, python and R are drastically different albeit over time there can be some convergence. -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of Deepayan Sarkar Sent: Tuesday, August 26, 2025 11:55 AM To: Rolf Turner <rolfturner at posteo.net> Cc: r-help at r-project.org Subject: Re: [R] The "**" exponentiation operator. On Tue, 26 Aug 2025 at 11:06, Rolf Turner <rolfturner at posteo.net> wrote:> > > > On more than one occasion I have got myself into trouble by > fumble-fingering and typing "**" when I intended to type "*". > Unfortunately the expression produced is syntactically correct and the > consequent incorrect results were difficult (for me) to disentangle. > > I would be much happier if the "**" operator were simply not allowed, > and threw an error. It seems to me that the existence of the "**" > operator is an archaism, probably deriving from Fortran. > > The documentation, obtained from ?Arithmetic, says at one point: > > > ** is translated in the parser to ^, but this was undocumented for > > many years. It appears as an index entry in Becker et al. (1988), > > pointing to the help for Deprecated but is not actually mentioned on > > that page. Even though it had been deprecated in S for 20 years, it > > was still accepted in R in 2008. > > It seems still be accepted in R in 2025. > > Would there be any mileage in asking R Core to deprecate "**", or > better still make it defunct? Can there be any rational basis for > keeping "**" around?Not a rational basis perhaps, but when I teach R to our newbie students who all want to learn Python, I have fun pointing out that ** is the official way to exponentiate in Python, and ^ does something quite crazy. So keeping ** around in R might make it a tad bit more welcoming to Pythonistas. Best, -Deepayan> cheers, > > Rolf Turner > > -- > Honorary Research Fellow > Department of Statistics > University of Auckland > Stats. Dep't. (secretaries) phone: > +64-9-373-7599 ext. 89622 > Home phone: +64-9-480-4619 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttps://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.