From dadler at uni-goettingen.de  Fri Dec 16 13:36:24 2011
From: dadler at uni-goettingen.de (Daniel Adler)
Date: Fri, 16 Dec 2011 13:36:24 +0100
Subject: [Rd] makeNamespace and rdyncall
Message-ID: <E176A8C3-6428-4AAA-9840-ACA09C314D26@uni-goettingen.de>

Dear R Core Team,

I have a question related to the programming interface for namespace object creation at run-time.

This is something that I need in the rdyncall package:
During the dynamic linkage binding of a shared C library, an R namespace object is created 
that gets populated with call wrappers, symbolic constants and type information objects. 

For example,

> dynport(SDL) # create namespace, populated with wrappers to SDL library 
> search()     # gives a "package:SDL" populated with all kinds of wrappers to the C functions, etc..
[1] ".GlobalEnv"        "package:SDL"  

I was trying various alternatives to get package-behaviour implemented in transparent manner for the end-user.

The current version uses real namespace environments with all sorts of advantages such as support for
search(), detach() and '::'.

Namespace object have certain conventions for fields, and there is currently no
public interface available in 'base' for setting up such objects;
The function "makeNamespace" in src/library/base/namespace.R is defined as local function to "loadNamespace".
So I go about this problem by 'copying' the code.

Recently, R-2.14 introduced a new mandatory field 'lazyData' which mades rdyncall broken.
(By re-synchronizing with 'makeNamespace' it has been fixed in 0.7.4.)

Would it be possible and feasible to make namespace-related management functions such as makeNamespace and sealNamespace
available as an public accessible interface? Or at least accessible via ':::' ?

I would also appreciate any hint/idea for alternative ways to implement the above described behaviour.

Here is the link to the code used for creation of dynamic C binding namespaces: http://dyncall.org/svn/dyncall/trunk/bindings/R/rdyncall/R/dynport.R

best wishes,
- Daniel



[Rd] makeNamespace and rdyncall
Daniel Adler