#clojure log - Nov 23 2014

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:00 rritoch: I'm looking for a way to develop and modify classes at runtime, would this be possible if I were to create macros to generate deftypes with a given name to provide specific default functionality, and then use defprotocol + extend-type to add class specific functionality?

0:01 Basically I'm trying to get around the fact that deftype doesn't seem to provide a way to extend a class.

0:02 I know reify does, but these need to be named classes so I can have multiple instances floating around

0:13 technomancy: https://twitter.com/apontious/status/536355219622211584

0:14 sdegutis: Compojure's destructuring syntax conveniently allows for params to be either keywords or strings, literally expanding to (get-in [req :params] :foo (get-in [req :params] "foo"))

0:15 I was not aware of this.

0:20 kenrestivo: rritoch: when i found myself in such straits, i ended up using gen-class

0:21 then i went AAAAH!! why am i trying to write java in clojure! and ended up dropping the project.

0:25 rritoch: kenrestivo: Yeah, I'm trying to get away from gen-class because I want something that can be modified at runtime

0:25 Right now I'm just toying with all of the possiblities

0:25 I think I may have finally come up with a viable solution though

0:25 kenrestivo: rritoch: http://github.com/llasram/shady

0:26 tho i think that is compile-time not runtime

0:26 rritoch: The core of my problem is simply that clojure doesn't provide namespace inheritance

0:27 But I just had the idea that maybe I can get around that issue by providing the "parent" functions which take the namespace as the first argument

0:27 So instead of -parentMethod ... I'd just call a regular function (foo (find-ns 'some-ns) ....)

0:27 kenrestivo: i don't know what problem you are trying to solve, but there might be a way to rethink it to be more functional and idiomatically clojure-y.

0:28 rritoch: kenrestivo: I'm trying to take a gen-class based MVC library and change it so it can be modified at runtime

0:29 ex. https://github.com/rritoch/clj-grid-mvc/blob/master/src/com/vnetpublishing/clj/grid/lib/mvc/base/module.clj

0:29 There's a lot of complexity in there that I'd like to keep out of sight

0:30 But I'm thinking now that I can probaly get around this mess, intead of using inheritance, just make functions that take a namespace as the first argument, to apply whatever functionality is needed to the provided namespace.

0:31 kenrestivo: a kind of a shot in the dark, but this might help: https://github.com/ztellman/scrawl/tree/master/src/scrawl

0:31 as an example of how to take something very OOP'ish and java-ish and make it more functional and idiomatic, in three steps.

0:55 brainproxy: in the sample.project.clj for the cljx library, org.clojure/clojurescript is listed under :dev :plugins

0:56 is that right?

1:10 yguan: Get a question on vector: get a value vector like [a1 a2 ... a3] and index [ 3 9 .. 876], how can I get a new vector filled with value correponding to those indexes? like keep-index?

1:13 rritoch: ,(mapv (partial get ["A" "B" "C"]) [2 0 1])

1:13 clojurebot: ["C" "A" "B"]

1:13 rritoch: yguan: Like that?

1:15 yguan: rritoch: nice! never notice there is mapv... thanks

1:30 amalloy: rritoch: (partial get [x y z]) is just the same as [x y z]: vectors are functions

1:31 rritoch: ,(mapv ["A" "B" "C"] [2 0 1])

1:31 clojurebot: ["C" "A" "B"]

1:31 rritoch: amalloy: Cool, didn't know that

Logging service provided by n01se.net