Looking at the source code for R, I see things like this:
int R_has_slot(SEXP obj, SEXP name) {
#define R_SLOT_INIT \
if(!(isSymbol(name) || (isString(name) && LENGTH(name) == 1))) \
error(_("invalid type or length for slot name")); \
if(!s_dot_Data) \
init_slot_handling(); \
if(isString(name)) name = installChar(STRING_ELT(name, 0))
R_SLOT_INIT;
if(name == s_dot_Data && TYPEOF(obj) != S4SXP)
return(1);
return(getAttrib(obj, name) != R_NilValue);
}
Which, I suppose, implies that you could drag it with getAttrib.
So, today I found out that S4 slots are actually only special attributes, and these attributes are available with @. Note:
> setClass("Foo", list(apple = "numeric"))
> foo <- new("Foo", apple = 1)
> foo@apple
[1] 1
> attributes(foo)
$apple
[1] 1
$class
[1] "Foo"
attr(,"package")
[1] ".GlobalEnv"
> foo@class
[1] "Foo"
attr(,"package")
[1] ".GlobalEnv"
> attr(foo, "bar") <- 2
> foo@bar
[1] 2
Hope this gives you a place to start, at least.