vetr
vetr copied to clipboard
Implement Variable Length Lists with `elist` and `vlist`
elist
(Extensible List, could be xlist
too) is an extensible list, where objects are accepted assuming that they have every element that is present in the template. This is supposed to mimic S4 objects where objects that inherit from another contain all the slots of the other. Some unresolved questions are whether the subset of elements must be first and in the same order as in the template, and whether named objects should be treated differently. In terms of implementation, elist
will probably produce and S4 object that will trigger special treatment.
One question is how we do something like structure(elist(...), attra, attrb)
etc. as then the return value of elist
can hardly be S4 as there could be conflicts between slots and attributes.
vlist
(Vector List) is a variable length list with the same template repeated n
times. TBD whether we allow a repetitions argument, or whether people should use a normal list template for those. Ideally the template would allow the same syntax present at the top level (i.e. use of template and evaluated tokens, etc.).
For these, the S4 template would keep the actual template as an object. Will need to measure overhead of using S4.