scicloj / wolframite

An interface between Clojure and Wolfram Language (the language of Mathematica)
https://scicloj.github.io/wolframite/
Mozilla Public License 2.0
56 stars 2 forks source link

[Improvement] Convert directly into Expr instead of using the Loopback Link; support arrays #60

Closed holyjak closed 4 months ago

holyjak commented 4 months ago

Issue: We have asked JLink to convert things into Expr via the Loopback Link where we could well have done it ourselves. It seems wasteful, and is perhaps clearer when we do it ourselves. This applies especially to primitive types (numbers, String) and cases where we ended up with a list of Expr that wasn't a function call.

Fix: 1. Extend proto/expr with non-seq input to simply pass it on to new Expr, so that anything it supports will be expressionified. Cons: we fall back on reflection here (though we could explicitly check the type and cast to it, but what's the pro?). 2. if every sub-part of a list an Expr, construct manually a Wolf List.

Bonus: Added support for passing in primitive Java arrays of numbers (so far only 1D).

Risk: All tests pass, but this changes how we convert from Clj to Expr, and it may have changed something I am unaware of.

holyjak commented 4 months ago

Draft, as this is based off #58 and needs to be rebased on main when that one is merged.

light-matters commented 4 months ago

Hasn't caused any problems that I've noticed.