Re: First post: how to mimic a Java List with types?

2020-08-15 Thread Erik Assum
Why not tease things apart? (defn eval [x] ...) (some eval my-list) ;; or list (every? eval my-list) ;; and list https://clojuredocs.org/clojure.core/some https://clojuredocs.org/clojure.core/every_q Now, you can make the eval function polymorphic in several ways, simplest is to case or cond o

Re: First post: how to mimic a Java List with types?

2020-08-15 Thread Jack Park
Hi Erik, I think that teasing things apart helps along some dimensions, but the problem I face, still thinking like a Java hacker, is that I need to put things together: I need to construct a *type* (deftype) which honors two different interfaces, a list, and an evaluable object. I need the type

Re: First post: how to mimic a Java List with types?

2020-08-15 Thread Brandon R
Hey Jack, Just been a fly on the wall for this convo, and aside from offering a specific solution, which others have done, I'm pretty certain this can be done with just protocols and records. Make a record (like your type) that implements the two protocols (like your interfaces). You could achieve

Re: First post: how to mimic a Java List with types?

2020-08-15 Thread Jack Park
Brandon! That just might be the idea I needed. Thank you. Film at 11... On Sat, Aug 15, 2020 at 2:28 PM Brandon R wrote: > Hey Jack, > > Just been a fly on the wall for this convo, and aside from offering a > specific solution, which others have done, I'm pretty certain this can be > done with

Re: First post: how to mimic a Java List with types?

2020-08-15 Thread Jack Park
My first attempt at using records (showing my ignorance here) is found in this gist https://gist.github.com/KnowledgeGarden/0f6ce01ed9300d4f9bd0ee0c61e3d91b It fails with this error (which doesn't give very good google) Syntax error macroexpanding clojure.core/defn at (cljtest/core.clj:123:1). >