From wdunlap at tibco.com  Fri Mar 13 20:19:15 2009
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 13 Mar 2009 12:19:15 -0700
Subject: [Rd] surprising behaviour of names<-
In-Reply-To: <49BAA8E6.3080407@idi.ntnu.no>
References: <49B67CB1.8060005@idi.ntnu.no>	<49B682F9.8050307@biostat.ku.dk>	<49B6E6D9.7010809@idi.ntnu.no>	<96A4BB14-D6EA-44B1-B524-6DB139F3A7F8@r-project.org>	<8CCAAAD3-919F-462F-A616-F4FDDB46D975@r-project.org>	<49B81186.4070107@idi.ntnu.no>	<20090312154008.56706f38@berwin-nus1>	<49B8D060.8090206@idi.ntnu.no>	<20090312173231.7a2929df@berwin-nus1>	<49B8DB8F.5030704@idi.ntnu.no>	<20090312213508.719afa73@berwin5>	<49B91A7E.50107@idi.ntnu.no>	<20090312231240.6a061f0b@berwin5>	<49B96FE7.2060705@idi.ntnu.no>	<20090313120309.7acb13e5@berwin-nus1>	<49BA38EB.3000004@idi.ntnu.no><20090313234755.6f6e08c9@berwin5>
	<49BAA8E6.3080407@idi.ntnu.no>
Message-ID: <77EB52C6DD32BA4D87471DCD70C8D700DF10EE@NA-PA-VBE03.na.tibco.com>

Would it make anyone any happier if the manual said
that the replacement functions should not be called
in the form
   xNew <- `func<-` (xOld, value)
and should only be used as
   func(xToBeChanged) <- value
? 

The explanation
      names(x) <- c("a","b")
  is equivalent to
      '*tmp*' <- x
      x <- "names<-"('*tmp*', value=c("a","b"))
could also be extended a bit, adding a line like
      rm(`*tmp*`)
Those 3 lines should be considered an atomic operation:
the value that `*tmp*` or `x` may have or what is
in the symbol table at various points in that sequence 
is not defined.  (Letting details be explicitly undefined
is important: it gives developers room to improve the
efficiency of the interpreter and tells users where not to go.) 


Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Wacek Kusnierczyk
> Sent: Friday, March 13, 2009 11:42 AM
> To: Berwin A Turlach
> Cc: r-devel at r-project.org List
> Subject: Re: [Rd] surprising behaviour of names<-
> ... blah blah blah
> >>     x = 1
> >>     tmp = x
> >>     x = 'names<-'(tmp, 'foo')
> >>     names(tmp)
> >>     # NULL



[Rd] surprising behaviour of names<-
William Dunlap