From wdun|@p @end|ng |rom t|bco@com  Fri Aug 30 18:02:02 2019
From: wdun|@p @end|ng |rom t|bco@com (William Dunlap)
Date: Fri, 30 Aug 2019 09:02:02 -0700
Subject: [Rd] ?Syntax wrong about `?`'s precedence ?
In-Reply-To: <7d4a921ac2594ecf83944eb594cbfe97@GBDCVPEXC08.corp.lgc-group.com>
References: <CAEKh8ugXyz4cmkGrVDc6wxtwR6E9HbEiS3H9qVHzPF7OGyzZ2Q@mail.gmail.com>
 <7d4a921ac2594ecf83944eb594cbfe97@GBDCVPEXC08.corp.lgc-group.com>
Message-ID: <CAF8bMcYxu+iuKyDZeYbtczimd+1nGBO-VjbTjkv9Va-eBnUhKw@mail.gmail.com>

Precedence is a property of the parser and has nothing to do with the
semantics assigned to various symbols.  Using just core R functions you can
see the precedence of '?' is between those of '=' and '<-'.

> # '=' has lower precedence than '?'
> str(as.list(parse(text="a ? b = c")[[1]]))
List of 3
 $ : symbol =
 $ : language `?`(a, b)
 $ : symbol c
> str(as.list(parse(text="a = b ? c")[[1]]))
List of 3
 $ : symbol =
 $ : symbol a
 $ : language `?`(b, c)
> # '<-' has higher precedence than '?'
> str(as.list(parse(text="a ? b <- c")[[1]]))
List of 3
 $ : symbol ?
 $ : symbol a
 $ : language b <- c
> str(as.list(parse(text="a <- b ? c")[[1]]))
List of 3
 $ : symbol ?
 $ : language a <- b
 $ : symbol c

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Fri, Aug 30, 2019 at 4:41 AM Stephen Ellison <S.Ellison at lgcgroup.com>
wrote:

> > From: R-devel [mailto:r-devel-bounces at r-project.org] On Behalf Of Ant F
> > Sent: 29 August 2019 12:06
> > To: r-devel at r-project.org
> > Subject: [Rd] ?Syntax wrong about `?`'s precedence ?
> > ...
> > See the following example :
> >
> >     `?` <- `+`
>
> I'm curious; What did you expect to happen if you replace the function '?'
> with the operator '+' ?
> ? is surely now being evaluated as a user-defined function and not as an
> operator.
> Would you expect the results of doing that to be the same as evaluation
> without replacement?
>
> S Ellison
>
>
>
>
> *******************************************************************
> This email and any attachments are confidential. Any u...{{dropped:10}}



[Rd] ?Syntax wrong about `?`'s precedence ?
William Dunlap