Is it possible to create a custom callable object in R?
Specifically, I'm interested in creating an object that behaves like a function (can be called with parentheses), but that has additional metadata attached:
To take a simple example:
my_callable <- not_a_function() # ??? my_callable() #> "Hello world (or something)" my_callable$doc #> "This object does a thing"
I was thinking about possibly subclassing
I suspect that this kind of pattern is deeply non-idiomatic; I'm interested in the question primarily from the persepective of understanding the language better.