From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Mon Mar 16 09:16:34 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Mon, 16 Mar 2009 09:16:34 +0100
Subject: [Rd] surprising behaviour of names<-
In-Reply-To: <20090316102625.1d93ded4@berwin-nus1>
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>	<49BD5E9D.1030601@idi.ntnu.no>
	<20090316102625.1d93ded4@berwin-nus1>
Message-ID: <49BE0AE2.1020909@idi.ntnu.no>

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 anything
> in the documentation that warns about this; but others may prove me
> wrong on this.
>   

hopefully.

>   
>> given that `*tmp*`is a perfectly legal (though some would say
>> 'non-standard') name, it would be good if somewhere here a warning
>> were issued -- perhaps where i assign to `*tmp*`, because `*tmp*` is
>> not just any non-standard name, but one that is 'obviously' used
>> under the hood to perform black magic.
>>     
>
> Now I wonder whether there are any other objects (with non-standard)
> names) that can be nuked by operations performed under the hood.  
>   

any such risk should be clearly documented, if not with a warning issued
each time the user risks h{is,er} workspace corrupted by the under-the-hood.


> I guess the best thing is to stay away from non-standard names, if only
> to save the typing of back-ticks. :)
>   

agree.  but then, there may be -- and probably are -- other such 'best
to stay away' things in r, all of which should be documented so that a
user know what may happen on the surface, *without* having to peek under
the hood.


> Thanks for letting me know, I have learned something new today.
>   

wow.  most of my fiercely truculent ranting is meant to point out things
that may not be intentional, or if they are, they seem to me design
flaws rather than features -- so that either i learn that i am ignorant
or wrong, or someone else does, pro bono.  hopefully.

vQ



[Rd] surprising behaviour of names<-
Wacek Kusnierczyk