2008-02-15
| 00:18 | scramflot | Thanks Chouser |
| 00:39 | Chouser | jh06 you probably defined user/if, and then ended up calling clojure/if |
| 00:40 | Chouser | or maybe it's because the built if isn't a macro |
| 00:41 | Chouser | er, I mean isn't a function |
| 00:41 | Chouser | (defmacro if [a b] `(+ ~a ~b)) |
| 00:41 | Chouser | (if 5 6) |
| 00:41 | Chouser | => 11 |
| 03:39 | bgeron | huh? |
| 09:04 | Chouser | jh06 was trying to redefine "if", so I demonstrated by using defmacro. |
| 09:05 | rhickey | I strongly discourage trying to redefine if, what's the objective? |
| 09:29 | Chouser | heh, yeah, I would tend to agree. I don't know why jh06 thought he wanted to. |
| 11:14 | rhickey | as of rev 675: |
| 11:14 | rhickey | user=> (map #(* 2 %) [1 2 3]) |
| 11:14 | rhickey | (2 4 6) |
| 11:14 | rhickey | user=> (map #(* 2 %1 %2) [1 2 3] [4 5 6]) |
| 11:14 | rhickey | (8 20 36) |
| 11:15 | rhickey | user=> (map #(/ 1 %) [1 2 3 4]) |
| 11:15 | rhickey | (1 1/2 1/3 1/4) |
| 11:15 | rhickey | user=> (quote #(foo % %2 (bar %&))) |
| 11:15 | rhickey | (fn* [p1__764 p2__765 & rest__766] (foo p1__764 p2__765 (bar rest__766))) |
| 11:16 | rhickey | i.e. anonymous function and arg reader syntax |
| 11:17 | Chouser | ok! |
| 11:18 | Chouser | care to share your thoughts on the choice of syntax? |
| 11:18 | Chouser | # and % specifically, I suppose. |
| 11:19 | rhickey | # usually designates reader magic |
| 11:19 | rhickey | % is from printf :) |
| 11:20 | rhickey | I like the similar capability in Mathematica |
| 11:20 | Chouser | looks good to me. |
| 11:20 | Chouser | handles multiple args much more nicely than arc's [ ... _ ... ] |
| 11:21 | rhickey | does arc handle multiple args? |
| 11:21 | Chouser | And presumabely handles multiple refs to the same arg better than Scala's ( ... _ ... ) |
| 11:21 | Chouser | as far as I know, arc's syntax only works to produce a single-arg function. |
| 11:22 | Chouser | pretty much exactly as yours if you couldn't put a number after % |
| 11:23 | rhickey | I have & too for rest args |
| 11:23 | rhickey | %& |
| 11:23 | Chouser | I suppose they could extend arc to allow [ * 2 _1 _2 ] |
| 11:23 | Chouser | yep, I saw that. Complete. I like. |
| 11:24 | Chouser | May I ask how you have time to work on clojure? |
| 11:24 | rhickey | No |
| 11:24 | rhickey | :) |
| 11:24 | rhickey | It's a question I avoid myself |
| 11:24 | Chouser | well, I don't need to. I'd rather have clojure than an answer to that question. :-) |
| 11:29 | Chouser | beautiful. |
| 15:10 | Chouser | rhickey: do you use a Mac? |
| 15:11 | rhickey | yup |
| 15:29 | Chouser | Ah! Well, that explains it. |
| 15:29 | Chouser | No, I'm totally kidding. I just noticed a path starting with "/User" in a .clj file. |
| 15:56 | bgeron | fortunately we have version control to save the error, long after we corrected it |
| 15:56 | bgeron | well, /me sleep, bye |
| 16:15 | ffailla | netjure |
| 16:16 | Chouser | "Did you mean: nature" |
| 16:18 | ffailla | sorry wrong irc |
| 16:22 | Chouser | :-) |
| 17:30 | ericthorsen | rich, what is the dispatch char for the named arg function feature? |
| 17:30 | rhickey | # |
| 17:30 | rhickey | #( |
| 17:30 | rhickey | (map #(* 2 %) [1 2 3]) |
| 17:30 | rhickey | -> (2 4 6) |
| 17:31 | ericthorsen | too easy :) thanks |
| 19:38 | ericthor | rich, what do i need to do to get an intellJ run config to see the boot.clj? (not really a clojure question) |
| 20:23 | rhickey | put -cp clojure.jar on the VM parameters, on before launch uncheck make, check run ant target jar |
| 20:24 | ericthor | i was halfway there |
| 20:44 | ericthor | I have a couple of questions on the java var binding. Is this a good place to ask them? |
| 20:45 | rhickey | sure |
| 20:45 | ericthor | clojure=>(in-ns 'fred) |
| 20:45 | ericthor | java.lang.IllegalStateException: Can't change/establish root binding of: *ns* with set |
| 20:45 | ericthor | at clojure.lang.Var.set(Var.java:140) |
| 20:45 | ericthor | at clojure.lang.RT$1.invoke(RT.java:136) |
| 20:45 | ericthor | at clojure.lang.AFn.applyToHelper(Unknown Source) |
| 20:45 | ericthor | at clojure.lang.AFn.applyTo(Unknown Source) |
| 20:45 | ericthor | at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2245) |
| 20:45 | ericthor | at clojure.lang.Compiler.eval(Compiler.java:3204) |
| 20:45 | ericthor | at beansclojure.ClojureEvaluator.run(ClojureEvaluator.java:73) |
| 20:45 | ericthor | at java.lang.Thread.run(Thread.java:613) |
| 20:45 | ericthor | you need more..1 sec |
| 20:46 | ericthor | this is how I'm binding to the current namespace var from outside |
| 20:46 | ericthor | final static Var CURRENT_NS = Var.intern(CLOJURE_NS, Symbol.create("*ns*"), |
| 20:46 | ericthor | CLOJURE_NS); |
| 20:48 | ericthor | Prior to starting the repl loop I'm calling the same functions for pushing the thread bindings, then calling what appears to be the same init code and I'm getting that message... |
| 20:48 | rhickey | If you are going to change *ns* it will have to be on a thread in which you've bound it with pushtrhreadbindings as does repl |
| 20:48 | ericthor | Is this the correct way to bind into the clojure vars? |
| 20:48 | ericthor | that's it |
| 20:49 | rhickey | you should call RT.inNamespace.invoke as does repl |
| 20:49 | rhickey | rather than directly manipulating *ns* |
| 20:49 | ericthor | not visible |
| 20:50 | ericthor | tried that |
| 20:50 | ericthor | can that change? |
| 20:50 | ericthor | :) |
| 20:51 | rhickey | you can make your own mapping to the same var Var.intern(CLOJURE_NS, Symbol.create("in-ns")) |
| 20:51 | rhickey | that's true of all vars, you don't need the actual static member vars of Clojure's runtime |
| 20:52 | ericthor | i did that as well....but i was not using the same thread to make the change as when the binding were put on...let me correct that |
| 21:11 | ericthor | does the TR.init() call also need to be on the same thread? |
| 21:11 | ericthor | RT.init() |
| 21:13 | rhickey | no - that's a one shot that loads boot.clj from the jar. It must be run before using the rest of Clojure |
| 21:13 | ericthor | ok |
| 22:27 | ericthor | to create a var i can reference between java and clojure: |
| 22:27 | ericthor | Var WARN_ON_REFLECTION = Var.intern(CLOJURE_NS, Symbol.create("*warn-on-reflection*")); |
| 22:27 | ericthor | where the name-space would be a user different namespace, etc. |
| 22:28 | ericthor | Var.intern(Namespace.findOrCreate(Symbol.create("eric"),Symbol.create("*dyn-var*)) |
| 22:29 | rhickey | yes |
| 22:30 | ericthor | i'm making progress...you'll be up for a few more hours yes? |
| 22:30 | rhickey | nope |
| 22:30 | ericthor | i think i will...fun stuff |
| 22:52 | jonathan__ | what are you building eric? |
| 23:18 | ericthor | tools!!! |