From sfalcon at fhcrc.org  Wed Feb  8 16:18:27 2006
From: sfalcon at fhcrc.org (Seth Falcon)
Date: Wed, 08 Feb 2006 07:18:27 -0800
Subject: [Rd] NAMESPACE Q: does import as exist?
In-Reply-To: <43E9DFBC.4090704@stats.uwo.ca> (Duncan Murdoch's message of "Wed,
	08 Feb 2006 07:10:36 -0500")
References: <D79013E40FEF254AAF0D72DFC94F274816B00B@extas4-hba.tas.csiro.au>
	<m2mzh2edjq.fsf@ziti.local> <43E9DFBC.4090704@stats.uwo.ca>
Message-ID: <m2lkwldgl8.fsf@ziti.local>

On  8 Feb 2006, murdoch at stats.uwo.ca wrote:
>>> in a NAMESPACE file. Useful-- yes. Possible-- I don't know!
>> Yes, this is along the lines of what I was thinking.  An unpleasant
>> work around would be to create a translation package
>> that does something along the lines of Duncan M.'s suggestion,
>> importing, renaming, exporting.
>
> Why do you call it unpleasant?  

Because other languages do this without defining an extra "package".
I don't think users should have to go to that length to resolve such
name issues.

> With the current mechanisms in R, that's probably what your
> ImportFromAs function would have to do.  There's no way to have two
> names referring to the same function.

Do you mean: there's no way to have one name referring to two
different functions?  

After looking over some of the namespace code, I think what I'm asking
for is possible (without creating extra packages).  E.g., attaching a
package with a NAMESPACE file looks like it will call
attachNamespace(), which creates an empty env on the search path and
then calls importIntoEnv() to fill it.  ImportIntoEnv() ends up in
do_importIntoEnv in envir.c.  The comment there is encouraging:

    /* This function copies values of variables from one environment
       to another environment, possibly with different names.
       Promises are not forced and active bindings are preserved. */

Am I on track here that this implies that it is possible to have an
importFromAs directive without change to the current underlying
mechanism and that only higher level additions would be needed (not to
say it would be easy).

Best,

+ seth



[Rd] NAMESPACE Q: does import as exist?
Seth Falcon