Re: [R] how to get a primitive function object

2009-01-23 Thread Patrick Burns
If I understand properly, you want '-' to be a generic function, which it currently isn't. There may be a way to fake that (I can't think of any). But I'm wondering if you should rethink what you want. The only reason that I can think of that you would want to change '-' is because of some

Re: [R] how to get a primitive function object

2009-01-23 Thread Duncan Murdoch
Wacek Kusnierczyk wrote: Duncan Murdoch wrote: You can use parent.frame() as the pos or envir argument to assign(), and then the assignment happens in the caller's frame. And assign() is also another way out if you overwrite - with something that doesn't work; just call it to reassign

Re: [R] how to get a primitive function object

2009-01-23 Thread Wacek Kusnierczyk
Duncan Murdoch wrote: Wacek Kusnierczyk wrote: Duncan Murdoch wrote: You can use parent.frame() as the pos or envir argument to assign(), and then the assignment happens in the caller's frame. And assign() is also another way out if you overwrite - with something that doesn't work; just

Re: [R] how to get a primitive function object

2009-01-23 Thread Yi Zhang
On Fri, Jan 23, 2009 at 5:15 AM, Patrick Burns pbu...@pburns.seanet.com wrote: If I understand properly, you want '-' to be a generic function, which it currently isn't. There may be a way to fake that (I can't think of any). But I'm wondering if you should rethink what you want. The only

Re: [R] how to get a primitive function object

2009-01-23 Thread Yi Zhang
On Fri, Jan 23, 2009 at 9:40 AM, Wacek Kusnierczyk waclaw.marcin.kusnierc...@idi.ntnu.no wrote: you might want to specify what 'completely unrecoverable' means, and what approaches are allowed. for the former, i guess that: - 'incompletely recoverable' means that there is at least one

Re: [R] how to get a primitive function object

2009-01-23 Thread Duncan Murdoch
On 1/23/2009 1:47 PM, Yi Zhang wrote: On Fri, Jan 23, 2009 at 5:15 AM, Patrick Burns pbu...@pburns.seanet.com wrote: If I understand properly, you want '-' to be a generic function, which it currently isn't. There may be a way to fake that (I can't think of any). But I'm wondering if you

Re: [R] how to get a primitive function object

2009-01-23 Thread Yi Zhang
On Fri, Jan 23, 2009 at 2:50 PM, Duncan Murdoch murd...@stats.uwo.ca wrote: External pointers are the standard way to do that. You don't need to worry about reference counting, R's garbage collector will call a finalizer when it doesn't need the object any more. I think the usual example of

[R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
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! __

Re: [R] how to get a primitive function object

2009-01-22 Thread Henrique Dallazuanna
Is there many functions: See: grep(-, ls(package:base), value = TRUE) For 'substring-': type `substring-` in R On Thu, Jan 22, 2009 at 5:41 PM, Yi Zhang yizhan...@gmail.com wrote: Hi, I want to create an alias for the - function and then later overwrite it. Any idea how I can get the -

Re: [R] how to get a primitive function object

2009-01-22 Thread Duncan Murdoch
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

Re: [R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
On Thu, Jan 22, 2009 at 3:06 PM, Duncan Murdoch murd...@stats.uwo.ca wrote: 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 `-`

Re: [R] how to get a primitive function object

2009-01-22 Thread Wacek Kusnierczyk
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.

Re: [R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
On Thu, Jan 22, 2009 at 4:17 PM, Wacek Kusnierczyk waclaw.marcin.kusnierc...@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

Re: [R] how to get a primitive function object

2009-01-22 Thread Wacek Kusnierczyk
Yi Zhang wrote: # 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

Re: [R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
i was sort-of joking, though it's a real option if you want it. but seriously, there's no reason for the %#* lamenting: x - 1 '-' = function(x,y) 0 x - 2 # 0 .Primitive('-')(x,2) x # 2 base::'-'(x, 3) x # 3 base::'-'('-', base::'-') x - 4 x # 4 vQ I'm still not sure if

Re: [R] how to get a primitive function object

2009-01-22 Thread Duncan Murdoch
On 22/01/2009 4:50 PM, Yi Zhang wrote: i was sort-of joking, though it's a real option if you want it. but seriously, there's no reason for the %#* lamenting: x - 1 '-' = function(x,y) 0 x - 2 # 0 .Primitive('-')(x,2) x # 2 base::'-'(x, 3) x # 3 base::'-'('-', base::'-') x - 4 x # 4 vQ

Re: [R] how to get a primitive function object

2009-01-22 Thread Wacek Kusnierczyk
Duncan Murdoch wrote: You can use parent.frame() as the pos or envir argument to assign(), and then the assignment happens in the caller's frame. And assign() is also another way out if you overwrite - with something that doesn't work; just call it to reassign base::`-` to it. Or just