#clojure logs

2008-02-15

00:18scramflotThanks Chouser
00:39Chouserjh06 you probably defined user/if, and then ended up calling clojure/if
00:40Chouseror maybe it's because the built if isn't a macro
00:41Chouserer, I mean isn't a function
00:41Chouser(defmacro if [a b] `(+ ~a ~b))
00:41Chouser(if 5 6)
00:41Chouser=> 11
03:39bgeronhuh?
09:04Chouserjh06 was trying to redefine "if", so I demonstrated by using defmacro.
09:05rhickeyI strongly discourage trying to redefine if, what's the objective?
09:29Chouserheh, yeah, I would tend to agree. I don't know why jh06 thought he wanted to.
11:14rhickeyas of rev 675:
11:14rhickeyuser=> (map #(* 2 %) [1 2 3])
11:14rhickey(2 4 6)
11:14rhickeyuser=> (map #(* 2 %1 %2) [1 2 3] [4 5 6])
11:14rhickey(8 20 36)
11:15rhickeyuser=> (map #(/ 1 %) [1 2 3 4])
11:15rhickey(1 1/2 1/3 1/4)
11:15rhickeyuser=> (quote #(foo % %2 (bar %&)))
11:15rhickey(fn* [p1__764 p2__765 & rest__766] (foo p1__764 p2__765 (bar rest__766)))
11:16rhickeyi.e. anonymous function and arg reader syntax
11:17Chouserok!
11:18Chousercare to share your thoughts on the choice of syntax?
11:18Chouser# and % specifically, I suppose.
11:19rhickey# usually designates reader magic
11:19rhickey% is from printf :)
11:20rhickeyI like the similar capability in Mathematica
11:20Chouserlooks good to me.
11:20Chouserhandles multiple args much more nicely than arc's [ ... _ ... ]
11:21rhickeydoes arc handle multiple args?
11:21ChouserAnd presumabely handles multiple refs to the same arg better than Scala's ( ... _ ... )
11:21Chouseras far as I know, arc's syntax only works to produce a single-arg function.
11:22Chouserpretty much exactly as yours if you couldn't put a number after %
11:23rhickeyI have & too for rest args
11:23rhickey%&
11:23ChouserI suppose they could extend arc to allow [ * 2 _1 _2 ]
11:23Chouseryep, I saw that. Complete. I like.
11:24ChouserMay I ask how you have time to work on clojure?
11:24rhickeyNo
11:24rhickey:)
11:24rhickeyIt's a question I avoid myself
11:24Chouserwell, I don't need to. I'd rather have clojure than an answer to that question. :-)
11:29Chouserbeautiful.
15:10Chouserrhickey: do you use a Mac?
15:11rhickeyyup
15:29ChouserAh! Well, that explains it.
15:29ChouserNo, I'm totally kidding. I just noticed a path starting with "/User" in a .clj file.
15:56bgeronfortunately we have version control to save the error, long after we corrected it
15:56bgeronwell, /me sleep, bye
16:15ffaillanetjure
16:16Chouser"Did you mean: nature"
16:18ffaillasorry wrong irc
16:22Chouser:-)
17:30ericthorsenrich, what is the dispatch char for the named arg function feature?
17:30rhickey#
17:30rhickey#(
17:30rhickey(map #(* 2 %) [1 2 3])
17:30rhickey-> (2 4 6)
17:31ericthorsentoo easy :) thanks
19:38ericthorrich, what do i need to do to get an intellJ run config to see the boot.clj? (not really a clojure question)
20:23rhickeyput -cp clojure.jar on the VM parameters, on before launch uncheck make, check run ant target jar
20:24ericthori was halfway there
20:44ericthorI have a couple of questions on the java var binding. Is this a good place to ask them?
20:45rhickeysure
20:45ericthorclojure=>(in-ns 'fred)
20:45ericthorjava.lang.IllegalStateException: Can't change/establish root binding of: *ns* with set
20:45ericthor at clojure.lang.Var.set(Var.java:140)
20:45ericthor at clojure.lang.RT$1.invoke(RT.java:136)
20:45ericthor at clojure.lang.AFn.applyToHelper(Unknown Source)
20:45ericthor at clojure.lang.AFn.applyTo(Unknown Source)
20:45ericthor at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2245)
20:45ericthor at clojure.lang.Compiler.eval(Compiler.java:3204)
20:45ericthor at beansclojure.ClojureEvaluator.run(ClojureEvaluator.java:73)
20:45ericthor at java.lang.Thread.run(Thread.java:613)
20:45ericthoryou need more..1 sec
20:46ericthorthis is how I'm binding to the current namespace var from outside
20:46ericthor final static Var CURRENT_NS = Var.intern(CLOJURE_NS, Symbol.create("*ns*"),
20:46ericthor CLOJURE_NS);
20:48ericthorPrior 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:48rhickeyIf 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:48ericthorIs this the correct way to bind into the clojure vars?
20:48ericthorthat's it
20:49rhickeyyou should call RT.inNamespace.invoke as does repl
20:49rhickeyrather than directly manipulating *ns*
20:49ericthornot visible
20:50ericthortried that
20:50ericthorcan that change?
20:50ericthor:)
20:51rhickeyyou can make your own mapping to the same var Var.intern(CLOJURE_NS, Symbol.create("in-ns"))
20:51rhickeythat's true of all vars, you don't need the actual static member vars of Clojure's runtime
20:52ericthori 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:11ericthordoes the TR.init() call also need to be on the same thread?
21:11ericthorRT.init()
21:13rhickeyno - that's a one shot that loads boot.clj from the jar. It must be run before using the rest of Clojure
21:13ericthorok
22:27ericthorto create a var i can reference between java and clojure:
22:27ericthor Var WARN_ON_REFLECTION = Var.intern(CLOJURE_NS, Symbol.create("*warn-on-reflection*"));
22:27ericthorwhere the name-space would be a user different namespace, etc.
22:28ericthorVar.intern(Namespace.findOrCreate(Symbol.create("eric"),Symbol.create("*dyn-var*))
22:29rhickeyyes
22:30ericthori'm making progress...you'll be up for a few more hours yes?
22:30rhickeynope
22:30ericthori think i will...fun stuff
22:52jonathan__what are you building eric?
23:18ericthortools!!!