#clojure logs

2008-10-09

00:25abrooksChimp's Clojure support is nice: http://kotka.de/projects/chimp.html
00:25Chouseryeah, pretty clever use of screen
00:27abrooksChouser: It's more polished than the like-slime-for-vim plugin.
00:27abrooksI was playing with that a bit but this is a much better starting point.
00:27Chouseroh, I hadn't tried that.
00:28abrooksChouser: Are you using Chimp?
00:28Chouserhave used. I suppose I should try to set up some scripts or keybinding to make launching it easy.
00:28abrooksI let localmapleader=","
00:29abrooks,et is pretty easy to type
03:14schlarfwhen you guys use slime, is that clojure-mode for emacs or is it the normal slime?
03:14schlarfor is it slime+enclojure-stuff?
04:27schlarfman desctruturing is nice, the more i use clojure the more it seems like the pragmatic programmers hoice out of functional languages. innovative and fresh, still very neat and practical
04:32hoeckschlarf: yeah, at the beginning i was very sceptical about the functional and immutable stuff, but somehow, lazy sequences are way better than generators and loops
04:57schlarfHmm I now have def-class, def-method, method-lookup, super for my object-system. 1. are those names ok with you clojurers? 2. what object-system do you prefer, common lisp, java , python etc?
04:57schlarfmethod-lookup is internal btw
05:03tWipschlarf: I prefer none
05:03tWipMost times using functional programming, I don't need an object system in the traditional sense.
05:07schlarfok but im implementing one anyway just to learn(lisp/clojure and how to create an object-system)
05:07schlarfso might as well try to do something people might find useful
05:12H4nsschlarf: i'd suggest that you just go ahead and write one that suits you
05:23schlarfyes
06:30schlarfcant i do : for key, value in zip(Map.keys, Map.values): do-something
06:30schlarflike in python
06:30schlarfi find no zip-function
06:30schlarfi could ofc write one
06:31schlarfzipmap
06:32schlarflol that was the pooopiste
06:32schlarfopposite
06:32H4ns(find-doc "zip") may help
09:04schlarfhow can i set intendation to 4 chars instead of 2? and always 4 chars...
09:04schlarfim using clojure-mode for emacs
09:06schlarfis lisp-paste-clojure not working?
09:18schlarfrhickey: do you work on clojure as a part of your job or it is something you do in your free-time?
09:18rhickeyschlarf: that question presumes traditional notions of 'job' and 'free time' :)
09:19schlarflol
09:30tWipweird.. entering 08 or 09 results in ReaderError with number format exception
09:31tWipothers like 02 evaluate to the expected number
09:31rhickeytWip: leading 0 means octal - 011 -> 9
09:32tWipok, I thought that I must be missing something
09:32rhickey8 and 9 are not valid octal digits
09:32tWipbut that is a logical explanation, thanks
09:41schlarfhow do i import? if i have a file object-system and i want it to be imported into my user.clj?
09:42schlarfand how are the lookup-rules? like does it look in the currenct directory only?
09:44rhickeyschlarf: Clojure uses the Java classpath system
09:53schlarfrhickey: ok i dont know how that works. if i have a file objectsystem.clj in the same dir as user.clj, how would i write? (import ObjectSystem.clj)
09:53schlarfdoesnt work
09:54schlarfnor does (.import ...)
09:54Chouserschlarf: the "right" way to do a lib is to put a file in a package and namespace subdir
09:54Chouserlike: schlarf/objectsystem/objectsystem.clj
09:54schlarfok
09:55Chouserthen you make sure that "schlarf"'s parent dir is in your classpath
09:56Chouserlike: java -cp clojure.jar:/my/dir (where shlarf is actually /my/dir/schlarf)
09:56Chouseronce that's set up, users can just say (ns foo (:require [schlarf/objectsystem :as sos])) and start calling your functions like: (sos/bar ...)
10:07schlarfdoes it really have to be that complicated?
10:07Chousernope, though it's usually worth it in the long run.
10:07schlarfor wait maybe it osnt
10:07Chouseryou could just say (load-file "objectsystem.clj")
10:08schlarfi cant find documenation on package and requie
10:08Chouser(doc ns) (doc require)
10:39cooldude127hey all
10:39cooldude127anyone using jambi with clojure?
10:41abrookscooldude127: I think Chouser did a little once.
10:42cooldude127i just dled it, and i'm not sure where to put everything so that it all gets loaded by default. i'm using to clojure with slime, so i'm not really sure how to mess with my classpath
10:42cooldude127s/using to/using
10:43abrookscooldude127: Do you have a jambi jar?
10:43cooldude127yeah
10:43cooldude127it needs two i think, one generic and one for the platform
10:43cooldude127i have them both, just not sure what to do
10:45abrooksI assume this is on Linux? I'd try exporting the full path to the generic jambi jar in the CLASSPATH environment variable before starting slime.
10:46cooldude127mac os x actually
10:47H4nscooldude127: i found it easiest to set up the classpath in the 'clojure' shell script that i use both to start clojure in slime and on the command line.
10:47cooldude127oh
10:47H4nscooldude127: i find that easier to work with than messing with the environment.
10:47cooldude127i guess so, but it means i need to go back and look and swank-clojure and reconfigure it
10:48cooldude127right now i'm just loading the clojure jar
10:48H4nscooldude127: it is a one-line change.
10:48H4ns(well, except for the shell script thing) :)
10:48cooldude127yeah, what is the one line change?
10:49cooldude127the readme for swank-clojure isn't too clear
10:49cooldude127wait is it just swank-clojure-binary?
10:49H4nsright
10:49cooldude127instaed of swank-clojure-jar-path
10:49cooldude127ok
10:49H4nsthat did it for me. i had to restart emacs to make that work.
10:50cooldude127should be enough i would think to reevaluate that, clear out swank-clojure-jar-path, and kill the slime and inferior-lisp buffers
10:50cooldude127but now saying all that makes restarting emacs seem much simpler
10:52cooldude127what would i put in my shell script? how does it want me to start clojure?
10:52cooldude127just a repl?
10:54H4nsthere is this clojure-contrib shell script that i use
10:54cooldude127in the sourceforge project?
10:55cooldude127or github?
10:56H4nsgithub
10:57achim_phi! this is not really a clojure question: has anybody successfully used Runtime.exec or ProcessBuilder for remote controlling interactive external processes?
10:58achim_pstarting processes (like "bash" or "ftp") works fine, i can send them input strings and read the responses, but they won't send me a prompt. this seems to be due to them behaving differently depending on whether started in a terminal (isatty) or a pipe. does abybody know a (hopefully cross-platform) way to evoke terminal-like behaviour of subprocesses?
10:59schlarfright now i have (method-lookup method_name instance) but i want (method_name instance) ; to get that id have to change the parser of clojure or do something like ($width rectangle) , having a prefix to all methods? which is basically the same anyway. ($ width rec)
10:59achim_pi started working on a simple popen/expect for clojure (http://www.bitbucket.org/achimpassen/clj-popen-expect/src/tip/src/io/popen/popen.clj), but expect isn't that useful without prompts ...
10:59schlarfor i could do (instance method)
10:59schlarfand somehow have some lookup-dispatch-table
10:59schlarfsomethinglol
11:00schlarf(instance $ method)
11:00schlarf$ being a macro
11:01schlarfcan i have backtracking macros? how do i get a form like: (rec $ width) ?
11:01schlarfif $ is a macro it can take width as a param, but how does it get rec?
11:01schlarfi guess ($ rec width is more lisp-ish)
11:03schlarf(load-file "file.clj") only works in currecnt directory?
11:04schlarfi cant do (load-file "current/next-dir/file.clj") ?
11:05Chouserto invoke a macro, its name has to be at the front of a list (macro-name arg1 arg2)
11:05schlarfyeah works
11:13schlarfwhat is a good symbol for using a method on object? ($ rec width) stinks
11:13schlarfso does >>
11:14schlarf(! rec width)
11:14schlarftaken
11:14schlarf(\ rec width)
11:15schlarf(| rec 'width)
11:21tWiphow about? (rec :width)
11:21tWipif objects are functions of their messages
11:22Chouseror (width rec) like multimethods already allow
11:31peter_12tWip: ++
11:39schlarfchouser: you prefer multimethods?
11:41Chouserschlarf: to what?
11:49schlarfuhm, message-passing?
11:49schlarfsingle disptach?
11:50ChouserAs far as I understand, clojure's multimethods are superset of regualr single-disptach object systems.
11:51schlarfbut lets seee, if i do (rec :width) then how would i parse that ? without change clojure interpreter? when it sees rec it will see a reference, how would it know what to do with it? it would have to be ordered to look at the next arguments, but how?
11:51ChouserIt's pretty easy to define a method that dispatches on the type of the first arg.
11:51schlarfyes (width rec) is easy, but (red width)?
11:52schlarfred=rec
11:52tWipif your objects are functions
11:53Chouseror if they are objects that implement IFn
11:53schlarfright now they are references
11:54Chouserthey could be functions that are closed around a reference
11:55schlarfcould you link to something that describes that? now i have the problem that i cant bind a method to a reference directly but i bind a method to a def that is a ref
11:55cooldude127anybody want to play a game of spot the error?
11:56cooldude127ava -Dpid=5760 -XstartOnFirstThread -cp .:/Users/mattmoriarity/usr/src/qtjambi-mac/*.jar:/Users/mattmoriarity/usr/src/clojure/clojure.jar clojure.lang.Repl
11:56cooldude127s/ava/java
11:56cooldude127brings up a repl but the jambi classes are non existent
11:57Chousercan you use *.jar in the classpath? I didn't know that.
11:57cooldude127i wondered, so i just tried it with the clojure jar
11:57cooldude127totally works
11:57cooldude127java -cp ~/usr/src/clojure/*.jar clojure.lang.Repl
11:57cooldude127brings up a repl
11:58Chouserah, not quite the same thing. try .:/whatever/usr/src/clojure/*.jar
11:58cooldude127fcuk
11:58cooldude127*fuck
11:59rhickeytry leaving off the .jar, just use *
11:59cooldude127zsh barfed on it when there were multiple components in the -cp arg
12:00cooldude127* only works when you have a single cp component
12:01cooldude127is my conclusion
12:01cooldude127adding ".:" to the front killed it
12:02cooldude127i guess it's the shell that is affecting that
12:02Chousercooldude127: it depends on whether it's your shell or java that's interpreting the * -- in your first clojure/*.jar test, zsh was expanding that before handing to java
12:02rhickeytry putting '*'
12:02rhickeyno .jar
12:03rhickeyhttp://blogs.sun.com/mr/entry/class_path_wildcards_in_mustang
12:03cooldude127zsh cries with or without the .jar
12:03cooldude127which java is mustang?
12:03cooldude127is that 6?
12:03cooldude127cuz this is 5
12:04Chousercooldude127: try with qoutes: java -cp ".:/foo/*:/bar/*" ...
12:04cooldude127k
12:04cooldude127i'm not sure what happened. it killed my terminal tab
12:04cooldude127wtf
12:04cooldude127it keeps doing that!
12:04cooldude127ahhh
12:05cooldude127still doesn't work. i don't think java 5 does wildcards in the cp
12:06cooldude127looks like i just have to list out the jars, cuz when i do that, everything is happy :)
12:11cooldude127ok my clojure script is working and loading the jambi classes
12:12cooldude127swing does have something going for it: the easy of setup (aka no setup)
12:17lisppaste8Chouser pasted "closing over a ref, for schlarf" at http://paste.lisp.org/display/68199
12:20Chouserwhere "sure" is "use" :-P
12:20Chouserlunch, bbl.
12:29cooldude127ahh dang it. stupid jambi
12:29cooldude127i can get the simple hello world example to work in the terminal
12:30cooldude127but if try to do it from slime, i have some problems
12:33abrookscooldude127: Is slime somehow not passing the CLASSPATH environment variable? Can you just add the jambi path to the java -cp commandline argument?
12:33cooldude127it's not that the jambi classes aren't loading
12:33cooldude127when i try to make an app
12:33abrookscooldude127: Oh.
12:33cooldude127slime doesn't return to the repl
12:33cooldude127i enter my expression and it just sits there
12:34abrooksDoes the jambi application window come up? It's probably blocking on the application. You could try sending the application call off in a thread.
12:35cooldude127the window does not come up is the problem
12:35cooldude127how would i do it in another thread?
12:46cooldude127alright new question:
12:46cooldude127trying to translate this java: quit.clicked.connect(QApplication.instance(), "quit()");
12:47cooldude127came up with this clojure: (.. b clicked (connect (QApplication/instance) "quit()"))
12:47cooldude127but i get this error: java.lang.IllegalArgumentException: More than one matching method found: instance
12:50cmvkkIf I have a multimethod and I want it to dispatch on two values, but to default out on one of them, can I do that?
12:50cmvkkfor example, if i want to dispatch on [:foo :bar], but if that doesn't exist, to default to [:foo :default]
12:51cmvkkor something like that
12:53digashblist
12:53rhickeycmvkk: you could (derive :bar :default)
12:55cmvkkaha, that would work, thanks.
12:57cooldude127how can (QApplication/instance) have multiple matching methods?
12:58rhickeycooldude127: I don't see how, are there online JavaDocs you can point me to? Does it derive from something generic?
12:59cooldude127here are the javadocs
12:59cooldude127http://doc.trolltech.com/qtjambi-4.4/html/index.html
13:00cooldude127com.trolltech.qt.gui.QApplication.instance()
13:00cooldude127i would have linked straight to that but i believe frames would not work with that
13:01cooldude127rhickey: i saw another person on gmane with this problem but they added a type annotation to fix it. and this case doesn't really have anything to annotate
13:03cooldude127found a temporary fix: the superclass QCoreApplication has an instance() method that works fine and returns the right thing
13:04cooldude127but i still don't see how this was messed up in the first place
13:08cooldude127is there a way to import every class in a package?
13:09Chousercooldude127: no, there is not. This is intentional.
13:09cooldude127ah man
13:10cooldude127cuz it would really make the repl more convenient
13:10Chouserbut you don't have to repeat the package name. Just (import '(foo.bar Baz Bang Boom))
13:12PupenoHello.
13:12cooldude127yeah, but i'm not always aware when i do that of all the classes from the package that i want
13:13cooldude127so i have to keep going back
13:13ChouserPupeno: hi
13:13cooldude127bring it on the vacation :)
13:14arohneris the slime checkout working for anyone else? I'm getting connection refused
13:14rhickeycooldude127: it must have to do with the same-sig static method in the base class
13:14cooldude127rhickey: it's debating between the one in QCoreApplication and QApplication?
13:15cooldude127is that a clojure problem or jvm problem?
13:15rhickeycooldude127: shouldn't be, but is
13:17cooldude127ahh
13:17cooldude127that is not cool
13:18rhickeyanyone know of an instance of that in the JDK libs - derived class and superclass with same-sig static method?
13:19cooldude127i wasn't even sure you could do that
13:23cooldude127oh snap time to learn how to make java objects in clojure :/
13:24aquanautHello
13:24Chouseraquanaut: hi
13:24aquanautHow does one open a file for reading or writing?
13:24Chousercooldude127: "proxy" isn't too unpleasant
13:24cooldude127nvm no it's not
13:25cooldude127yeah i wasn't all that scared it looks simple
13:25cooldude127turns out i don't need to do that anyway
13:25cooldude127all these stupid qt examples do it put a bunch of initializer code in the constructors. they don't really override anything
13:25cooldude127i can do all this outside a class completely
13:25aquanautAlso, any ideas why clojure doesn't dispatch on singletons?
13:25Chouseraquanaut: (doc slurp) for files
13:26Chouseraquanaut: what do you mean, dispatch on singletons? are you talking about static methods?
13:27aquanautslurp brings the reads the file into a string, I need to keep the file open.
13:27cooldude127aquanaut: with-open
13:27cooldude127pass in a java.io.FileReader
13:28cooldude127basically just makes sure you don't forget to call close on your stuff
13:28Chouseraquanaut: in that case I highly recommend clojure.contrib.duck-streams, otherwise you have to do the same dance as in Java with IOStreams, Readers, and whathot
13:28cooldude127otherwise you're interacting with the java io stuff
13:28Chouserer, whatnot
13:28Chousercooldude127: with-open doesn't actually open anything :-)
13:28cooldude127i know
13:28Chouserit's more of a "with close" actually.
13:28Chouseroh, ok.
13:28cooldude127lol yeah
13:31cooldude127oh duck streams looks nifty
13:31cooldude127i would say use that along with with-open
13:31cooldude127despite the confusing name
13:32aquanaut(defn fact [0] "off" [1] "on" [x] "unknown")
13:32cooldude127pattern matching is only on arity, not actual values
13:33rhickeythat's not pattern matching, just arity overloading
13:33cooldude127yeah, that makes more sense
13:33aquanautwhy no pattern matching on values?
13:34rhickeyaquanaut: there's no pattern matching
13:34cooldude127EVER
13:35rhickeycooldude127: I didn't say that, but it's important to note that function args are just that, args, not patterns/conditionals
13:35cooldude127yeah i know
13:35cooldude127it confused me at first tho too. idk why i came to expect this
13:35aquanautI understand the language doesn't support pattern matching, my question is what is the rational behind it.
13:36rhickeypattern matching is inextensible
13:36cooldude127so use multimethods instead?
13:36rhickeyvs multimethods, say
13:36cooldude127ah
13:36cooldude127pattern matching is more succinct i would think in small cases like his
13:38rhickeyaquanaut: (defn fact [x] ({0 "off" 1 "on"} x "unknown"))
13:38cooldude127when the differences in behavior are big or extensibility is very important, multimethods all the way. but it's kind of overkill for something like a factorial
13:38cooldude127OH
13:38cooldude127i like that
13:38cooldude127i wish you would have sent that before i typed all that bullshit
13:38cooldude127saved me some keystrokes
13:39aquanautrhickey: I am not sure I understand how this works.
13:39cooldude127maps are functions that will lookup by key
13:40cooldude127the last arg is what to return if the key isn't in the map
13:41aquanautBut this will work only for methods with only one argument
13:41cooldude127yeahhhh
13:41cooldude127multimethods :)
13:41aquanautWhat is the multimethod solution
13:42rhickeyarity dispatch is direct - no conditionals, no counting, so any other conditionals must be done at the next level, in the body
13:44lisppaste8cooldude127 pasted "multimethods" at http://paste.lisp.org/display/68204
13:44cooldude127rhickey might be able to point out a better way but that was my multimethod solution
13:45cooldude127seems a tad verbose, but maybe a macro could fix it up?
13:45rhickeythere's no reason for multmethods here, we were talking generally about alternatives to pattern matching. In the smallest cases it could be maps or cond
13:46cooldude127yeah, but i blew the stack when i tried to use maps
13:46cooldude127not sure why
13:46cooldude127(defn fact [x] ({0 1 1 1} x (* x (fact (dec x)))))
13:46rhickeycooldude127: you read fact as factorial, but that wasn't the function
13:46cooldude127i know
13:47cooldude127i went off in my own direction lol
13:47aquanautcooldude127: you blew the stack beacuse of the lack tail calls
13:48cooldude127except for i only should have made 5 function calss
13:48cooldude127*calls
13:48cooldude1275ish
13:49rhickeythat's not tail recursive anyway, call to fact is not in tail position
13:50aquanautThats right. It is just recursive
13:50cooldude127yeah. it shouldn't have blown the stack anyway with a (fact 5 call)
13:50cooldude127(fact 5) call
13:50cooldude127that is
13:51johnwayn`probably because the default value is going to be calculated first
13:51cooldude127the multimethod solution is the same code inside and it works fine
13:51aquanautIt blows it even for (fact 1)
13:51cooldude127OH
13:51cooldude127johnwayn` is brilliant
13:51johnwaynerhardly
13:51cooldude127but you did figure this one out
13:51johnwaynerI get one point :)
13:52cooldude127so the maps solution doesn't work out with a recursive function
13:52rhickeycooldude127: maps doesn't work with any function, just a mapping of values to values like the original question
13:53cooldude127yeah
13:53cooldude127i see that now
13:53cooldude127why can't everything be lazy?
13:53cooldude127:)
13:54gnuvincecooldude127: it is in Haskell (and it causes its share of problems too ;))
13:54cooldude127yeah i've done a little haskell. like the laziness, but the purity just makes things difficult sometimes
13:54cooldude127and yes the laziness can be annoying too
13:54cooldude127just less often
14:00lisppaste8johnwayner pasted "map factorial for cooldude" at http://paste.lisp.org/display/68206
14:01johnwayner:)
14:04gnuvinceWhy so complicated?
14:04lisppaste8cooldude127 annotated #68206 with "slightly better" at http://paste.lisp.org/display/68206#1
14:05johnwaynerjust proving I'm not "brilliant"...
14:05cooldude127lol
14:05gnuvinceAny reason you're using a hash?
14:05cooldude127because we can
14:05cooldude127not the best way by any means
14:06wwmorganwhy are there two base cases?
14:06johnwayneryeah...it's kinda a joke
14:06gnuvinceHow about: (defn fact [n] (apply * (range 1 (+ 1 n)))) ?
14:06gnuvincek
14:06cooldude127i would use reduce over apply
14:07cooldude127idk about clojure but other lisps have a limit on the number of args you can pass to a function
14:08rhickey(apply + (range 1000000))
14:08cooldude127ok i guess it's not a problem for clojure :)
14:08rhickeyindefinite amount via apply
14:09cooldude127apply and reduce take about the same time
14:10cooldude127space-wise, who knows
15:07lisppaste8schlarf pasted "list and eval" at http://paste.lisp.org/display/68211
15:08schlarf^^ can someone explain that. how to create a list and have ref in it
15:08schlarfdo i need a macro?
15:10schlarfhmm i could pass as parameters to def-method perhaps
15:36ChouserIf you want the value of i to change over time, it should be a ref.
15:36ChouserI demonstrated that in my earlier paste, did you see it?
15:38schlarfit is a ref
15:38schlarfi is a ref
15:39schlarfif i list the value of ref is listed and the function performed, thus replacing witht he value of the function
15:39schlarfif i quote then it is the char /symbol i not the value of i
15:42schlarfi write like shit on irc lol
15:43Chouserfrom you paste, I can't really tell what you're doing. Can you provide a short but complete example?
15:43Chouserby complete I mean: not referring to things without defining them
15:46lisppaste8schlarf pasted "oo-system" at http://paste.lisp.org/display/68214
15:46schlarf^^ all the code, some is duplicated, im still refactoring and rewriting and far from done
15:47danlarkinschlarf: neat
15:51schlarfdan: thanks, i will make it more complete and perhaps have some meta-class-system to easily define your own ==-system
15:51schlarfOO-system
15:52solkisBeing new to Emacs and clojure, can anyone explain to me the difference between simple inferior-lisp mode and slime/swank? Initially I setup the former and now I have the latter but I'm not sure what other benefits the slime integration brings.
15:52schlarfslime = Superior Lisp Interactione Mode for Emacs
15:52schlarfname should say all
15:54solkisschlarf: saw that... that's why I loaded it :-) now I want to know *what* makes it superior
15:56solkisI see the feature highlights on the slime page (which I'm not enough of a lisp/clojure hacker to grok completely) but I didn't know if there was some killer feature in terms of clojure
15:56shooverclojure-mode gives the basic syntax highlighting and code navigation features. slime adds more features like macroexpansion, tab completion in the the REPL, stack traces from the REPL. Do you have a slime menu at the top? All those features are beyond what clojure-mode has.
15:57shoover(but some of the features in the menus aren't implemented yet for Clojure)
15:59solkisshoover: yes, I do have the menu... I'll check it out through that. thx
16:52PupenoDo I have to define a function before using it in a file? like in C (without headers)?
16:53drewrIt has to be defined before using it, yes.
16:53drewrYou can do it in a file or at the REPL.
16:54PupenoThat's nasty :(
16:55drewr?
16:55PupenoI tend to have util-functions at the bottom of the files.
16:56drewrEvery time you start a new JVM, it has to be loaded with code you want to have access to.
16:56PupenoActually, my files tend to look like:
16:56Pupeno(def a [] b)
16:56Pupeno(def b [] c)
16:56PupenoI mean,
16:56Pupeno(def a [] (b))
16:56Pupeno(def b [] (c))
16:57Pupeno(def c [] 1)
16:58schlarfis there any advantage of single dispatch over multipel dispatch?
16:58schlarfjust easier to implemetn?
16:58rhickeyyou can pre-def things with (def x), then provide full def later
16:58waltersschlarf: it maps to the virtual metal
16:59Pupenorhickey: is there a reason why it doesn't just work?
17:00schlarfwalters:you mean it is more like how a computer works whiole multiple dispatch is the more abstract concept?
17:00ChouserPupeno: names are resovled at compile time, so that runtime performance is better
17:01rhickeynames that can't be resolved could be bound in current-ns, but errors would be much harder to detect
17:03PupenoSo, what do you do? Have a C-style header, defing everything, or have the functions in bottom-up order?
17:03rhickeythen there is the CL interning/package problem. You use foo, intending some-ns/foo, but hadn't referenced it. This has the side effect of interning your-ns/foo, at runtime you get an error, you try to fix it by making the refer but now some-ns/foo is in conflict with your-ns/foo
17:05rhickeyPupeno: personal preference
17:05cemerickPupeno: you only need to def the things you refer to in other code before fully defining them. I think I have pre-def'ed 10 fns over the past 4 months
17:06Pupenocemerick: then you are using bottom-up order, I pressume.
17:06rhickeybut yes, if you wanted a true top-down file you'd have more defs
17:07cemerickPupeno: Not consciously. I also put a lot of effort into moving generally-useful fns into other namespaces.
17:07rhickeyI think the answer is some sort of intern-tracking, checking that actual defs have been made by end-of-file, but that is kind of icky in being file-based, and I haven't had time to refine the idea
17:08cemerickIt's a really minor thing, IMO.
17:08rhickeyIt was raised early on, but I don't get many complaints
17:11PupenoI understand why there may not be a straightforward solution, but I really thought I escaped that problem when I stopped conding in C years ago. Personally, for me it's not a minor thing, but I can understand it is for others.
17:18lisppaste8arohner pasted "stupid java print stack trace" at http://paste.lisp.org/display/68217
17:19arohnernotice the "and 68 more lines" at the bottom of the stack trace? That's why we need to extend .printStackTrace()
17:19arohnerrhickey: would you be accept a patch that does that?
17:19rhickeywhat do you mean by extend?
17:21arohnercreate a subclass of java.lang.Exception that has a working printStackTrace()
17:21rhickeyI don't think so
17:22arohnerwell, my desired goal is not have java print "and 68 more lines"
17:22rhickeycan't you just write a better stand-alone pst function that works with any exception?
17:23arohneroh, yeah, looks like you can using exception.getStackTrace()
17:25ggbbggwhat does trailing '#' mean on symbols in defmacros ?
17:26rhickeyggbbgg: that's an auto-gensym - guaranteed to be a unique name, and every x# in the same ` expression is the same name
17:27ggbbggthanks rich.
17:30arohneris it a bug that (macroexpand '(foo..)) generates a compiler exception?
17:31arohnerI have a macro that is doing something broken, so I did (macroexpand '(foo...)) and I only get the exception
17:31rhickeywhat is ... ?
17:32arohner(macroexpand '(mk-validator validate-not-blank not-blank-pred "must not be blank"))
17:32rhickeyworks here
17:32arohnerright, but mk-validator is my broken macro
17:33rhickeyand the exception doesn't help?
17:34arohnerI was surprised that I got a compiler exception instead of source code
17:34rhickeyyour macro is being called by the compiler, it is failing
17:35rhickeythe expander itself, not the expansion
17:40arohnerok, let me approach this a different way. can you create a defmacro that returns a defn?
17:40rhickeyarohner: sure
17:42Pupenolisppaste8: url
17:42lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:43lisppaste8Pupeno pasted "defs" at http://paste.lisp.org/display/68220
17:44PupenoI wrote a macro to define a bunch of names, (def a) (def b) (def c), like that. Can it be improved?
17:45rhickeyPupeno: looks ok, you might want to call it declare
17:46rhickeygood candidate for the standard lib
17:46Pupenorhickey: thanks.
17:47rhickeymacros to the rescue
17:47Pupenorhickey: I could try to include it into Clojure by myself and send you the patch, write tests if needed, documentation, whatever. It's probably trivial for you, but I'd like to get my hands dirty in Clojure itself.
17:47rhickeyI'll add it
17:48PupenoOk.
18:01lisppaste8arohner pasted "no error or stack trace" at http://paste.lisp.org/display/68221
18:01arohnerthis looks to be the most isolated version of the problem I was having
18:01arohnerthough this doesn't have a stack trace, and I'm not sure why
18:06danlarkinmacroexpand-1 gives (clojure/defn clojure.name__482@c610af [user/a] (clojure/println user/a))
18:08danlarkinI think you have a typo in that macro
18:08arohnerI do, that was the point
18:08danlarkinoh
18:08danlarkind'oh :o
18:11danlarkinis it something about using name like that?
18:11arohnername is an already existing function
18:11arohnerI should have used ~fn-name instead of ~name, but I made a mistake
18:11arohnerthe point of the paste was that the error was not very useful
18:12danlarkinarohner: yeah you were way ahead of me
18:12danlarkinI'm caught up now though!
18:29lisppaste8johnwayner annotated #68220 with "more DRY" at http://paste.lisp.org/display/68220#1
18:32johnwaynerPupeno: Perhaps you can do something like that last annotation to save some typing.
18:35duck1123does anyone else have problems using slime with clojure
18:35duck1123I'm running up to date on everything
18:36duck1123I'm still getting "java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)"
18:36johnwaynerare you using the clojure swank?
18:36duck1123yes
18:37shooverSomehow it's sending Common Lisp code to the clojure swank. Do you have (require 'swank-clojure-autoload) before (require 'slime)?
18:37johnwaynerperhaps a paste of the appropriate parts of your emacs configuration would shed light?
18:38duck1123it looks like slime-init-command is generating the code
18:39duck1123so swank-clojure has to be required first?
18:39Pupenojohnwayner: thanks for the annotation. I absolutely agree it's more DRY, or actually DRY, but I haven't done it for two reasons: 1- I'm not sure I like how the code looks when using that macro 2- It goes way beyond my macro-skills. I wonder if Emacs can be configured to not indent after a certain special keyword in a form...
18:39lisppaste8johnwayner pasted "slime emacs config" at http://paste.lisp.org/display/68224
18:39shooverduck1123: Yes, that autoload sets up some things so that the generic slime code knows which swank code to use
18:41johnwaynerPupeno: hmmm you'd probably have to tweak clojure-mode.
18:42lisppaste8shoover annotated #68224 with "there's always another way" at http://paste.lisp.org/display/68224#1
18:49duck1123thanks guys. I got it working with shoover's code
18:49duck1123now to put back the rest of my .emacs file
18:55danlarkinjohnwayner: what does this with-fwd-declare macro do?
18:56johnwaynerit finds all your defn's and forward declares them so you can use them before you define them.
18:57johnwaynerPupeno was looking for way to do top down definitions
18:57johnwaynerI'm not even suggesting this is the best way to do it. I'm a newb :)
18:58danlarkinjohnwayner: oh, cool!
18:58johnwaynerthanks :)
19:15johnwaynerinteresting... why does #(do `(def x)) work, but #(`(def x)) doesn't?
19:17johnwaynerooohh.... right. '(def x) isn't a function.
19:34danlarkin(#(`(def x))) doesn't work, but ((fn [] `(def x))) does
19:34danlarkinI wonder why that is
19:34johnwayneryeah... that's what threw me
19:35Chousercurrently macros are just functions that return a list (of code), and are marked using metadata as macros
19:35Chouseroh, nm, you'd not even dealing with macros.
19:35Chousersorry
19:35johnwaynerbut still interesting to knwo
19:37johnwayneris there a non-reader way of doing quoted syntax (`)?
19:37Chouserah, the problem with #() is that #(foo) expands to (fn [] (foo))
19:38Chouserthus (#(`(def x))) means ((fn [] (`(def x))))
19:38johnwayneryes, whatever you put in #() must be IFn
19:39Chouserright, and the LazyCons returned by `(def x) is not IFN
19:40johnwaynerI guess it just seemed that ` was a short-hand for a function
19:41johnwayneror I guess I should say IFn
19:42johnwaynermeh. doesn't matter... since that result would still need to be called as IFn since it heads a list
19:43johnwaynerdinner time...
21:14lisppaste8johnwayner annotated #68220 with "ok, I'm done messing with this now :)" at http://paste.lisp.org/display/68220#2
21:16rhickey_I prefer (declare foo bar baz) preceding their use
22:18Chouserhmph. How much does performance matter when printing regex patterns?
22:22rhickey_Chouser: not much
22:24akingI accidently def'd a var in the wrong namespace - is there a way to 'undef' it without having to restart the jvm? THere seems to be no (remove-var) or similar
22:25rhickey_aking: (doc ns-unmap)
22:26akingrhickey_: cool - thanks. I also tried 'undef'.. was close :)
22:27rhickey_ns-unmap works for imports and refers too
22:54yangsxdoes any body use both CL and Clojure with slime at the same time? Only the last one (either clojure or a CL implementation) works on open files
22:55danlarkinyangsx: can you clarify?
22:57yangsxdanlarkin: sure. I run both sbcl and clojure with slime, if clojure is the last one, then all actions on any lisp buffer are sent to clojure, not sbcl
22:57yangsxand vice versa
23:00yangsxmy slime-lisp-implementations contains both sbcl and clojure, and M-- M-x slime sbcl (or clojure) to run any one of them
23:04danlarkinHm
23:09danlarkinthe same thing happens to me... but that's with two slime clojures
23:09yangsxdanlarkin: why two slime clojures?
23:13danlarkinworking on two files at once