farrellm / scad-clj

OpenSCAD DSL in Clojure
Eclipse Public License 1.0
318 stars 51 forks source link

Support for additional offset() parameters #40

Closed veikman closed 5 years ago

veikman commented 5 years ago

The current offset function supports only one of the three parameters that OpenSCAD can use, and it does so in numeric form. This PR adds support for additional parameters on the pattern of other functions already in scad-clj, using a map of keyword arguments in place of the old number.

I have preserved support for the numeric-only call signature and I have not marked it as deprecated. However, I propose that it should be formally deprecated and eventually removed (in v1.0.0) to control cyclomatic complexity.

farrellm commented 5 years ago

Good catch. I like the change, though the implementation seems a bit more complicated than necessary. I'll merge the PR as a do appreciate the tests, but I'll probably rewrite it a bit.

veikman commented 5 years ago

Sounds like a good plan. I went with the verbose version because it would be easier to add a formal deprecation warning to it. Here’s a terse version.

(defn offset [opt & block] `(:offset ~(if (map? opt) opt {:r opt}) ~@block))