Message-ID: <a0428ec90901221323vc3c617k43a1c88e7cd7a84f@mail.gmail.com>
Date: 2009-01-22T21:23:48Z
From: Yi Zhang
Subject: how to get a primitive function object
In-Reply-To: <4978E266.3090805@idi.ntnu.no>
On Thu, Jan 22, 2009 at 4:17 PM, Wacek Kusnierczyk
<Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
> Duncan Murdoch wrote:
>> On 1/22/2009 2:41 PM, Yi Zhang wrote:
>>> Hi,
>>>
>>> I want to create an alias for the "<-" function and then later
>>> overwrite it. Any idea how I can get the "<-" function object? I know
>>> for other functions it's easy, something like "f <- seq" will do; how
>>> really no clue for this one. Thanks!
>>
>> get("<-") will give it to you, and
>>
>> `<-` <- function(x, y) cat("x=", x, "y=", y, "\n")
>>
>> will change it -- and will probably be the last effective thing you do
>> in that session, unless you're really careful:
>>
>> > x <- 1
>> > x
>> [1] 1
>> > `<-` <- function(x, y) cat("x=", x, "y=", y, "\n")
>> > x <- 3
>> x= 1 y= 3
>> > x
>> [1] 1
>> > # now what?? &%#*
>
> now you are really motivated to use '=' instead of '<-':
>
> x = 3
> x
> # 3
>
> vQ
>
Thanks. That certainly is an option. But I want to preserve `<-`'s
functionality because I'm writing a package and I don't want to limit
the package user's freedom to use `<-`...
--
Yi