#clojure logs

2008-11-15

02:50bradbevis SVN for Clojure down right now?
02:56johnwaynerI'm not having any problems with it
02:59bradbevhmm
03:00bradbevapparently something to do with https
04:01Lau_of_DKTop of the morning gents
04:24Lau_of_DKAsking as a Java-noob, how difficult is it to load a .c/.h and drive it from my clojure code ??
07:27Chouserrhickey: what are the chances of getting duck-streams or something like it into core for 1.0?
07:30AWizzArdDuck streams? As in: "we stream everything for you"?
07:31Chouserclojure.contrib.duck-streams -- I'm not sure about the origin of the name, since it doesn't really use duck typing
09:27Lau_of_DKDoes Java search /usr/lib/* for .so files ?
09:28StartsWithKLau_of_DK: no
09:29Lau_of_DKWhere can I count on it StartsWithK , do you know?
09:29StartsWithKyou have to add -Djava.library.path
09:30StartsWithKmaybe it will search for .so files under java main installation tree, but i dont know that
09:31StartsWithKso if you use say jogl (opengl) and all gluegen and jogl files are under lib/ dir you will have to start clojure something like
09:31StartsWithKjava -Djava.library.path=lib -cp lib/jars-you-want clojure.lang.Repl
09:33Lau_of_DKIt was exactly jogl I was trying to install
09:34Lau_of_DKIt seems it autloads /usr/lib/jvm/java-6-sun-1.6.0.10/jre/lib/i386/
09:34StartsWithKunzip jogl in your lib dir, you should have gluegen jar and .so files too inside distribution
09:35blackdogLau_of_DK, do a search for JNA i think it's called on the clojur group
09:35StartsWithKand call it with java.library.path
09:35blackdogthere's an example of calliing native code
09:36StartsWithKblackdog: jna dosn't need any native so files to work
09:36StartsWithKjust a .jar for your target platform
09:36blackdogsorry i saw a question by Lau_of_DK earlier so i may not have the current context
09:37blackdogof this discussion
09:38Lau_of_DKblackdog, you were commenting on C integration ?
09:39blackdogyes
09:39Lau_of_DKoh okay, cool, thanks alot
09:39Lau_of_DKStartsWithK, whats this Gluegen ?
09:40StartsWithKits wrapper they created just for opengl, so i think jogl.jar is autocreated from c api
09:40blackdogLau_of_DK, http://groups.google.com/group/clojure/browse_thread/thread/77e626c5440bf1a0/487327209b633451?lnk=gst&q=jna#487327209b633451
09:40StartsWithKthats why GL class is one giant mess
09:40Lau_of_DKoh ok
09:40StartsWithKwith all C names
09:40StartsWithKLau_of_DK: http://pastebin.com/f4708ffa8 try this for your ant build
09:41Lau_of_DKCool
09:41StartsWithKi could't find a good way to use jogl with maven/ivy repositories
09:41Lau_of_DKStartsWithK, blackdog , thanks to the both of you
09:41StartsWithKso i have this snippet in my ant file
09:42Lau_of_DKand so that builds an executable jar ?
09:42StartsWithKno, it just downloads jogl.zip from java.net and copies file to my lib/ directory
09:43StartsWithKand in build.properties i can select platform and os i want to use
09:43Lau_of_DKok, Ive only ever used ant to build the clojure source
09:44StartsWithKit helps to eliminate external jars from your local revision system
09:45StartsWithKfor now i only have to keep clojure.jar, still no nice way to pull from svn in ant build
09:45Lau_of_DKWhere did you start out, to get comfy with jogl ?
09:45StartsWithKi started jogl wrapper
09:46StartsWithKand did gears demo, some examples from redbook and nehe tutorials
09:46StartsWithKthere is nehe (and redbook) port to java
09:47Lau_of_DKOh thats right
09:47StartsWithKi plan to rewrite jogl wrapper, it was when i started using clojure, first thing i did, so its realy bad :)
09:47Lau_of_DKI believe you actually posted all that in here in the early days of clojure?
09:47StartsWithKyes
09:49StartsWithKLau_of_DK: http://ksojat.net/repository/ repository from that time is here
09:50StartsWithKi don't think it works anymore, i integrated it with my main project, noone was using it anyway :)
10:10rhickey_svn 1104: added static main() support for AOT. Just defn main in your ns, will be applied to command line string args
10:17Chouserrhickey_: sweet. The only way to call that fn from the command line is after it's been AOT compiled, right?
10:17rhickey_Chouser: right
10:18rhickey_you should be able to jar up your Clojure app and invoke just as if it was a java app
10:18ChouserI wonder if there's any sensible way to make it callable when not pre-compiled.
10:19rhickey_Chouser: not sure what you mean
10:19rhickey_you can dynamically redefine main
10:19Chouserwell, I'm not sure either. Some parts of the clojurescript .clj are useful as a command-line app.
10:19blackdogrhickey, vcool, betting on the betting on clojure gets validated daily, thanks!
10:20rhickey_you could define a main which took as it's first arg the name of the sub-command
10:20rhickey_its
10:21kotarakeg. svn co
10:21ChouserCurrently I have the part that parses *command-line-args* in a separate main.clj, so you can run: java -cp ... clojure.lang.Script clojurescript/main.clj -- --help
10:21rhickey_it's fun because the main fn is applied - it can be overloaded on arity
10:22Chouserso it'd be nice to move main.clj into a defn main of the primary tojs.clj, but I'm not sure how to then call it without pre-compiling.
10:23ChouserI guess the odd thing is I'm trying to make a single .clj work both as a support library and as a command-line app.
10:23ChouserIt's not uncommon in Python, but maybe it doesn't work in Java-land.
10:23rhickey_Chouser: I don't see why not
10:24Chouserwell, when my tojs.clj loads, are the *command-line-args* for me or not?
10:26rhickey_seems like you shouldn't depend on them coming specifically from *command-line-args*
10:29Chouserok, so instead I can define a main fn to take the args. But then how can I call that from the command-line without pre-compiling?
10:30Chouseror are you saying a general convention of the first command-line arg specifying which .clj's main fn to call?
10:30rhickey_precompiling only puts the static void main in your .class file. If you defn main in a .clj it's there compiled or not
10:31rhickey_(your.ns/main ...) will work without precompilation
10:32Chouseryes, but how can I trigger that from the command line?
10:33ChouserAgain, one way would be to have a separate "main.clj" that just does (your.ns/main ...), and call it from the command-line like: java ...Script your/ns/main.clj
10:33rhickey_either you are running clojure.lang.Script or you are not, if you ar eyour script runs, if you end it with (when-not *compile-files* (apply main *command-line-args*)) that might work
10:35rhickey_I really don't understand the problem space, so I don't see the problem :(
10:36rhickey_you want to be able to say either java ... clojure.lang.Script my/app.clj -- args
10:36rhickey_or java my.app args
10:36rhickey_?
10:36kotarakDo I have to set that compile-path? I thought it would default to classes?
10:37Chouseryeah, Java's never concentrated on support command-line; one of its few weaknesses that Clojure doesn't address yet. I'll write it up for the g.group
10:37Chouserkotarak: it defaults to "./classes", so it's relative to your CWD when you start clojure.
10:38rhickey_kotarak: bound to classes only in the repl
10:38dudleyfIdeally, you shouldn't have to say 'java' anything
10:38kotarakAh. That's it.
10:38kotarakFor a script I use (binding)?
10:38rhickey_there are many java app packagers
10:38Chouserdudleyf: that's a separate issue
10:39rhickey_kotarak: yes, binding
10:39kotarakrhickey_: thanks. :)
10:39dudleyfChouser: I thought you were talking about command line invocations
10:39kotarakI was looking for to AOT. Just porting my projects. :)
10:40ChouserI already have a "clj" shell script that works pretty well for me, but I think I need more hooks from the outside.
10:40dudleyfChouser: So do I, I think that's one of the problems ;-)
10:41Chouserhm, though perhaps I could use a java property or something hm...
10:43rhickey_what's wrong with (when-not *compile-files* (apply main *command-line-args*))
10:43rhickey_?
10:44rhickey_a defmain macro could both defn main and emit that, just put at end of script
10:44ChouserI also want to be able to (require my.ns) inside some other app.
10:45ChouserIn that case, whether it's being compiled or not isn't the issue. I need to know if my ns is being invoked directly or not, similar to how a Java class can be "invoked" thus calling it's main() method.
10:45rhickey_Chouser: ah
10:46kotarakSorry, me again: what does that mean? Exception in thread "main" java.lang.reflect.InvocationTargetException (clojurecheck.clj:23)
10:46Chouserpython does this with something like: if __this__ == __main__: ...
10:46Chouserkotarak: you have an error on line 23 of clojurecheck.clj :-)
10:47kotarakChouser: in code which worked perfectly before.
10:47kotarakThe code looks like this: (defn todo* [body] (binding [*some-var* special-val] (body)))
10:48Chouserkotarak: defn? not a macro? so body must be an IFn
10:49kotarak(defmacro todo [& body] `(todo* (fn [] ~@body)))
10:50kotarakThis happens while compile, btw.
10:50rhickey_kotarak: got more stack trace?
10:50kotarakSure. just a sec.
10:50rhickey_where'd the lisp paste bot go?
10:51Chouserlisp paste site wasn't even pasting right yesterday
10:52Lau_of_DKClomacs should include built-in pasting to #clojure :)
10:53Chouseryeah, still not pasting.
10:55kotarakYes. paste.lisp.org seems halfway broken, but w/o channel it worked: http://paste.lisp.org/display/70434
10:57rhickey_kotarak: your compile path must be in your classpath
10:57kotarakIt should be. But will cross-check.
11:00rhickey_I've been thinking about removing that restriction, as so many people trip over it. What happens now is the classes you compile are loaded back from disk, a nice double-check. Without this restriction, I could just load from bytecode already in memory, but wouldn't be accessible as high up in the classloader hierarchy
11:00Lau_of_DKShouldnt that just be optional ?
11:01rhickey_No, I think it should work one way
11:01kotarakHmm... I had a symbolic link to the "compile" directory. But obviously the master .class from the master .clj is missing. So I suppose this was the problem. Setting it explicitely with env during the compile fixed the problem.
11:02Lau_of_DKrhickey, it seems a little like a waste of ressources to write to disk and then read it again, if you dont need it higher up, I would happily deselect that feature
11:03rhickey_every option doubles complexity
11:03Lau_of_DKk
11:04AWizzArdrhickey_: would it be possible to offer an (disassemble function)?
11:05rhickey_AWizzArd: I've left that part of ASM out of the Clojure build, for size reasons
11:06AWizzArdSize reasons? To make Clojure more available for cell phones and fridges?
11:07rhickey_cell phones are an important target Clojure still doesn't quite make yet
11:08rhickey_phone people have complained about the 450k size
11:09AWizzArduh
11:10rhickey_But I admit it might be a false economy. If using stock ASM, could pull out of Clojure entirely, would become a jar dependency though...
11:10AWizzArddo they know it's nearly 2009? And that mobile phones come with several mb ram?
11:10Lau_of_DKI would suggest a clojure and a clojure-light, but that would probably quadrouple complexity
11:24leafwI would suggest waiting a year, when cell phones multiply their memory and it's no longer an issue at all.
11:25leafwno need to complicate matters.
11:42johnwaynerAnyone else run into a "Var com.johnwayner.world/main is unbound" error when attempting to invoke main from the command line?
11:43johnwaynerI've defn'd main and there's a world$main__2644.class file in my classpath (along with the other fns for that ns)
11:45AWizzArdrhickey_: is there some version number or timestamp compiled into Clojure, so that one can see that one definitly is using the newest version?
11:46kotarakAWizzArd: http://groups.google.com/group/clojure/browse_thread/thread/9fa07b00c88280fc
11:48rhickey_johnwayner: fixing now, hang tight
11:49johnwaynerrhickey_: sweet.
11:58AWizzArdIs it possible to run the newest version of Clojure inside NetBeans? Or is there a a clojure.jar hard encoded inside the Enclojure plugin?
12:00rhickey_AWizzArd: try #enclojure
12:08rhickey_johnwayner: fixed - try rev 1105
12:09jgracinhow do I create byte[] in Clojure? is it (make-array Byte x)?
12:10rhickey_user=> Byte
12:10rhickey_java.lang.Byte
12:10rhickey_user=> Byte/TYPE
12:10rhickey_byte
12:11jgracinrhickey: thanks!
12:11rhickey_all the primitive types can be found the same way
12:23johnwaynerrhickey_: fixed, thanks!
12:24rhickey_johnwayner: great!
12:25johnwaynerrhickey_: I suppose it's also expected behaviour that the jvm doesn't shut down after main returns?
12:26rhickey_johnwayner: depends on your app - my hello world test does
12:27johnwaynerrhickey_: hmmm Perhaps I have running threads
12:27johnwaynerrhickey_: I'll explore more.
12:34danleihow can i interrupt a long-taking computation in slime? slime-interrupt doesn't seem to work for me, when C-c in clj suffices.
12:40Lau_of_DKdanlei, I would like to know that also! :)
12:41Lau_of_DKYou can always do a nasty work-around, but getting C-c C-c to work would be nice
12:42danleiwhat kind of workaround do you have in mind, besides C-c C-c in the inferior lisp buffer?
12:42Lau_of_DKI dont know. If I have threads running computations, my only escape is to have them throw exceptions
12:44danlei(set x (range 333333333333333333))
12:44Lau_of_DKhehe
12:45danlei=)
12:45AWizzArdjust give it some time, and it will finish
12:45Lau_of_DKhaha, AWizzArd didnt you give the same advice to rhickey regarding the clojure cell-phone variant ?
12:46AWizzArdhmm, I don't think so
12:46danleiAWizzArd: that would be the stoic solution, yes
12:47Lau_of_DKAWizzArd, youre right, that was leafw
13:35abeI have very limited lisp experiance and i have a beginer macro problem.
13:37abei want to doseq in my macro and i cant get the computer bind to a counter without throwing an error
13:37abeam i being clear?
13:37abeand is anybody actually here?
13:37Chousukeare you using old style binding or new style binding? :)
13:37Chousukedoseq changed a while ago
13:38Chousukeas of revision 1089 it takes a vector
13:38abeoh...i have no idea what revision i am using
13:38Chousukedid you get it form SVN?
13:38Chousukefrom*
13:38abenah
13:39Chousukethen it's probably fairly old
13:39Chousukethere have been a lot of interesting changes recently
13:40abethink i should download from the svn?
13:40Chousukeprobably.
13:40abeok well i will do that later
13:40Chousukeif you use slime you'll need a newer clojure-swank too
13:41abei havent even set up a real development environment. i'm really just browsing
13:42abebut the body of my macro looks like this
13:42abe `(do (doseq ~i ~args (~tprint ~i)) (~f ~@args))))
13:43abeits just to print the arguments of a fncall out before it executes
13:43Chouserwhere's i coming from?
13:43abethis is the whole jobbe
13:43abe (defmacro debug [f & args]
13:43abe (let [tprint #(do (print %) (print ":"))]
13:43abe `(do (doseq ~i ~args (~tprint ~i)) (~f ~@args))))
13:43Chousukehttp://groups.google.com/group/clojure/browse_thread/thread/8618a1d93cbbf8b7# here's a list of recent breaking changes
13:44Chouserabe: ~i will evaluate the expression i -- I assume that's what the error is about?
13:45abeyeah
13:45abehow can i just get some sort of dummy in there to bind
13:45Chouserbecause i is not defined. Try giving it a value -- (let [i (gensym)] `(do ...))
13:46Chouseror as a short-cut, replace all ~i with i#
13:51abei am confused because (doseq i [1 2 3] (print i)) works
13:51Chouserabe: yes, but notice that there you've replaced ~args with [1 2 3], but ~i with i
13:52abeahhhh thank you
13:54Chousukeabe: that form will stop working with the newer version :) it's now (doseq [i [1 2 3]] (print i))
14:05ndhi! I get latest version of clojure from svn, build it and have errors running slime:
14:05nd(clojure/require (quote swank))
14:05ndjava.lang.Exception: No such namespace: clojure (NO_SOURCE_FILE:3)
14:05nduser=>
14:05nd(swank/ignore-protocol-version "2008-11-02")
14:05ndjava.lang.Exception: No such namespace: swank (NO_SOURCE_FILE:5)
14:05nduser=>
14:05nd(swank/start-server "/tmp/slime.5462" :encoding "iso-latin-1-unix")
14:05ndjava.lang.Exception: No such namespace: swank (NO_SOURCE_FILE:7)
14:05nd
14:05ndI also update clojure swank-clojure, but it doesn't help.. What should I do to make it work again?
14:06Chousukewhat instructions suggest using (clojure/require 'swank) :/
14:06Chousukemy settings don't have that, and they work.
14:06Chouserrhickey_: My opinion (whatever that's worth) is that current behavior of compile regarding "./classes" should remain. You'd need your classpath to correct eventually anyway, I think it's currently less confusing than it would be otherwise.
14:07Chousukend: use these settings: http://en.wikibooks.org/wiki/Clojure_Programming#Emacs_.2F_Slime_Integration
14:07ndChousuke: thanks, I'll try it
14:09drewrnd: The latest swank works with the latest Clojure. Make sure you've loaded everything. Restart Emacs, perhaps.
14:23ndit seems that i forget to update something, update all again, and now it's work. thanks
14:26drewrTrying out main support. What am I missing?
14:26drewr(defn main [& args] (println (str "args: " args)))
14:27drewrCalling that from a file on the command line.
14:27drewr(ns foo.bar) is before that.
14:27rhickey_drewr: what svn rev?
14:28drewrrhickey_: 1105
14:28rhickey_what happens?
14:28drewrNo output.
14:28drewrNo errors.
14:29drewrRunning with "java -cp clojure.jar clojure.lang.Script main.clj -- foo bar"
14:29rhickey_drewr: you don't use Script with main
14:30drewrJust run it outright?
14:30rhickey_java ... foo.bar.main args
14:30Chouserdrewr: and you have to compile your ns first
14:30rhickey_sorry
14:30rhickey_hava ... foo.bar args
14:30rhickey_java
14:31rhickey_with foo/bar.class in classpath
14:31rhickey_main support is for standard Java invocation
14:32rhickey_(ns my.hello)
14:32rhickey_(defn main []
14:32rhickey_ (println "Hello World!"))
14:33rhickey_localhost:clojure rich$ java -server -cp ./test:./classes:clojure.jar my.hello
14:33rhickey_Hello World!
14:34drewrIs add-classpath enough to load the directory I'm saving the file in?
14:35scottjrhickey_: what wiki software is clojure.org using?
14:35rhickey_drewr: probably not
14:35drewrscottj: http://www.wikispaces.com/
14:51drewrOK, got it to work.
14:51rhickey_drewr: cool
14:51drewrSo would there still be any advantage to using Script?
14:52drewrThis seems a little more straightforward once you get it wired up.
14:52drewrNo tricks on the command line, *command-line-args*, etc.
14:52Lau_of_DKrhickey, since AOT is now working, is gen-&-load-class and all these related func's removed ?
14:52Chouserif you don't want to re-compile every time make a change.
14:52ChouserLau_of_DK: not yet. They still have features that haven't been rolled into AOT yet.
14:52Lau_of_DKSweet :)
14:54kotarakis it possible to assign an existing function to a multimethod? (defn foo-impl [x] (+ x 1)) (defmethod foo Integer foo-impl) ?
14:55rhickey_Chouser: I've made it so main calls RT.load, which does the is-the-classfile-newer-than-the-clj test, if not will load .clj
14:55duck1123has anyone seen the message: cannot load '/model/entry/entry.clj' again while it is loading
14:56duck1123I think it might be because I have 2 files that use each other, but I can't figure out how to resolve it
14:56Chouserrhickey_: ohhhh... of course. So you only need to compile once to get your properly named class with a main() stub.
14:57rhickey_Chouser: right, the same command line will give you your not-yet-compiled clj script
14:57rhickey_via the old class stub
14:58Chouserdoes it just load the .clj, or compile it to disk first?
14:58rhickey_Chouser: just loads
14:59rhickey_compilation to disk is always explicit
14:59Chouserok
15:00badkinsHas anyone expressed interest in getting Clojure in the running on the shootout site? http://shootout.alioth.debian.org/
15:00rhickey_there will be a :genclass option in ns
15:00rhickey_taking the same args as genclass
15:00badkinsI realize there are some "issues" with the methodology, but it would be nice if Clojure was represented - the performance seems quite good.
15:01rhickey_will apply to the AOT class corresponding to the current ns
15:01Chouserrhickey_: ah! sounds nice.
15:01Chouserstill using the Class-method naming scheme?
15:02rhickey_Chouser: no, I'm back to -method
15:02rhickey_since class is in the ns
15:02Chouserright, ok. leading - then?
15:02rhickey_yep
15:03rhickey_main hardwired to main
15:03Chousersure, that should be fine.
15:04rhickey_so for basic use (not really defining a class for instantiation) you'll get main and won't need :genclass section
15:04Chouseryou don't want to lift the :genclass sub-options right up to the ns macro level?
15:05ChouserI ask these things as if you haven't already thought them all through. I should know better by now.
15:05rhickey_Chouser: no, then they'll need to be independently addressable - genclass will use the same name->method hack as does :use :require etc
15:06Chouserah, sure.
15:06rhickey_plus a spectacular hack of gen-class to work in this new contet
15:06rhickey_context
15:06rhickey_gen-and-load and gen-and-save will go away
15:07kotarakhallelujah
15:08rhickey_badkins: someone should probably do it - coordinate here for perf tips
15:11arohnersince listpaste is broken, is there an alternative?
15:11Chouserarohner: try using it with not channel selected?
15:12kotarakarohner: yes. That works, but you have to post the URL manually.
15:12arohnerChouser was right, it works if the channel is not selected
15:12arohnerI could use some help with this macro
15:13arohnerI'm trying to write an mocking/expectation library
15:13arohnerI'm trying to write a macro that looks like binding, messes with the arguments and sends the modified arguments to (clojure/binding)
15:13arohnerhttp://paste.lisp.org/display/70458
15:16Chouserarohner: try moving the ` from let down to binding
15:16Chouserthen use macroexpand-1 and see if you like what you get.
15:18arohnerjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentList (NO_SOURCE_FILE:1)
15:18arohnerwhen trying to run it or expand it
15:19arohnercan I refer to local variables created outside of the backtick inside of it?
15:19drewrarohner: Yep, it creates a "clojure" :-)
15:21arohner:-) I think I have my head wrapped around 'normal' closures. Still trying to figure out how they work with macros
15:21Chouserno, I think in this case it expands the value into the expanded s-expr. Not a closure.
15:22drewrThe sexp that gets returned has a bound environment that the let creates. That's the def of a closure, at least in my mind.
15:23arohnerHere's how I expect to be able to use this http://paste.lisp.org/display/70458#1
15:23arohnerthat (mock) function returns a hash that contains the stub function, and state that tracks how many times the stub has been called, how many times it should be called, etc
15:24arohnerso I want to pull the stub fn out of the hash, and create a binding that is [var stub-fn]
15:26Chouserdrewr: I think if closures were inserted into macro expansions, you'd see in a macroexpand a reference to the (invisible) data. But you don't, you see the raw printed data itself.
15:27rhickey_if you insert a real closure into code as a constant value it will not work, closures can't be serialized yet. Non-closure fns can
15:29Lau_of_TestLau_of_DK:
15:29arohnerso if I move the backtick back up to the let, I won't have a closure, right?
15:33Chouserarohner: how does http://paste.lisp.org/display/70458#2 strike you?
15:34arohnerNPE
15:34Chouserhmph
15:35Chousereven with macroexpand?
15:35arohneroh, no
15:35arohnernow that works except that the value in the binding is null
15:36arohner(clojure/binding [user/foo nil] (test/function))
15:37rhickey_I really, really recommend you write macros by saying: I want to write this, I expect the expansion to be that, and write a first expansion by hand to make sure it works, then make sure your macro generates the same expansion
15:39arohnerChouser: I think you got me back on the right track. thanks
15:42arohnerrhickey_: the place where i get hung up is not clearly understanding the rules about what is possible and how each thing works
15:42ChouserIf I try to skip any step of that advice, I almost always end up having to go back and do it anyway.
15:43rhickey_arohner: if you have those 2 things, and paste them with your macro, it is so much easier to help you
15:44arohnerok. I pasted the expected input. I guess part of my problem was that I didn't know what the expected output was
15:44rhickey_exactly
15:44rhickey_me neither :)
15:44arohner:-)
15:45arohnerhaving more about macros in the docs would be helpful, like explaining what ~ and ~@ do.
15:46arohnerthe docs currently appear to be 'clojure for people who are CL experts'
15:47AWizzArdarohner: you can look it up here: http://www.gigamonkeys.com/book/macros-defining-your-own.html
15:47AWizzArdit's about in the middle of the page, search for "Backquote Examples"
15:47AWizzArdand think of ~ as ,
15:47danlei~ unquotes in a quasiquotation, that means `(~a a) == (list a 'a)
15:48drewrTable 8-1 on that page is very helpful.
15:48AWizzArdyou never need ~ and never need ~@
15:48danleiAWizzArd: exactly
15:48AWizzArdyou can write all macros with append and list
15:48drewrOh, that's the one called "Backquote examples" :-)
15:49rhickey_arohner: I understand - there's a lot to explain in Clojure, even though it's small, it covers Lisp/FP/STM etc
15:50rhickey_the docs are a language ref but don't supply background in all those areas, yet
15:50rhickey_the community is helping fill in the blanks
15:51AWizzArdand rhickey_ makes sure to give us new blanks (= extensions of Clojure) :-)
15:58ChousukeI think syntax-quote in clojure is different enough in clojure that it doesn't suffice just to say it works like in CL :/
15:58Chousukesince namespaces affect it
15:58kotarakyes, ' is not `
15:59ChousukeI meant ` in clojure is not ` in CL, though :)
15:59Chousukeeven though they're very similar :/
15:59kotarakI think ' in Clojure is ` in CL, no?
15:59danleithose auto-gensyms are nice, imho
15:59danleino
15:59Chousukekotarak: no, ' is ' in CL too
16:00kotarakHmmm... I can do '(foo ,bar)?
16:00kotarakI thought this works only with `: `(foo ,bar)
16:00Chousukeclojure doesn't have ,? what.
16:00kotarakBut I'm not a CL guy. So I should believe you. ;)
16:01Chousukeoops.
16:01Chousukequestion mark in hte wrong place.
16:01drewrChousuke: Yes, it's ~/
16:01drewrEr ~.
16:01kotarakI meant CL: Can I do '(foo ,bar) in CL?
16:01danleino
16:02danlei"comma not inside a backquote", or similar condition
16:02Chousukethe thing to note is that in clojure `(a ~a) -> (user/a 1) but in CL: `(a ,a) -> (A 1)
16:03Chousukeassuming a is def'd as 1
16:03Chouserhygene without the pain
16:03danleihm
16:04Chousukeif you wanted (a 1) you'd have to do `(~'a ~a) in clojure
16:04kotarakHmm. I was under impression, that '(foo ~x) would work in Clojure, but now I get a ExceptionInInitializer. Hmmm...
16:04danleibut then, in cl it would be the interned symbol cl-user:a
16:04danlei(or whatever package you're in)
16:04danleiit's gensyms, that are automatically inserted in clojure,
16:04danleiavoiding var capure
16:05danleifor example, in cl, if you're binding a var inside a macro, it could be captured. that's what you use gensym for. in clojure, you have # for the same effect.
16:06kotarakBut there are situations, where you also have to fall back to gensym.
16:06danlei(correct me, if i'm wrong, i'm not a cl guru either)
16:06Chousukeso your names in your macros get qualified with your namespace, so there's no fear that they will interfere with macros from other namespaces.
16:07danleicouldn't a var in a clojure macro (if not suffixed by # in the backquote expression) be captured too?
16:07Chouserkotarak: pre-AOT '(foo ~x) didn't produce an exception. What it produced wasn't terribly useful, but your memory may not be entirely at fault.
16:08Chousukedanlei: I think variable capture is possible; I'm not quite clear on how it happens in clojure :/
16:09Chousukeyou can force macros to emit non-qualified names when you *do* want to capture something in the surrounding environment
16:09kotarakdanlei: if you don't suffix your var with # (or use gensym) you will get a qualified name. So `(let [x ...] ..) should complain.
16:09danleii guess, if a bound (non gensymed) var is used within the expansion of the macro
16:09kotarakone can use `(let [~'x ...] ...) which can be captured.
16:10kotarak(Done for example with proxy's this)
16:10Chousukeyeah it'll say: java.lang.Exception: Can't let qualified name: user/a (NO_SOURCE_FILE:6)
16:11rhickey_kotarak: but not unintentionally, that's the point
16:12kotarakrhickey_: I know.
16:13Chousuke~'foo is ugly enough to immediately alert any readers too :P
16:14kotarakIt just has to be well documented (as in the proxy case) and has to be used with care.
16:17Chouserrhickey: what are the chances of getting duck-streams or something like it into core for 1.0?
16:18rhickey_Chouser: it's possible - I have to admit to being unfamiliar with the bulk of contrib :( It would be great if you guys could put together what you think are the best candidates for inclusion
16:19Chouserheh. I bet we each think the thing we wrote ought to be in core.
16:19rhickey_heh
16:19Chouserbut I guess it is true that I didn't write duck-streams or case, and would vote for both.
16:19kotarakmake a poll on the list. say 3 or 5 extensions, which can be voted.
16:23danleikotarak: thanks, works like a charm (defmacro awhen [expr & body] `(let [~'it ~expr] (when ~expr ~@body))), for example
16:23danlei(if one likes anaphoric macros)
16:24Chouserdanlei: beware the wrath of rhickey_, though. :-)
16:24danlei=)
16:24kotarakdanlei: think twice before you do that, and once you really decided for capturing clearly document the fact
16:24ChouserHe'll site you for language abuse.
16:24danleiwell, let's call it research then :)
16:26danleikotarak: you're right, i know about the implications. anyway, nice to know how, if i needed it
16:38Chousukehmmhmm
16:44ChouserPlease do NOT fill out this form yet: https://spreadsheets.google.com/viewform?key=p1hkQs__fVyaQGEP_bOFRVQ
16:45ChouserBut do please comment on its structure and language. What do you think?
16:46Chousukehaa
16:47Chousukefound the culprit I think
16:47Chousukefor some reason, (bigdec 3) throws an exception :/
16:51Chouserwow
16:52Chouser3M is ok, though
16:52bradbevChouser: It looks good to me. maybe have text box for comments?
16:52Chouserbradbev: sure, good idea.
16:54ChousukeI wonder what's wrong with bigdec
16:54Chousukeit looks okay to me.
16:55bradbevIf I wanted to do really fast 2d graphics in Java, what is the best place to start. I'm talking 30hz game kinda speed. Also, what good profilers are there for Clojure/Java?
16:55bradbev(maybe my drawing isn't the issue :))
16:57Lau_of_DKbradbev: Have a quick look a JOGL - It might be too heavy
16:57bradbevtoo heavy effort wise or rendering-wise?
16:58Lau_of_DKLibrary-wise, I dont know if you need to unbutton OpenGL for the project you have in mind
16:58Chousukehm
16:58Chousukeit seems BigDecimal's valueOf doesn't like ints
16:58ChouserChousuke: bigdec apparently won't take an Integer. Other options: (bigdec 3.0) (bigdec (long 3))
16:58Chouserah, you found it. :-)
16:59bradbevI've written a realtime viewer for nand chip access. 1/2 listens on a socket, 1/2 draws it. There is so much socket access that drawing via swing appears to be getting shutout unless I sleep the socket thread. :(
16:59ChouserChousuke: I think the latter is your best bet. Unless I'm mistaken, (long 3) becomes a literal primitive when compiled, even though it looks like a function call.
17:00ChousukeChouser: so is the test in test-clojure supposed to throw a big scary exception? :)
17:00ChouserChousuke: above my pay-grade. :-)
17:00Chouserbradbev: I know nothing from personal experience, but I've seen some impressive animation demos of large numbers of graphics objects using Qt/Jambi.
17:02bradbevChouser: I'll have to take a look.
17:05StartsWithKbradbev: maybe you should check out pulp to (i have no personal experience with it) http://www.interactivepulp.com/pulpcore/
17:16Jedi_Stanniskotarak: the makefile with gorilla gives me the following error: Makefile:40: *** missing separator. Stop.
17:16kotarakJedi_Stannis: that's because it's not a GNU makefile. You should have to use it anyway.
17:17Jedi_Stanniswhat's the recommended way of installing it?
17:18kotarakJust use the jar, which comes with the distribution.
17:18kotarakBut it in your classpath and the vim file in the corresponding places in your .vim directory.
17:18Jedi_Stannisk
17:19kotarakThe Makefile won't help you installing it, since it just creates the jar.... Please note: this is all highly experimental and will most likely blow up.
17:21Jedi_Stannisit looks very cool though
17:22kotarakYeah. I'm working on the stability. But syncronising Clojure with vim is a problem.
17:22Jedi_Stannisthe repl in vim looks like a big improvement, since you get the indenting and the colors
17:22kotarakyes, but it's intended for editing.
17:22kotarakit's not...
17:23kotarakFor small expressions its fine, but larger expressions should be edited in a separate buffer and send via \et
17:23Jedi_Stannisyeah, still looks like a good usability improvement. I'll try it out and let you know if I find any bugs
17:24kotarakI jumped through some hoops to get <CR> as smart as possible, but it can be easily confused.
17:24kotarakNote, also: it's not compatible with the latest Clojure SVN head, yet.
17:24Jedi_Stannisok, I haven't updated yet
17:24Jedi_Stannisim still using an older one
17:25danleiJedi_Stannis: have you also considered slime?
17:26Jedi_StannisI've been using vim for a while, I like it a lot
17:26Jedi_Stanniscan't really imagine relearning an editor, never gave emacs to long of a try, but never liked any of its bindings compared to vim
17:27danleiah, ok. slime is quite nice, though
17:27kotarakyeah, that's why I'm working on Gorilla: to something slime like to Vim.
17:28Jedi_Stannisyeah, I've gathered that's what most people use for lisp, but I wanna stick with vi. chimp has been working out pretty well, and gorilla looks even better
17:28Jedi_Stanniswhat other features does slime have?
17:28danleiwell, i can't compare it, because i only use slime. features? hm, there are a lot
17:29kotarakThere's a video showing the features of slime. One feature is that you shouldn't stop the process. hehe. But most likely this is fixed now.
17:29danleinice it just integrates nicely, gives you a good debugger and inspector, hard to pin it down
17:29Chouserdebugger doesn't work for clojure yet, does it? slime's I mean.
17:30danleiwell, you cant walk around in the stack frames
17:30danleilike with a cl
17:30danleibut at least it runs with closure, i'm sure it will further improve
17:31danleifor cl, its said to be the best solution (free one) available
17:31Chousukein the meantime, you'll have to use a java debugger :)
17:31danleiwell, at the moment, i'm just playing a bit
17:50Jedi_StannisI'm no java expert, what am I doing wrong here?
17:50Jedi_Stannisjava -cp gorilla-1.0.0.jar de.kotka.socketrepl.SocketRepl
17:50Jedi_StannisGives me a class not found error
17:52kotarakjava -cp clojure.jar:gorilla-1.0.0.jar de.kotka.socketrepl.SocketRepl
17:54Jedi_Stannisthanks
17:55kotarakJedi_Stannis: -cp overrides your CLASSPATH env var, as far as I can tell. But I'm no Java expert either...
17:56Jedi_Stannisyeah, as long as it works im happy
17:57Jedi_Stannisso does each \et run in its own instance now? I used to use \et to change currently running code, it seem slike I can't do that now
17:58kotarak\et runs in its own connection, but that is visible in the Repl. Run a (def x 5) with \et and the type x in the Repl and you will get 5. (As long as the buffer with the def and the repl are in the same namespace.)
17:59Jedi_Stannisok, cool
17:59kotarakGorilla tries to be smart and looks for a ns or in-ns call in the buffer.
18:00kotarakIn that case it uses the given namespace when evaluating the code.
18:00kotarakThe Repl can also do a change with in-ns, but this won't be reflected in the prompt as normal. This will probably change.
18:01Jedi_Stannisok, sounds good
18:01Jedi_Stannis\me and \m1 are giving me NoMethodError: undefined method 'macro_expand' for Gorilla:Module
18:02kotarakhuh? Just a sec.
18:02Lau_of_DKChouser: Did you finish work on (source x) ?
18:04kotarakJedi_Stannis: Ok. Obviously I'm stupid. Please have a look in ~/.vim/plugin/gorilla.vim, search for expand_macro and change it to macro_expand. I can remember I wanted to change the name, but somehow this got stuck halfway through. And then I obviously tested the wrong version. I shouldn't release software late in the evening....
18:05Jedi_Stannislol, no problem, it happens
18:05Jedi_StannisI'm also having problems with \eb and \ef, they don't seem to be working
18:06kotarakNo. This is a known limitation for now. One can send only one expression per send, since the prompt after each expression is used for syncronisation.
18:07Jedi_Stannisgot it
18:07Jedi_Stannishmm
18:07kotarakSo we have to know the number of expressions. This requires a full blown reader. eg. 123"hello":foo are three expressions....
18:07Jedi_Stannisright
18:07Jedi_Stannisyou need the reader on both sides?
18:07kotarakI need it in Vim to know, how often I have to wait for the prompt.
18:08kotarakSay I send two expression, and wait until the first prompt.
18:08kotarakThen Clojure tries to send more, but Vim doesn't expect it.
18:08kotarakProblem..
18:08kotarakSo I have to know "2 Prompts", then it's ok.
18:09kotarakBut then again I have to parse the code.... ergo I need a reader...
18:10Jedi_Stannisis it possible to somehow modify the socketrepl to let vim know when it should be waiting for more input from it or not instead of having vim just look for the prompt?
18:11bradbevHas anybody used JRat with Clojure? Or really, any good profilers?
18:11kotarakI could tell the repl to read as much as possible, and send the prompt only at the end.
18:12kotarakBut what happens for a connection over a slow line? How does the repl now, that the input is finished?
18:12kotarakMaybe I have to send some special markers. Something like gorilla/start .... gorilla/end
18:13kotarakAnd catch those in the repl.
18:13kotarakAlthough I wanted to avoid that.
18:14kotarakIt would be more flexible to be able to connect to an arbitrary repl.
18:14Jedi_Stannisyeah, it seems like you would need some sort of special repl markers or have a full reader on the vim side
18:14kotarakbeh.. for either way....
18:15kotarakMaybe the reader would be good, but it's a lot of work.
18:16Jedi_Stannisit would be nice if you could just tap into clojure's reader from vim somehow
18:18Jedi_Stanniswhat if for \ef at least, you just have it send each form one at a time?
18:20kotarakHmmm.... That would be a possibility. I see no reason, why there should a global :keyword or "string" or something. So for well-behaved buffers, this should be possible.
18:23bradbevis anybody working on tools that would expose the JVMTI interface to Clojure?
18:41AWizzArdDoes anyone else also get a "502 Bad Gateway" for Clojures svn? http://clojure.svn.sourceforge.net/viewvc/clojure/
18:41kotarakno, seems to work
18:41Jedi_Stannisits working fine for me over here
18:51gnuvince_Does proxy create methods or does it just override them?
18:53Chousergnuvince_: overrides existing methods only
18:54gnuvince_OK.
18:55gnuvince_Unless I'm reading wrong, it is not mentionned in the documentation
18:55Chouserkotarak: For a browser repl I've used a technique of sending whatever the user has typed so far, and feeding it to read via a StringReader
18:56kotarakChouser: and how do you syncronise?
18:56Chouserkotarak: then if I get an Exception message with "EOF while reading", I know the expression's not done yet, and I do no more processing.
18:56Chouserif it fails with some other exception, I report to the user
18:57kotarakAnd how do you handle multiple expressions?
18:57Chouseronlyy if the read succeeds do I proceed with the rest of the work
18:57Chouserhm, good question. I bet multiple expressions wouldn't work right.
18:58ChouserI guess I could keep running read until I reach EOF on the StringReader
18:58kotarakMy main problem is the following: (defn x 5) (defn y 6) => the repl responds with #'user/x Prompt=> #'user/y Prompt=>
18:58kotarakThe Vim side uses Prompt=> to check whether the response of the repl is complete.
18:58Chouserkotarak: right, I'm not trying to parse the repl's response at all.
18:59kotarakI have to. I need to know, when it's finished.
18:59kotarak(not really parsing, but checking for the end)
18:59Chouserright, but if you run the string through read first (with an EOF) you'll get an exception if it's not done.
19:00Chouseroh! you need to know if the output from the expression is complete.
19:00kotarakyes. but (def x 5) (def y 6) will not give an exception
19:00kotarakyes exactly.
19:00Chouserah, sorry, I don't have that problem because I don't eval on the server. :-/
19:00kotarakDo I need to wait for more output, or is it finished?
19:00Jedi_Stanniskotarak: can you just parens match to see how many forms there are?
19:01Chouserno because the output could be any text.
19:01kotarakJedi_Stannis: you can also type x at the repl and get 5 as a response
19:01Jedi_StannisI meant on the input to know how many prompts to wait for
19:01kotarakI need a full-blown reader then.
19:01Jedi_Stannishm right
19:01kotarakx is an input
19:01Chouseryeah, i bet it would work best to eval some unique sentinel after each expression. I think you already mentioned that.
19:02kotarakIn files it's rather unlikely. There you will most likely have only () at the toplevel. But not in the repl
19:02kotarakChouser: I'd like to avoid that. :| But if it's the only way...
19:02Chouserdoesn't sound too bad to me. this is the repl, after all.
19:03ChouserI'd still run the original through read first, to make sure it's all well-formed before tacking more program text on the end.
19:04kotarakHmmm.... I could define a namespace gorilla with the end function. It just prints "GORILLA END". And after each send, I simply call it (gorilla/end). And filter it transparently for the user. That wouldn't need modifications to the repl.
19:12kotarakJedi_Stannis, Chouser: thanks for the ideas. I will give that a try tomorrow.
19:13Jedi_Stannisno problem, thanks for working on gorilla
19:13Chousukehmm
19:15ChousukeI'm not exactly a grandmaster of either editor, so maybe I could get the best of both...
19:45mmcgranaHi all, I'm trying to use the latest clojure head but am getting a weird error when running ant:
19:46mmcgrana2008-11-15 19:42:53.509 java[20155:613] Apple AWT Startup Exception : *** -[NSCFArray insertObject:atIndex:]: attempt to insert nil
19:46Chousukehmm
19:46Chousukethat doesn't happen on my system
19:46mmcgranaI've used recent clojure versions and post aot versions ok, it seems to have stopped working with recent precompile core stuff
19:46Chousukewhich java version are you using?
19:46mmcgrana1.6
19:46Chousuketry 1.5
19:47mmcgranamac os x leopard
19:47ChousukeI think the GUI stuff is broken in 1.6
19:48mmcgranahm ok is there an easy way to tell ant to use 1.5 or would i have to switch the java bin symlinks to 1.5
19:48Chousukeand clojure precompiles things that import some GUI stuff which apparently requires some special GUI interaction on OS X
19:48ChousukeI don't know. :/
19:52mmcgranaok well thanks for the thoughts I'm just going to temporarily revert to 1.5 to see if i can get it working
19:53Chousukemmcgrana: you could also edit the precompile.clj script and remove clojure.inspector from the precompiled stuff
19:53Chousukemmcgrana: it's the only one that requires GUI stuff
19:53mmcgranao nice yeah i'll try that
19:54Chousukethough if you do that you won't be able to use it, as the jar will only contain the precompiled things
19:54mmcgranaright, np
19:55Chousuketo work around *that*, remove the comment marks form the line <!-- <fileset dir="${cljsrc}" includes="**/*.clj"/> --> in build.xml :P
19:55Chousukethat'll include non-precompiled stuff as well
19:55Chousukeclojure will prefer precompiled classes, so that shouldn't be a problem
19:55Chousukeyour jar will just be a bit larger
19:58mmcgranaok that worked (editing precompile.clj), thanks Chousuke, I have slightly better startup time now
19:59Chousuke:)
22:59djkthxi'm trying to compile a file in emacs/slime with a namespace declaration
22:59djkthx(clojure/ns mylib.nifty-funs)
22:59djkthxwhen i try
22:59djkthxit throws this error
22:59djkthx-+ Errors (2) |-- java.lang.Exception: No such namespace: clojure (niftyfuns.clj:1) `-- java.lang.Exception: No such namespace: clojure
23:00hiredmanclojure.core
23:00hiredmanthe clojure stuff got moved into clojure.core to avoid single segment namespaces
23:01djkthxahh