From murdoch at stats.uwo.ca  Sun Feb 21 20:54:38 2010
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Sun, 21 Feb 2010 14:54:38 -0500
Subject: [Rd] Problem with ?Syntax
In-Reply-To: <4B8170F2.5050707@stats.uwo.ca>
References: <971536df1002200152p7d583e1cv416cd06afe865d55@mail.gmail.com>	<d8ad40b51002200357x667008fan5bb069864af3b102@mail.gmail.com>	<971536df1002200407w2d5bedc6q5e74ff92e9787570@mail.gmail.com>
	<4B8170F2.5050707@stats.uwo.ca>
Message-ID: <4B818F7E.3020202@stats.uwo.ca>

On 21/02/2010 12:44 PM, Duncan Murdoch wrote:
> Gabor Grothendieck wrote:
>> I wasn't claiming there was an ambiguity but it does not perform
>> according to the operator precedence documented in ?Syntax .  If it
>> performed as documented it would give an error.
>>   
> 
> There are a few other errors in that page, e.g. saying that [ has 
> greater priority than ::, but
> 
> version <- 1:10
> base::version[1]
> 
> shows :: has higher priority.   I'll take a look.

Actually, just one error.  The indexing operators were shown with higher 
priority than they should have.  Because ::, :::, $ and @ can only take 
a name or a string constant on the right, they effectively have higher 
priority than [ or [[.  I've clarified the man page.

Duncan Murdoch

> 
> Duncan Murdoch
>> On Sat, Feb 20, 2010 at 6:57 AM, Barry Rowlingson
>> <b.rowlingson at lancaster.ac.uk> wrote:
>>   
>>> On Sat, Feb 20, 2010 at 9:52 AM, Gabor Grothendieck
>>> <ggrothendieck at gmail.com> wrote:
>>>     
>>>> In ?Syntax [ is given as higher priority than $ but BOD$demand[3]
>>>> seems to be the same as (BOD$demand)[3] contrary to [ being higher
>>>> priority.
>>>>
>>>>       
>>>>> BOD$demand[3]
>>>>>         
>>>> [1] 19
>>>>       
>>>>> (BOD$demand)[3]
>>>>>         
>>>> [1] 19
>>>>
>>>> What is the rule being used here?
>>>>       
>>>  I think its the parser rule that defines the syntax of $ on a list. Does:
>>>
>>>  BOD$(demand[3]) even work?
>>>
>>>     
>>>> BOD$(demand[3])
>>>>       
>>> Error: unexpected '(' in "BOD$("
>>>
>>>  - no. The parser sees a $ and then gets the next token (gram.y shows
>>> this to be a symbol or a string constant) as the thing to deal with.
>>> Symbols  I can't think of an example where $ and [ could have
>>> ambiguous precedence that is syntactically correct, so maybe the order
>>> is irrelevant...
>>>
>>>  Just for fun:
>>>
>>>     
>>>> x=list(a=1,b=2)
>>>> x$"a[1]"=2
>>>> x$"a[1]"
>>>>       
>>> [1] 2
>>>     
>>>> x$a[1]
>>>>       
>>> [1] 1
>>>
>>>
>>> Barry
>>>
>>>     
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Problem with ?Syntax
Duncan Murdoch