dgkf / R

An experimental reimagining of R
https://dgkf.github.io/R
GNU General Public License v3.0
135 stars 6 forks source link

Fall cleaning pass ideas :fallen_leaf: :broom: #170

Open dgkf opened 1 month ago

dgkf commented 1 month ago

Just documenting a few cleanup ideas to give an opportunity for input before I embark on a few cleanup passes:

dgkf commented 1 month ago

In the spirit of honing the scope of a few distinct crates, I'd like to explore decoupling the parsing from the evaluation a bit more consciously.

This is almost decoupled, but is tethered just a bit by the Expr::Primitive variant, which contains boxed references to actual functions. I'm exploring whether it's worth separating these steps so that the actual look-up of the primitive only happens upon evaluation, not during parsing.

Instead of

Expr::Call(Expr::Primitive(Box<InfixAdd>), ...)

We'd have

Expr::Call(CallKind::Infix, Expr::Symbol("+"), ...)

This would allow us to expose the parser to derive macros to declare the formal arguments in a proc macro instead of an inline macro.

dgkf commented 4 weeks ago

This design would be more difficult to deal with using things like Rs do.call - specifically for [ and ( if they’re being repurposed as vector and list constructor syntax.

In do.call, should they call the constructor or the indexing function?

To avoid this, I’m considering a design that looks like Julia’s juxtapose “function”, as a mechanism of differentiating these while still using simple S-expression like representations.