Thanks for the info.

I think I've tried that a while ago, but IIRCC, the problem was always 
that R won't let me create on object that would pass as a full grown 
NAMESPACE object.

 > foo <- function(x) print(x)
 > assignInNamespace(x="foo", value=foo, ns="testNS")
Fehler in loadNamespace(name) : there is no package called 'testNS'

I've looked into this briefly:
?asNamespace
?attachNamespace

But there are no examples, so I don't really know how to use them ;-)

Regards,
Janko

On 20.05.2011 10:45, Barry Rowlingson wrote:
> On Fri, May 20, 2011 at 9:16 AM, Janko Thyson
> <janko.thyson.rst...@googlemail.com>  wrote:
>
>> Yet, IMHO there will be more and more problems regarding this in the
>> future as the number of contributed packages keeps growing. I personally
>> would not mind at all to get used to typing 'thePackage::foo()' *all*
>> the time, or at least have this as an option. In principal, this is no
>> big deal once you actually *have* a true package with a namespace at
>> hand. But what about the process of creating a package? AFAU, there is
>> no way of "simulating/emulating" a namespace (which I understand is some
>> special form of environment?) in order to be able to use '::' when
>> creating/debugging functions that call other functions of the unfinished
>> package. If anyone has some ideas on that one, I would appreciate to hear.
>   there's some stuff in utils that might do it for you:
>
> Description:
>
>       Utility functions to access and replace the non-exported functions
>       in a name space, for use in developing packages with name spaces.
>
> Usage:
>
>       getFromNamespace(x, ns, pos = -1, envir = as.environment(pos))
>
>       assignInNamespace(x, value, ns, pos = -1,
>                         envir = as.environment(pos))
>
>       fixInNamespace(x, ns, pos = -1, envir = as.environment(pos), ...)
>
>
> See ?assignInNamespace for the full info.
>
> Personally, I like the python way of doing things like this, and
> dealing with name clashes. You can do:
>
>   import foo
>
> and then you do foo.bar(), foo.baz()
>
>   or
>
> from foo import bar
>
> then you can just do bar(). There's also:
>
> from foo import *
>
>   which lets you do bar(), baz(), but is frowned upon a bit because of
> possible name collisions. Or if you want to use functions with the
> same name from two packages you can do:
>
> from foo import bar as bar1
> from baz import bar as bar2
>
>   Then you can do bar1() and bar2()
>
>   Of course if you want to change anything in the bar package then
> similar hackery to the 'assignInNamespace' of R is necessary unless
> you want to rebuild the python package. Often called "Monkey
> patching", I think, although this possibly only refers to mucking with
> class objects and methods.
>
> Barry
>


-- 
------------------------------------------------------------------------

*Janko Thyson*
janko.thy...@googlemail.com <mailto:janko.thy...@googlemail.com>

Jesuitenstraße 3
D-85049 Ingolstadt

Mobile: +49 (0)176 83294257

This e-mail and any attachment is for authorized use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be
copied, disclosed to, retained or used by any other party.
If you are not an intended recipient then please promptly delete this
e-mail and any attachment and all copies and inform the sender.


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to