This repository has been archived by the owner on May 21, 2021. It is now read-only.
Should I greatly simplify the structure of the package? #3
jeanmathieupotvin
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context
Reflecting over the code I wrote for version 9002, I believe I am overkilling a simple problem. What I seek is a general interface to efficiently spawn and share schemas (or blueprints here) without having to generate the object itself. Building on that idea, the intent is to develop a couple of nice features to serialize, validate, and generate these schemas.
Here is an example of what I am seeking. Say we export only one class
Schema
. That class is instantiated through a call to$new()
. Then, we could typically write something like below.Example one: recursive list-like objects
This is nice beacause (1) it is simple and (2) it's fast. Moreover, since we are passing a function to the
constructor
slot, we can use this constructor as a callback function in the code whenever needed. From it, we can also detect a couple of interesting features.From these simple calls, we can extract the definition of the constructor, where it is located, and how to call it if needed. Therefore, we could build a built-in package manager into the
Schema
class. Someone could call something likemySchema$installModules()
and automatically set-up itsR
environment for future work. Why? Because we can detect whether the underlying namespace is installed or not. Easy work.Example two: environments
Not as hard as someone could think. We simply embed calls to
Schema$new()
. BecauseR
is currently dominated by stupid pipes, we could even make that thing work with the%>%
operator and define whole environments just with just oneSchema
. This is attractive.The exact method of breaking this recursive structure into a flat one so that it works nicely with pipes remains to be determined. But this is not a hard problem. Should we consider overloading
+
instead to add schemas and bundle them into a bigger one?Example three: working with pipes to flatten recursive schemas
As highlighted above, the big question is how to efficiently name objects when using
%>%
. Could we only pass a name to...
? A character to optionalname
argument? Make a flexible$new()
constructor? Probably. To be determined.Beta Was this translation helpful? Give feedback.
All reactions