From renaud at mancala.cbio.uct.ac.za  Mon Jun 27 09:17:23 2011
From: renaud at mancala.cbio.uct.ac.za (Renaud Gaujoux)
Date: Mon, 27 Jun 2011 09:17:23 +0200
Subject: [Rd] Class not found when search in .onLoad
In-Reply-To: <4E04EDB1.70105@r-project.org>
References: <4E0321DE.2020601@cbio.uct.ac.za> <4E036D6E.3000509@r-project.org>
	<4E044276.1070002@cbio.uct.ac.za> <4E04EDB1.70105@r-project.org>
Message-ID: <4E082E83.3060204@cbio.uct.ac.za>


On 24/06/2011 22:04, John Chambers wrote:
>
> Strictly speaking, that is not meaningful.  A class (like any R 
> object) is uniquely referenced by a name *and an environment*.  The 
> name of a package can be used to construct the environment, but your 
> "character slot" won't identify a class reliably unless the character 
> string has a "package" attribute.
>
> Look at class(x), for example, from an object from one of these 
> classes.  It will have a "package" attribute identifying the package.
> The character string with the package attribute is what you should be 
> storing in the slot (or else store the class definition---takes more 
> space but is slightly more efficient).
>

Thank you for this clarification, I will make my factory method for the 
relevant class add the package attribute to the slot.
Storing the class would require recreating the object if the user makes 
changes in the class definition. These objects are meant to be used when 
developing new algorithms. In this context one expects the user to do 
multiple tries and modifications, and I want to ease the process, by 
using dynamic links to classes (a character slot) rather than static 
links (result of getClass).

However, this does not explain why .onLoad does not find the class while 
.onAttach finds it, does it?
Is .onLoad evaluated outside the namespace environment, while .onAttach 
is evaluated within the namespace?

Thank you.
Renaud

 

###
UNIVERSITY OF CAPE TOWN 

This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}}



[Rd] Class not found when search in .onLoad
Renaud Gaujoux