The puzzle is accessing elements of a list in the object's "pseudo-slot".
That's successful using 2 out of 4 approaches one might try:
setClass("TempA", contains="list")
A = new("TempA", list(a=1,b=2))
A
Just printing A does not show the list names.
## An object of class "TempA"
## [[1]]
## [1] 1
##
## [[2]]
## [1] 2
Nevertheless, you can extract the elements by name.
A[["b"]]
## [1] 2
And names() extracts the names.
names(A)
## [1] "a" "b"
But there are no names here in the pseudo-slot.
A@.Data
## [[1]]
## [1] 1
##
## [[2]]
## [1] 2
So where are the names hiding, if not in the pseudo-slot itself?
The plot thickens. My goal is to subclass (to add some slots; not shown here). But if we subclass, even the two successful approaches above now fail. The list's names are apparently nowhere.
setClass("TempB", contains="TempA")
B = new("TempB", list(a=1,b=2))
names(B) ## no names.
## NULL
B[["b"]] ## NULL
## NULL
Here's a different approach. Does this do it? Nope.
B2 = new("TempB", new("TempA", list(a=1,b=2)))
B2[["a"]] # NULL
## NULL
names(B2) # NULL
## NULL
names(as(B2, "TempA")) ## still no dice
## NULL
In summary, when the pseudo-slot is a named list, trying to view or use those names is successful for only 2 out of 4 obvious approaches, and zero out of the 4 after subclassing. Working around the problem is not the issue; that's pretty easy. (Though I'd like to know how to write an accessor for a TempB object using the names.) I just want to understand.