Skip to content
Prev 7435 / 12125 Next

[R-pkg-devel] Lists vs Attributes

On 01/10/2021 6:14 p.m., Reed A. Cartwright wrote:
Is the object like some other common R object?  You say it's a 16x16x16 
array of integers.  Is there an advantage to treating it *exactly* like 
that, so x[1,2,3] gives an integer?  Then put the other stuff in attributes.

Is it weird enough that x[1,2,3] *needs* to look at the other attributes 
to know what to return?  Does it never make sense to do regular 
operations on the object, as though it really was 16x16x16 array of 
integers?  Then make it a list of different components, and spend the 
time to define methods to handle any operations that do make sense.

Both approaches are possible; you want to choose the one that is 
easiest, and most maintainable.

Duncan Murdoch