[Rd] [External] Re: New pipe operator
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Sat Dec 5 16:57:15 CET 2020
On 04/12/2020 9:11 p.m., luke-tierney using uiowa.edu wrote:
> On Sat, 5 Dec 2020, Duncan Murdoch wrote:
>
>> On 04/12/2020 2:26 p.m., luke-tierney using uiowa.edu wrote:
>>> On Fri, 4 Dec 2020, Dénes Tóth wrote:
>>>
>>>>
>>>> On 12/4/20 3:05 PM, Duncan Murdoch wrote:
>>>>> ...
>>>>>
>>>>> It's tempting to suggest it should allow something like
>>>>>
>>>>> mtcars |> subset(cyl == 4) |> lm(mpg ~ disp, data = .)
>>>>>
>>>>> which would be expanded to something equivalent to the other versions:
>>>>> but
>>>>> that makes it quite a bit more complicated. (Maybe _ or \. should be
>>>>> used
>>>>> instead of ., since those are not legal variable names.)
>>>>
>>>> I support the idea of using an underscore (_) as the placeholder symbol.
>>>
>>> I strongly oppose adding a placeholder. Allowing for an optional
>>> placeholder significantly complicates both implementing and explaining
>>> the semantics. For a simple syntax transformation to be viable it
>>> would also require some restrictions, such as only allowing a
>>> placeholder as a top level argument and only once. Checking that these
>>> restrictions are met, and accurately signaling when they are not with
>>> reasonable error messages, is essentially an unsolvable problem given
>>> R's semantics.
>>
>> I don't think you read my suggestion, but that's okay: you're maintaining
>> it, not me.
>
> I thought I did but maybe I missed something. You are right that
> supporting a placeholder makes things a lot more complicated. For
> being able to easily recognize the non-standard cases _ is better than
> . but for me at least not by much.
>
> We did try a number of variations; the code is in the R-syntax branch.
> At the root of that branch are two .md files with some notes as of
> around useR20. Once things settle down I may update those and look
> into turning them into a blog post.
Thanks for pointing out those documents.
Duncan Murdoch
More information about the R-devel
mailing list