architecture

mathpunk 2018-04-18T02:52:24.000120Z

hey, architects--- I'm trying to design an API, and my first idea isn't compatible with spec. Can anyone suggest alternatives? https://clojurians.slack.com/archives/C1B1BB2Q3/p1523995746000171?thread_ts=1523995746.000171&cid=C1B1BB2Q3

mathpunk 2018-04-18T02:56:25.000006Z

Facts about the domain: - every simplex is a special case of a complex, but there are complexes that are not simplexes - the Java library I'm wrapping understands only integer vertices, so I want to have implementations that map arbitrary non-collection data to integer vertices - users might want to provide their own implementations, to shortcut certain naive approaches that are exponential time

mathpunk 2018-04-18T02:58:31.000066Z

I want to use many specs to add value to the Java library, but the way I've gone about this, I'm trying to spec protocol functions which is not actually possible

mathpunk 2018-04-18T02:59:45.000021Z

There is a suggestion to use wrapper functions --- I only sort of know what that means, but I'll be meditating on it

2018-04-18T17:51:33.000027Z

I would push back on "isn't compatible with spec" spec has a lot of different parts, and some parts don't work well protocol functions

2018-04-18T17:53:11.000136Z

something like (assert (valid? `dim dim)) would likely work

john 2018-04-18T17:54:41.000599Z

The "wrapper function" thing just means (defn make-frobber [] (let [init-val 123] (Frobber. init-val))) or some such

john 2018-04-18T17:54:56.000278Z

so the things you'd normally do in a constructor, you do in make-frobber

john 2018-04-18T17:55:24.000122Z

(... if I understood your 'wrapper' comment correctly)

john 2018-04-18T17:57:33.000291Z

oh my bad, I thought your reference to wrapper fns were about another conversation in another room...

john 2018-04-18T17:58:46.000680Z

So, wrt wrapping a protocol fn... Wouldn't that just mean defining a top level function that calls the protocol fn on the object passed in? And then instrument that?

alexmiller 2018-04-18T18:02:11.000305Z

for me, I don’t think that’s worth doing - I would just not spec the protocol functions

alexmiller 2018-04-18T18:02:36.000330Z

it’s ok not to spec everything :)

mathpunk 2018-04-18T18:53:19.000582Z

heh! well, I definitely want to make topological data analysis more accessible, and I supposed that defining invariants at that level would help. however I also have a math-tendency to make things more general than is needed for the problem. Still working on coding with good taste!