futureverse / marshal

[PROTOTYPE] R package: marshal - Framework to Marshal Objects to be Used in Another R Processes
https://marshal.futureverse.org/
Other
15 stars 1 forks source link

DESIGN: Save package (versions) instead of unmarshal function #11

Open sebffischer opened 7 months ago

sebffischer commented 7 months ago

I think it might be an idea to replace the default marshal() implementation by not storing the unmarshal function in the marshalled object, but instead by saving the required package (versions). I.e. I am talking about this line here: https://github.com/HenrikBengtsson/marshal/blob/72e976c61f00861ceb0b4c0c0fd7016b4eee417a/R/marshal.default.R#L30

This would mean, that instead of only having to implement the marshal.<class> method, one would have to implement. marshal.<class> and unmarshal.<class>. The unmarshal generic could then verify that the packages required to unmarshal the object are loaded (including the package that contains the unmarshal generic) before dispatching onto the method.

The advantages of this approach would be:

The disadvantages would be: