From du@@@@dr|@n @end|ng |rom gm@||@com  Sat Mar  2 12:06:08 2024
From: du@@@@dr|@n @end|ng |rom gm@||@com (=?UTF-8?B?QWRyaWFuIER1yJlh?=)
Date: Sat, 2 Mar 2024 13:06:08 +0200
Subject: [Rd] capture "->"
In-Reply-To: <003d01da6c1f$b4326b00$1c974100$@gmail.com>
References: <CAJL_pojF-Qc8YA0_eB+Ab9w3qD5sgMkjm0C3b0ooOmoOUy769w@mail.gmail.com>
 <ff87b48a-ccad-40ec-b79e-3fb4c945d3a9@gmail.com>
 <CAJL_pogbYhhLxsXQN0jjm83sZybh1nO1wE6F+CwNV18F9EkYUA@mail.gmail.com>
 <79f6c330-e5bf-4ad4-9ccc-ed47ab8dcb69@gmail.com>
 <CAJL_poiOUuBfPLqa3uTswA=1LG=1CZeBR9XudSaFQYbesQG+cA@mail.gmail.com>
 <1cef84f8-a9d4-436a-a606-765a084a4a91@gmail.com>
 <005b01da6be5$0361b9f0$0a252dd0$@gmail.com>
 <CAJ=0CtBZPv+Sia-OkGQBCAj+ogSUeTyQ3hVWorbv-DaOZwi64A@mail.gmail.com>
 <003d01da6c1f$b4326b00$1c974100$@gmail.com>
Message-ID: <CAJ=0CtCdmFC_VQd7arvp5AvkeZzhrJXV=fnB5kDUtdu2b0NA4g@mail.gmail.com>

That would have been an elegant solution, but it doesn't seem to work:

> `->` <- `+`
> 1 -> 3 # expecting 4
Error in 3 <- 1 : invalid (do_set) left-hand side to assignment

It is possible to reassign other multiple character operators:
> `%%` <- `+`
> 1 %% 3
[1] 4

The assignment operator `->` is so special for the R parser, that it seems
impossible to change.

On Fri, Mar 1, 2024 at 11:30?PM <avi.e.gross at gmail.com> wrote:

> Adrian,
>
> That is indeed a specialized need albeit not necessarily one that cannot
> be done by requiring an alternate way of typing a formula that avoids being
> something the parser sees as needed to do at that level.
>
> In this case, my other questions become moot as I assume the global
> assignment operator and somethings like assign(?xyz?, 5) will not be in the
> way.
>
> What I was wondering about is what happens if you temporarily disable the
> meaning of the assignment operator <- and turn it back on after.
>
> In the following code, for no reason, I redefine + to mean ? and then undo
> it:
>
>
> > temp <- `+`
> > `+` <- `-`
> > 5 + 3
> [1] 2
> > `+` <- temp
> > 5 + 3
> [1] 8
>

	[[alternative HTML version deleted]]



[Rd] capture "->"
=?UTF-8?B?QWRyaWFuIER1yJlh?=