Re: [Rd] surprising behaviour of names<-

2009-03-16 Thread Wacek Kusnierczyk
Thomas Lumley wrote: > > Wacek, > > In this case I think the *tmp* dates from the days before backticks, > when it was not a legal name (it still isn't) and it was much, much > harder to use illegal names, so the collision issue really didn't exist. > thanks for the explanation. > You're right ab

Re: [Rd] surprising behaviour of names<-

2009-03-16 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > >> '*tmp*' = 0 >> `*tmp*` >> # 0 >> >> x = 1 >> names(x) = 'foo' >> `*tmp*` >> # error: object "*tmp*" not found >> >> `*ugly*` >> > > I agree, and I am a bit flabbergasted. I had not expected that > something like this would happen and I am indeed not aware of anyth

Re: [Rd] surprising behaviour of names<-

2009-03-16 Thread Thomas Lumley
Wacek, In this case I think the *tmp* dates from the days before backticks, when it was not a legal name (it still isn't) and it was much, much harder to use illegal names, so the collision issue really didn't exist. You're right about the documentation. -thomas On Sun, 15 Mar 2009,

Re: [Rd] surprising behaviour of names<-

2009-03-15 Thread Berwin A Turlach
G'day Wacek, On Sun, 15 Mar 2009 21:01:33 +0100 Wacek Kusnierczyk wrote: > Berwin A Turlach wrote: > > > > Obviously, assuming that R really executes > > *tmp* <- x > > x <- "names<-"('*tmp*', value=c("a","b")) > > under the hood, in the C code, then *tmp* does not end up in the > > sym

Re: [Rd] surprising behaviour of names<-

2009-03-15 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > > Obviously, assuming that R really executes > *tmp* <- x > x <- "names<-"('*tmp*', value=c("a","b")) > under the hood, in the C code, then *tmp* does not end up in the symbol > table and does not persist beyond the execution of > names(x) <- c("a","b")

Re: [Rd] surprising behaviour of names<-

2009-03-14 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > On Sat, 14 Mar 2009 07:22:34 +0100 > Wacek Kusnierczyk wrote: > > [...] > >>> Well, I don't see any new object created in my workspace after >>> x <- 4 >>> names(x) <- "foo" >>> Do you? >>> >>> >> of course not. that's why i'd say the two above are *

Re: [Rd] surprising behaviour of names<-

2009-03-14 Thread Berwin A Turlach
On Sat, 14 Mar 2009 07:22:34 +0100 Wacek Kusnierczyk wrote: [...] > > Well, I don't see any new object created in my workspace after > > x <- 4 > > names(x) <- "foo" > > Do you? > > > > of course not. that's why i'd say the two above are *not* > equivalent. > > i haven't noticed th

Re: [Rd] surprising behaviour of names<-

2009-03-14 Thread Thomas Lumley
On Fri, 13 Mar 2009, William Dunlap wrote: 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 ? That was my reaction, too. The discussion

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > On Fri, 13 Mar 2009 19:41:42 +0100 > Wacek Kusnierczyk wrote: > > > >> indeed, you said "R supposedly uses call-by-value (though we know how >> to circumvent that, don't we?)". >> >> in that vain, R supposedly can be used to do valid statistical >> computations (though

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Berwin A Turlach
On Fri, 13 Mar 2009 19:41:42 +0100 Wacek Kusnierczyk wrote: > > Glad to see that we agree on this. > > > > owe you a beer. O.k., if we ever meet is is first your shout and then mine. > >> haven't objected to that. i object to your 'r uses pass by value', > >> which is only partially corre

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Wacek Kusnierczyk
Tony Plate wrote: > Wacek Kusnierczyk wrote: >> Tony Plate wrote: >> >>> Is there anything incorrect or missing in the help page for normal >>> usage of the replacement function for 'names'? (i.e., when used in an >>> expression like 'names(x) <- ...') >>> >> >> what is missing here in the

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Tony Plate
Wacek Kusnierczyk wrote: Tony Plate wrote: Wacek Kusnierczyk wrote: [snip] i just can't get it why the manual does not manifestly explain what 'names<-' does, and leaves you doing the guesswork you suggest. I'm having trouble understanding the point of this discussion. Someo

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Wacek Kusnierczyk
Tony Plate wrote: > Wacek Kusnierczyk wrote: >> [snip] >> i just can't get it why the manual does not manifestly explain what >> 'names<-' does, and leaves you doing the guesswork you suggest. >> >> > I'm having trouble understanding the point of this discussion. > Someone is calling a replacem

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Wacek Kusnierczyk
William Dunlap wrote: > 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 > surely better than guesswork. > ? > > The explana

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Tony Plate
Wacek Kusnierczyk wrote: [snip] i just can't get it why the manual does not manifestly explain what 'names<-' does, and leaves you doing the guesswork you suggest. I'm having trouble understanding the point of this discussion. Someone is calling a replacement function in a way that it's not

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread William Dunlap
ion wdunlap tibco.com > -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Wacek Kusnierczyk > Sent: Friday, March 13, 2009 11:42 AM > To: Berwin A Turlach > Cc: r-devel@r-project.org List > Subject: Re: [Rd] surpr

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > >> sure! >> > > Glad to see that we agree on this. > owe you a beer. > >>> Read section 2.1.10 ("Environments") in the R >>> Language Definition, >>> >> haven't objected to that. i object to your 'r uses pass by value', >> which is only partially corr

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Berwin A Turlach
On Fri, 13 Mar 2009 11:43:55 +0100 Wacek Kusnierczyk wrote: > Berwin A Turlach wrote: > > > And it is documented behaviour. > > sure! Glad to see that we agree on this. > > Read section 2.1.10 ("Environments") in the R > > Language Definition, > > haven't objected to that. i object to you

Re: [Rd] surprising behaviour of names<-

2009-03-13 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > >> foo = function(arg) arg$foo = foo >> >> e = new.env() >> foo(e) >> e$foo >> >> are you sure this is pass by value? >> > > But that is what environments are for, aren't they? might be. > And it is > documented behaviour. sure! > Read s

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Berwin A Turlach
On Thu, 12 Mar 2009 21:26:15 +0100 Wacek Kusnierczyk wrote: > > YMMV, but when I read a passage like this in R documentation, I > > start to wonder why it is stated that > > names(x) <- c("a","b") > > is equivalent to > > *tmp* <- x > > x <- "names<-"('*tmp*', value=c("a","b")) > >

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
G. Jay Kerns wrote: > Wacek Kusnierczyk wrote: > > > > I am prompted to imagine someone pointing out to the volunteers of the > International Red Cross - on the field of a natural disaster, no less > - that their uniforms are not an acceptably consistent shade of > pink... or that the screws on

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Josh Ulrich
On Thu, Mar 12, 2009 at 3:24 PM, G. Jay Kerns wrote: > Wacek Kusnierczyk wrote: > > [snip] > >> as i explained a few months ago, i study r to find examples of bad >> design.  if anyone in the r core is interested in having the problems i >> report fixed, i'm happy to get involved in a discussion a

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Simon Urbanek wrote: > > On Mar 12, 2009, at 11:12 , Wacek Kusnierczyk wrote: > >> Simon Urbanek wrote: >>> >>> On Mar 11, 2009, at 10:52 , Simon Urbanek wrote: >>> Wacek, Peter gave you a full answer explaining it very well. If you really want to be able to trace each instance

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > On Thu, 12 Mar 2009 15:21:50 +0100 > Wacek Kusnierczyk wrote: > > >> seems to suggest? is not the purpose of documentation to clearly, >> ideally beyond any doubt, specify what is to be specified? >> > > The R Language Definition manual is still a draft. :) >

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread G. Jay Kerns
Wacek Kusnierczyk wrote: [snip] > as i explained a few months ago, i study r to find examples of bad > design. if anyone in the r core is interested in having the problems i > report fixed, i'm happy to get involved in a discussion about the design > and implementation. if not, i'm happy with j

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Simon Urbanek
On Mar 12, 2009, at 11:12 , Wacek Kusnierczyk wrote: Simon Urbanek wrote: On Mar 11, 2009, at 10:52 , Simon Urbanek wrote: Wacek, Peter gave you a full answer explaining it very well. If you really want to be able to trace each instance yourself, you have to learn far more about R internal

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Berwin A Turlach
On Thu, 12 Mar 2009 15:21:50 +0100 Wacek Kusnierczyk wrote: [...] > >>> And the R Language manual (ignoring for the moment that it is a > >>> draft and all that), > >>> > >> since we must... > >> > >> > >>> clearly states that > >>> > >>> names(x) <- c("a","b") > >>> > >>> is e

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Simon Urbanek wrote: > > On Mar 11, 2009, at 10:52 , Simon Urbanek wrote: > >> Wacek, >> >> Peter gave you a full answer explaining it very well. If you really >> want to be able to trace each instance yourself, you have to learn >> far more about R internals than you apparently know (and Peter hin

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: > Berwin A Turlach wrote: > > >> This is similar to the discussion what value i should have in the >> following C snippet: >> i = 0; >> i += i++; >> >> > > > in fact, your example is useless because the result here is clearly > specified by the semantic

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > On Thu, 12 Mar 2009 10:53:19 +0100 > Wacek Kusnierczyk wrote: > > >> well, ?'names<-' says: >> >> " >> Value: >> For 'names<-', the updated object. >> " >> >> which is only partially correct, in that the value will sometimes be >> an updated *copy* of the object.

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Berwin A Turlach
On Thu, 12 Mar 2009 10:53:19 +0100 Wacek Kusnierczyk wrote: > well, ?'names<-' says: > > " > Value: > For 'names<-', the updated object. > " > > which is only partially correct, in that the value will sometimes be > an updated *copy* of the object. But since R supposedly uses call-by-val

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > > Whoever said that must have been at that moment not as precise as he or > she could have been. Also, R does not behave according to what people > say on this list (which is good, because some times people they wrong > things on this list) but according to how it is docu

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Berwin A Turlach
On Thu, 12 Mar 2009 10:05:36 +0100 Wacek Kusnierczyk wrote: > well, as far as i remember, it has been said on this list that in r > the infix syntax is equivalent to the prefix syntax, [...] Whoever said that must have been at that moment not as precise as he or she could have been. Also, R doe

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Wacek Kusnierczyk wrote: > > is precisely why i'd think that the prefix 'names<-' should never do > destructive modifications, because that's what x = 'names<-'(x, 'foo'), > and thus also names(x) = 'foo', is for. > > to make the point differently, i'd expect the following two to be equivalent:

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > On Wed, 11 Mar 2009 20:29:14 +0100 > Wacek Kusnierczyk wrote: > > >> Simon Urbanek wrote: >> >>> Wacek, >>> >>> Peter gave you a full answer explaining it very well. If you really >>> want to be able to trace each instance yourself, you have to learn >>> far more

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: > On Wed, 11 Mar 2009 20:31:18 +0100 > Wacek Kusnierczyk wrote: > > >> Simon Urbanek wrote: >> >>> On Mar 11, 2009, at 10:52 , Simon Urbanek wrote: >>> >>> Wacek, Peter gave you a full answer explaining it very well. If you really want to

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Berwin A Turlach
On Wed, 11 Mar 2009 20:29:14 +0100 Wacek Kusnierczyk wrote: > Simon Urbanek wrote: > > Wacek, > > > > Peter gave you a full answer explaining it very well. If you really > > want to be able to trace each instance yourself, you have to learn > > far more about R internals than you apparently know

Re: [Rd] surprising behaviour of names<-

2009-03-12 Thread Berwin A Turlach
On Wed, 11 Mar 2009 20:31:18 +0100 Wacek Kusnierczyk wrote: > Simon Urbanek wrote: > > > > On Mar 11, 2009, at 10:52 , Simon Urbanek wrote: > > > >> Wacek, > >> > >> Peter gave you a full answer explaining it very well. If you really > >> want to be able to trace each instance yourself, you have

Re: [Rd] surprising behaviour of names<-

2009-03-11 Thread Wacek Kusnierczyk
Simon Urbanek wrote: > > On Mar 11, 2009, at 10:52 , Simon Urbanek wrote: > >> Wacek, >> >> Peter gave you a full answer explaining it very well. If you really >> want to be able to trace each instance yourself, you have to learn >> far more about R internals than you apparently know (and Peter hin

Re: [Rd] surprising behaviour of names<-

2009-03-11 Thread Wacek Kusnierczyk
Simon Urbanek wrote: > Wacek, > > Peter gave you a full answer explaining it very well. If you really > want to be able to trace each instance yourself, you have to learn far > more about R internals than you apparently know (and Peter hinted at > that). Internally x=1 an x=c(1) are slightly differ

Re: [Rd] surprising behaviour of names<-

2009-03-11 Thread Simon Urbanek
On Mar 11, 2009, at 10:52 , Simon Urbanek wrote: Wacek, Peter gave you a full answer explaining it very well. If you really want to be able to trace each instance yourself, you have to learn far more about R internals than you apparently know (and Peter hinted at that). Internally x=1 an

Re: [Rd] surprising behaviour of names<-

2009-03-11 Thread Simon Urbanek
Wacek, Peter gave you a full answer explaining it very well. If you really want to be able to trace each instance yourself, you have to learn far more about R internals than you apparently know (and Peter hinted at that). Internally x=1 an x=c(1) are slightly different in that the former

Re: [Rd] surprising behaviour of names<-

2009-03-10 Thread Wacek Kusnierczyk
i got an offline response saying that my original post may have not been clear as to what the problem was, essentially, and that i may need to restate it in words, in addition to code. the problem is: the performance of 'names<-' is incoherent, in that in some situations it acts in a functional m

Re: [Rd] surprising behaviour of names<-

2009-03-10 Thread Wacek Kusnierczyk
Peter Dalgaard wrote: > > (*) unless you mess with match.call() or substitute() and the like. But > that's a different story. > different or not, it is a story that happens quite often -- too often, perhaps -- to the degree that one may be tempted to say that the semantics of argument passing i

Re: [Rd] surprising behaviour of names<-

2009-03-10 Thread Wacek Kusnierczyk
Stavros Macrakis wrote: >>> (B) you cannot (easily) predict whether or not x will be modified >>> destructively >>> >> that's fine, thanks, but i must be terribly stupid as i do not see how >> this explains the examples above. where is the x used by something else >> in the first example, s

Re: [Rd] surprising behaviour of names<-

2009-03-10 Thread Stavros Macrakis
>> (B) you cannot (easily) predict whether or not x will be modified >> destructively > > that's fine, thanks, but i must be terribly stupid as i do not see how > this explains the examples above.  where is the x used by something else > in the first example, so that 'names<-'(x, 'foo') does *not*

Re: [Rd] surprising behaviour of names<-

2009-03-10 Thread Wacek Kusnierczyk
Peter Dalgaard wrote: > Wacek Kusnierczyk wrote: > >> playing with 'names<-', i observed the following: >> >> x = 1 >> names(x) >> # NULL >> 'names<-'(x, 'foo') >> # c(foo=1) >> names(x) >> # NULL >> >> where 'names<-' has a functional flavour (does not change x),

Re: [Rd] surprising behaviour of names<-

2009-03-10 Thread Peter Dalgaard
Wacek Kusnierczyk wrote: > playing with 'names<-', i observed the following: > > x = 1 > names(x) > # NULL > 'names<-'(x, 'foo') > # c(foo=1) > names(x) > # NULL > > where 'names<-' has a functional flavour (does not change x), but: > > x = 1:2 > names(x) >

[Rd] surprising behaviour of names<-

2009-03-10 Thread Wacek Kusnierczyk
playing with 'names<-', i observed the following: x = 1 names(x) # NULL 'names<-'(x, 'foo') # c(foo=1) names(x) # NULL where 'names<-' has a functional flavour (does not change x), but: x = 1:2 names(x) # NULL 'names<-'(x, 'foo') # c(foo=1, 2)