#clojure log - Oct 09 2008

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

0:25 abrooks: Chimp's Clojure support is nice: http://kotka.de/projects/chimp.html

0:25 Chouser: yeah, pretty clever use of screen

0:27 abrooks: Chouser: It's more polished than the like-slime-for-vim plugin.

0:27 I was playing with that a bit but this is a much better starting point.

0:27 Chouser: oh, I hadn't tried that.

0:28 abrooks: Chouser: Are you using Chimp?

0:28 Chouser: have used. I suppose I should try to set up some scripts or keybinding to make launching it easy.

0:28 abrooks: I let localmapleader=","

0:29 ,et is pretty easy to type

3:14 schlarf: when you guys use slime, is that clojure-mode for emacs or is it the normal slime?

3:14 or is it slime+enclojure-stuff?

4:27 man 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

4:32 hoeck: schlarf: 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

4:57 schlarf: Hmm 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?

4:57 method-lookup is internal btw

5:03 tWip: schlarf: I prefer none

5:03 Most times using functional programming, I don't need an object system in the traditional sense.

5:07 schlarf: ok but im implementing one anyway just to learn(lisp/clojure and how to create an object-system)

5:07 so might as well try to do something people might find useful

5:12 H4ns: schlarf: i'd suggest that you just go ahead and write one that suits you

5:23 schlarf: yes

6:30 cant i do : for key, value in zip(Map.keys, Map.values): do-something

6:30 like in python

6:30 i find no zip-function

6:30 i could ofc write one

6:31 zipmap

6:32 lol that was the pooopiste

6:32 opposite

6:32 H4ns: (find-doc "zip") may help

9:04 schlarf: how can i set intendation to 4 chars instead of 2? and always 4 chars...

9:04 im using clojure-mode for emacs

9:06 is lisp-paste-clojure not working?

9:18 rhickey: do you work on clojure as a part of your job or it is something you do in your free-time?

9:18 rhickey: schlarf: that question presumes traditional notions of 'job' and 'free time' :)

9:19 schlarf: lol

9:30 tWip: weird.. entering 08 or 09 results in ReaderError with number format exception

9:31 others like 02 evaluate to the expected number

9:31 rhickey: tWip: leading 0 means octal - 011 -> 9

9:32 tWip: ok, I thought that I must be missing something

9:32 rhickey: 8 and 9 are not valid octal digits

9:32 tWip: but that is a logical explanation, thanks

9:41 schlarf: how do i import? if i have a file object-system and i want it to be imported into my user.clj?

9:42 and how are the lookup-rules? like does it look in the currenct directory only?

9:44 rhickey: schlarf: Clojure uses the Java classpath system

9:53 schlarf: rhickey: 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)

9:53 doesnt work

9:54 nor does (.import ...)

9:54 Chouser: schlarf: the "right" way to do a lib is to put a file in a package and namespace subdir

9:54 like: schlarf/objectsystem/objectsystem.clj

9:54 schlarf: ok

9:55 Chouser: then you make sure that "schlarf"'s parent dir is in your classpath

9:56 like: java -cp clojure.jar:/my/dir (where shlarf is actually /my/dir/schlarf)

9:56 once that's set up, users can just say (ns foo (:require [schlarf/objectsystem :as sos])) and start calling your functions like: (sos/bar ...)

10:07 schlarf: does it really have to be that complicated?

10:07 Chouser: nope, though it's usually worth it in the long run.

10:07 schlarf: or wait maybe it osnt

10:07 Chouser: you could just say (load-file "objectsystem.clj")

10:08 schlarf: i cant find documenation on package and requie

10:08 Chouser: (doc ns) (doc require)

10:39 cooldude127: hey all

10:39 anyone using jambi with clojure?

10:41 abrooks: cooldude127: I think Chouser did a little once.

10:42 cooldude127: i 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:42 s/using to/using

10:43 abrooks: cooldude127: Do you have a jambi jar?

10:43 cooldude127: yeah

10:43 it needs two i think, one generic and one for the platform

10:43 i have them both, just not sure what to do

10:45 abrooks: I 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:46 cooldude127: mac os x actually

10:47 H4ns: cooldude127: 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:47 cooldude127: oh

10:47 H4ns: cooldude127: i find that easier to work with than messing with the environment.

10:47 cooldude127: i guess so, but it means i need to go back and look and swank-clojure and reconfigure it

10:48 right now i'm just loading the clojure jar

10:48 H4ns: cooldude127: it is a one-line change.

10:48 (well, except for the shell script thing) :)

10:48 cooldude127: yeah, what is the one line change?

10:49 the readme for swank-clojure isn't too clear

10:49 wait is it just swank-clojure-binary?

10:49 H4ns: right

10:49 cooldude127: instaed of swank-clojure-jar-path

10:49 ok

10:49 H4ns: that did it for me. i had to restart emacs to make that work.

10:50 cooldude127: should be enough i would think to reevaluate that, clear out swank-clojure-jar-path, and kill the slime and inferior-lisp buffers

10:50 but now saying all that makes restarting emacs seem much simpler

10:52 what would i put in my shell script? how does it want me to start clojure?

10:52 just a repl?

10:54 H4ns: there is this clojure-contrib shell script that i use

10:54 cooldude127: in the sourceforge project?

10:55 or github?

10:56 H4ns: github

10:57 achim_p: hi! this is not really a clojure question: has anybody successfully used Runtime.exec or ProcessBuilder for remote controlling interactive external processes?

10:58 starting 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:59 schlarf: right 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:59 achim_p: i 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:59 schlarf: or i could do (instance method)

10:59 and somehow have some lookup-dispatch-table

10:59 somethinglol

11:00 (instance $ method)

11:00 $ being a macro

11:01 can i have backtracking macros? how do i get a form like: (rec $ width) ?

11:01 if $ is a macro it can take width as a param, but how does it get rec?

11:01 i guess ($ rec width is more lisp-ish)

11:03 (load-file "file.clj") only works in currecnt directory?

11:04 i cant do (load-file "current/next-dir/file.clj") ?

11:05 Chouser: to invoke a macro, its name has to be at the front of a list (macro-name arg1 arg2)

11:05 schlarf: yeah works

11:13 what is a good symbol for using a method on object? ($ rec width) stinks

11:13 so does >>

11:14 (! rec width)

11:14 taken

11:14 (\ rec width)

11:15 (| rec 'width)

11:21 tWip: how about? (rec :width)

11:21 if objects are functions of their messages

11:22 Chouser: or (width rec) like multimethods already allow

11:31 peter_12: tWip: ++

11:39 schlarf: chouser: you prefer multimethods?

11:41 Chouser: schlarf: to what?

11:49 schlarf: uhm, message-passing?

11:49 single disptach?

11:50 Chouser: As far as I understand, clojure's multimethods are superset of regualr single-disptach object systems.

11:51 schlarf: but 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:51 Chouser: It's pretty easy to define a method that dispatches on the type of the first arg.

11:51 schlarf: yes (width rec) is easy, but (red width)?

11:52 red=rec

11:52 tWip: if your objects are functions

11:53 Chouser: or if they are objects that implement IFn

11:53 schlarf: right now they are references

11:54 Chouser: they could be functions that are closed around a reference

11:55 schlarf: could 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:55 cooldude127: anybody want to play a game of spot the error?

11:56 ava -Dpid=5760 -XstartOnFirstThread -cp .:/Users/mattmoriarity/usr/src/qtjambi-mac/*.jar:/Users/mattmoriarity/usr/src/clojure/clojure.jar clojure.lang.Repl

11:56 s/ava/java

11:56 brings up a repl but the jambi classes are non existent

11:57 Chouser: can you use *.jar in the classpath? I didn't know that.

11:57 cooldude127: i wondered, so i just tried it with the clojure jar

11:57 totally works

11:57 java -cp ~/usr/src/clojure/*.jar clojure.lang.Repl

11:57 brings up a repl

11:58 Chouser: ah, not quite the same thing. try .:/whatever/usr/src/clojure/*.jar

11:58 cooldude127: fcuk

11:58 *fuck

11:59 rhickey: try leaving off the .jar, just use *

11:59 cooldude127: zsh barfed on it when there were multiple components in the -cp arg

12:00 * only works when you have a single cp component

12:01 is my conclusion

12:01 adding ".:" to the front killed it

12:02 i guess it's the shell that is affecting that

12:02 Chouser: cooldude127: 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:02 rhickey: try putting '*'

12:02 no .jar

12:03 http://blogs.sun.com/mr/entry/class_path_wildcards_in_mustang

12:03 cooldude127: zsh cries with or without the .jar

12:03 which java is mustang?

12:03 is that 6?

12:03 cuz this is 5

12:04 Chouser: cooldude127: try with qoutes: java -cp ".:/foo/*:/bar/*" ...

12:04 cooldude127: k

12:04 i'm not sure what happened. it killed my terminal tab

12:04 wtf

12:04 it keeps doing that!

12:04 ahhh

12:05 still doesn't work. i don't think java 5 does wildcards in the cp

12:06 looks like i just have to list out the jars, cuz when i do that, everything is happy :)

12:11 ok my clojure script is working and loading the jambi classes

12:12 swing does have something going for it: the easy of setup (aka no setup)

12:17 lisppaste8: Chouser pasted "closing over a ref, for schlarf" at http://paste.lisp.org/display/68199

12:20 Chouser: where "sure" is "use" :-P

12:20 lunch, bbl.

12:29 cooldude127: ahh dang it. stupid jambi

12:29 i can get the simple hello world example to work in the terminal

12:30 but if try to do it from slime, i have some problems

12:33 abrooks: cooldude127: Is slime somehow not passing the CLASSPATH environment variable? Can you just add the jambi path to the java -cp commandline argument?

12:33 cooldude127: it's not that the jambi classes aren't loading

12:33 when i try to make an app

12:33 abrooks: cooldude127: Oh.

12:33 cooldude127: slime doesn't return to the repl

12:33 i enter my expression and it just sits there

12:34 abrooks: Does 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:35 cooldude127: the window does not come up is the problem

12:35 how would i do it in another thread?

12:46 alright new question:

12:46 trying to translate this java: quit.clicked.connect(QApplication.instance(), "quit()");

12:47 came up with this clojure: (.. b clicked (connect (QApplication/instance) "quit()"))

12:47 but i get this error: java.lang.IllegalArgumentException: More than one matching method found: instance

12:50 cmvkk: If 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:50 for example, if i want to dispatch on [:foo :bar], but if that doesn't exist, to default to [:foo :default]

12:51 or something like that

12:53 digash: blist

12:53 rhickey: cmvkk: you could (derive :bar :default)

12:54 * rhickey wonders if (isa? x Object) shouldn't be true for all x

12:55 cmvkk: aha, that would work, thanks.

12:57 cooldude127: how can (QApplication/instance) have multiple matching methods?

12:58 rhickey: cooldude127: I don't see how, are there online JavaDocs you can point me to? Does it derive from something generic?

12:59 cooldude127: here are the javadocs

12:59 http://doc.trolltech.com/qtjambi-4.4/html/index.html

13:00 com.trolltech.qt.gui.QApplication.instance()

13:00 i would have linked straight to that but i believe frames would not work with that

13:01 rhickey: 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:03 found a temporary fix: the superclass QCoreApplication has an instance() method that works fine and returns the right thing

13:04 but i still don't see how this was messed up in the first place

13:08 is there a way to import every class in a package?

13:09 Chouser: cooldude127: no, there is not. This is intentional.

13:09 cooldude127: ah man

13:10 cuz it would really make the repl more convenient

13:10 Chouser: but you don't have to repeat the package name. Just (import '(foo.bar Baz Bang Boom))

13:12 Pupeno: Hello.

13:12 cooldude127: yeah, but i'm not always aware when i do that of all the classes from the package that i want

13:13 so i have to keep going back

13:13 Chouser: Pupeno: hi

13:13 * Pupeno comes back from vacations eager to return to Clojure :)

13:13 cooldude127: bring it on the vacation :)

13:14 arohner: is the slime checkout working for anyone else? I'm getting connection refused

13:14 rhickey: cooldude127: it must have to do with the same-sig static method in the base class

13:14 cooldude127: rhickey: it's debating between the one in QCoreApplication and QApplication?

13:15 is that a clojure problem or jvm problem?

13:15 rhickey: cooldude127: shouldn't be, but is

13:17 cooldude127: ahh

13:17 that is not cool

13:18 rhickey: anyone know of an instance of that in the JDK libs - derived class and superclass with same-sig static method?

13:19 cooldude127: i wasn't even sure you could do that

13:23 oh snap time to learn how to make java objects in clojure :/

13:24 aquanaut: Hello

13:24 Chouser: aquanaut: hi

13:24 aquanaut: How does one open a file for reading or writing?

13:24 Chouser: cooldude127: "proxy" isn't too unpleasant

13:24 cooldude127: nvm no it's not

13:25 yeah i wasn't all that scared it looks simple

13:25 turns out i don't need to do that anyway

13:25 all these stupid qt examples do it put a bunch of initializer code in the constructors. they don't really override anything

13:25 i can do all this outside a class completely

13:25 aquanaut: Also, any ideas why clojure doesn't dispatch on singletons?

13:25 Chouser: aquanaut: (doc slurp) for files

13:26 aquanaut: what do you mean, dispatch on singletons? are you talking about static methods?

13:27 aquanaut: slurp brings the reads the file into a string, I need to keep the file open.

13:27 cooldude127: aquanaut: with-open

13:27 pass in a java.io.FileReader

13:28 basically just makes sure you don't forget to call close on your stuff

13:28 Chouser: aquanaut: 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:28 cooldude127: otherwise you're interacting with the java io stuff

13:28 Chouser: er, whatnot

13:28 cooldude127: with-open doesn't actually open anything :-)

13:28 * cooldude127 didn't know about that contrib stuff

13:28 cooldude127: i know

13:28 Chouser: it's more of a "with close" actually.

13:28 oh, ok.

13:28 cooldude127: lol yeah

13:31 oh duck streams looks nifty

13:31 i would say use that along with with-open

13:31 despite the confusing name

13:32 aquanaut: (defn fact [0] "off" [1] "on" [x] "unknown")

13:32 cooldude127: pattern matching is only on arity, not actual values

13:33 rhickey: that's not pattern matching, just arity overloading

13:33 cooldude127: yeah, that makes more sense

13:33 aquanaut: why no pattern matching on values?

13:34 rhickey: aquanaut: there's no pattern matching

13:34 cooldude127: EVER

13:35 rhickey: cooldude127: I didn't say that, but it's important to note that function args are just that, args, not patterns/conditionals

13:35 cooldude127: yeah i know

13:35 it confused me at first tho too. idk why i came to expect this

13:35 aquanaut: I understand the language doesn't support pattern matching, my question is what is the rational behind it.

13:36 rhickey: pattern matching is inextensible

13:36 cooldude127: so use multimethods instead?

13:36 rhickey: vs multimethods, say

13:36 cooldude127: ah

13:36 pattern matching is more succinct i would think in small cases like his

13:38 rhickey: aquanaut: (defn fact [x] ({0 "off" 1 "on"} x "unknown"))

13:38 cooldude127: when 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:38 OH

13:38 i like that

13:38 i wish you would have sent that before i typed all that bullshit

13:38 saved me some keystrokes

13:39 aquanaut: rhickey: I am not sure I understand how this works.

13:39 cooldude127: maps are functions that will lookup by key

13:40 the last arg is what to return if the key isn't in the map

13:41 aquanaut: But this will work only for methods with only one argument

13:41 cooldude127: yeahhhh

13:41 multimethods :)

13:41 aquanaut: What is the multimethod solution

13:42 rhickey: arity dispatch is direct - no conditionals, no counting, so any other conditionals must be done at the next level, in the body

13:44 lisppaste8: cooldude127 pasted "multimethods" at http://paste.lisp.org/display/68204

13:44 cooldude127: rhickey might be able to point out a better way but that was my multimethod solution

13:45 seems a tad verbose, but maybe a macro could fix it up?

13:45 rhickey: there'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:46 cooldude127: yeah, but i blew the stack when i tried to use maps

13:46 not sure why

13:46 (defn fact [x] ({0 1 1 1} x (* x (fact (dec x)))))

13:46 rhickey: cooldude127: you read fact as factorial, but that wasn't the function

13:46 cooldude127: i know

13:47 i went off in my own direction lol

13:47 aquanaut: cooldude127: you blew the stack beacuse of the lack tail calls

13:48 cooldude127: except for i only should have made 5 function calss

13:48 *calls

13:48 5ish

13:49 rhickey: that's not tail recursive anyway, call to fact is not in tail position

13:50 aquanaut: Thats right. It is just recursive

13:50 cooldude127: yeah. it shouldn't have blown the stack anyway with a (fact 5 call)

13:50 (fact 5) call

13:50 that is

13:51 johnwayn`: probably because the default value is going to be calculated first

13:51 cooldude127: the multimethod solution is the same code inside and it works fine

13:51 aquanaut: It blows it even for (fact 1)

13:51 cooldude127: OH

13:51 johnwayn` is brilliant

13:51 johnwayner: hardly

13:51 cooldude127: but you did figure this one out

13:51 johnwayner: I get one point :)

13:52 cooldude127: so the maps solution doesn't work out with a recursive function

13:52 rhickey: cooldude127: maps doesn't work with any function, just a mapping of values to values like the original question

13:53 cooldude127: yeah

13:53 i see that now

13:53 why can't everything be lazy?

13:53 :)

13:54 gnuvince: cooldude127: it is in Haskell (and it causes its share of problems too ;))

13:54 cooldude127: yeah i've done a little haskell. like the laziness, but the purity just makes things difficult sometimes

13:54 and yes the laziness can be annoying too

13:54 just less often

14:00 lisppaste8: johnwayner pasted "map factorial for cooldude" at http://paste.lisp.org/display/68206

14:01 johnwayner: :)

14:04 gnuvince: Why so complicated?

14:04 lisppaste8: cooldude127 annotated #68206 with "slightly better" at http://paste.lisp.org/display/68206#1

14:05 johnwayner: just proving I'm not "brilliant"...

14:05 cooldude127: lol

14:05 gnuvince: Any reason you're using a hash?

14:05 cooldude127: because we can

14:05 not the best way by any means

14:06 wwmorgan: why are there two base cases?

14:06 johnwayner: yeah...it's kinda a joke

14:06 gnuvince: How about: (defn fact [n] (apply * (range 1 (+ 1 n)))) ?

14:06 k

14:06 cooldude127: i would use reduce over apply

14:07 idk about clojure but other lisps have a limit on the number of args you can pass to a function

14:08 rhickey: (apply + (range 1000000))

14:08 cooldude127: ok i guess it's not a problem for clojure :)

14:08 rhickey: indefinite amount via apply

14:09 cooldude127: apply and reduce take about the same time

14:10 space-wise, who knows

15:07 lisppaste8: schlarf pasted "list and eval" at http://paste.lisp.org/display/68211

15:08 schlarf: ^^ can someone explain that. how to create a list and have ref in it

15:08 do i need a macro?

15:10 hmm i could pass as parameters to def-method perhaps

15:36 Chouser: If you want the value of i to change over time, it should be a ref.

15:36 I demonstrated that in my earlier paste, did you see it?

15:38 schlarf: it is a ref

15:38 i is a ref

15:39 if i list the value of ref is listed and the function performed, thus replacing witht he value of the function

15:39 if i quote then it is the char /symbol i not the value of i

15:42 i write like shit on irc lol

15:43 Chouser: from you paste, I can't really tell what you're doing. Can you provide a short but complete example?

15:43 by complete I mean: not referring to things without defining them

15:46 lisppaste8: schlarf pasted "oo-system" at http://paste.lisp.org/display/68214

15:46 schlarf: ^^ all the code, some is duplicated, im still refactoring and rewriting and far from done

15:47 danlarkin: schlarf: neat

15:51 schlarf: dan: thanks, i will make it more complete and perhaps have some meta-class-system to easily define your own ==-system

15:51 OO-system

15:52 solkis: Being 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:52 schlarf: slime = Superior Lisp Interactione Mode for Emacs

15:52 name should say all

15:54 solkis: schlarf: saw that... that's why I loaded it :-) now I want to know *what* makes it superior

15:56 I 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:56 shoover: clojure-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:57 (but some of the features in the menus aren't implemented yet for Clojure)

15:59 solkis: shoover: yes, I do have the menu... I'll check it out through that. thx

16:52 Pupeno: Do I have to define a function before using it in a file? like in C (without headers)?

16:53 drewr: It has to be defined before using it, yes.

16:53 You can do it in a file or at the REPL.

16:54 Pupeno: That's nasty :(

16:55 drewr: ?

16:55 Pupeno: I tend to have util-functions at the bottom of the files.

16:56 drewr: Every time you start a new JVM, it has to be loaded with code you want to have access to.

16:56 Pupeno: Actually, my files tend to look like:

16:56 (def a [] b)

16:56 (def b [] c)

16:56 I mean,

16:56 (def a [] (b))

16:56 (def b [] (c))

16:57 (def c [] 1)

16:58 schlarf: is there any advantage of single dispatch over multipel dispatch?

16:58 just easier to implemetn?

16:58 rhickey: you can pre-def things with (def x), then provide full def later

16:58 walters: schlarf: it maps to the virtual metal

16:59 Pupeno: rhickey: is there a reason why it doesn't just work?

17:00 schlarf: walters:you mean it is more like how a computer works whiole multiple dispatch is the more abstract concept?

17:00 Chouser: Pupeno: names are resovled at compile time, so that runtime performance is better

17:01 rhickey: names that can't be resolved could be bound in current-ns, but errors would be much harder to detect

17:03 Pupeno: So, what do you do? Have a C-style header, defing everything, or have the functions in bottom-up order?

17:03 rhickey: then 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:05 Pupeno: personal preference

17:05 cemerick: Pupeno: 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:06 Pupeno: cemerick: then you are using bottom-up order, I pressume.

17:06 rhickey: but yes, if you wanted a true top-down file you'd have more defs

17:07 cemerick: Pupeno: Not consciously. I also put a lot of effort into moving generally-useful fns into other namespaces.

17:07 rhickey: I 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:08 cemerick: It's a really minor thing, IMO.

17:08 rhickey: It was raised early on, but I don't get many complaints

17:11 Pupeno: I 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:18 lisppaste8: arohner pasted "stupid java print stack trace" at http://paste.lisp.org/display/68217

17:19 arohner: notice the "and 68 more lines" at the bottom of the stack trace? That's why we need to extend .printStackTrace()

17:19 rhickey: would you be accept a patch that does that?

17:19 rhickey: what do you mean by extend?

17:21 arohner: create a subclass of java.lang.Exception that has a working printStackTrace()

17:21 rhickey: I don't think so

17:22 arohner: well, my desired goal is not have java print "and 68 more lines"

17:22 rhickey: can't you just write a better stand-alone pst function that works with any exception?

17:23 arohner: oh, yeah, looks like you can using exception.getStackTrace()

17:25 ggbbgg: what does trailing '#' mean on symbols in defmacros ?

17:26 rhickey: ggbbgg: that's an auto-gensym - guaranteed to be a unique name, and every x# in the same ` expression is the same name

17:27 ggbbgg: thanks rich.

17:30 arohner: is it a bug that (macroexpand '(foo..)) generates a compiler exception?

17:31 I have a macro that is doing something broken, so I did (macroexpand '(foo...)) and I only get the exception

17:31 rhickey: what is ... ?

17:32 arohner: (macroexpand '(mk-validator validate-not-blank not-blank-pred "must not be blank"))

17:32 rhickey: works here

17:32 arohner: right, but mk-validator is my broken macro

17:33 rhickey: and the exception doesn't help?

17:34 arohner: I was surprised that I got a compiler exception instead of source code

17:34 rhickey: your macro is being called by the compiler, it is failing

17:35 the expander itself, not the expansion

17:40 arohner: ok, let me approach this a different way. can you create a defmacro that returns a defn?

17:40 rhickey: arohner: sure

17:42 Pupeno: lisppaste8: url

17:42 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

17:43 Pupeno pasted "defs" at http://paste.lisp.org/display/68220

17:44 Pupeno: I wrote a macro to define a bunch of names, (def a) (def b) (def c), like that. Can it be improved?

17:45 rhickey: Pupeno: looks ok, you might want to call it declare

17:46 good candidate for the standard lib

17:46 Pupeno: rhickey: thanks.

17:47 rhickey: macros to the rescue

17:47 Pupeno: rhickey: 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:47 rhickey: I'll add it

17:48 Pupeno: Ok.

18:01 lisppaste8: arohner pasted "no error or stack trace" at http://paste.lisp.org/display/68221

18:01 arohner: this looks to be the most isolated version of the problem I was having

18:01 though this doesn't have a stack trace, and I'm not sure why

18:06 danlarkin: macroexpand-1 gives (clojure/defn clojure.name__482@c610af [user/a] (clojure/println user/a))

18:08 I think you have a typo in that macro

18:08 arohner: I do, that was the point

18:08 danlarkin: oh

18:08 d'oh :o

18:11 is it something about using name like that?

18:11 arohner: name is an already existing function

18:11 I should have used ~fn-name instead of ~name, but I made a mistake

18:11 the point of the paste was that the error was not very useful

18:12 danlarkin: arohner: yeah you were way ahead of me

18:12 I'm caught up now though!

18:29 lisppaste8: johnwayner annotated #68220 with "more DRY" at http://paste.lisp.org/display/68220#1

18:32 johnwayner: Pupeno: Perhaps you can do something like that last annotation to save some typing.

18:35 duck1123: does anyone else have problems using slime with clojure

18:35 I'm running up to date on everything

18:36 I'm still getting "java.lang.Exception: Unable to resolve symbol: progn in this context (NO_SOURCE_FILE:1)"

18:36 johnwayner: are you using the clojure swank?

18:36 duck1123: yes

18:37 shoover: Somehow it's sending Common Lisp code to the clojure swank. Do you have (require 'swank-clojure-autoload) before (require 'slime)?

18:37 johnwayner: perhaps a paste of the appropriate parts of your emacs configuration would shed light?

18:38 duck1123: it looks like slime-init-command is generating the code

18:39 so swank-clojure has to be required first?

18:39 Pupeno: johnwayner: 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:39 lisppaste8: johnwayner pasted "slime emacs config" at http://paste.lisp.org/display/68224

18:39 shoover: duck1123: Yes, that autoload sets up some things so that the generic slime code knows which swank code to use

18:41 johnwayner: Pupeno: hmmm you'd probably have to tweak clojure-mode.

18:42 lisppaste8: shoover annotated #68224 with "there's always another way" at http://paste.lisp.org/display/68224#1

18:49 duck1123: thanks guys. I got it working with shoover's code

18:49 now to put back the rest of my .emacs file

18:55 danlarkin: johnwayner: what does this with-fwd-declare macro do?

18:56 johnwayner: it finds all your defn's and forward declares them so you can use them before you define them.

18:57 Pupeno was looking for way to do top down definitions

18:57 I'm not even suggesting this is the best way to do it. I'm a newb :)

18:58 danlarkin: johnwayner: oh, cool!

18:58 johnwayner: thanks :)

19:15 interesting... why does #(do `(def x)) work, but #(`(def x)) doesn't?

19:17 ooohh.... right. '(def x) isn't a function.

19:34 danlarkin: (#(`(def x))) doesn't work, but ((fn [] `(def x))) does

19:34 I wonder why that is

19:34 johnwayner: yeah... that's what threw me

19:35 Chouser: currently macros are just functions that return a list (of code), and are marked using metadata as macros

19:35 oh, nm, you'd not even dealing with macros.

19:35 sorry

19:35 johnwayner: but still interesting to knwo

19:37 is there a non-reader way of doing quoted syntax (`)?

19:37 Chouser: ah, the problem with #() is that #(foo) expands to (fn [] (foo))

19:38 thus (#(`(def x))) means ((fn [] (`(def x))))

19:38 johnwayner: yes, whatever you put in #() must be IFn

19:39 Chouser: right, and the LazyCons returned by `(def x) is not IFN

19:40 johnwayner: I guess it just seemed that ` was a short-hand for a function

19:41 or I guess I should say IFn

19:42 meh. doesn't matter... since that result would still need to be called as IFn since it heads a list

19:43 dinner time...

21:14 lisppaste8: johnwayner annotated #68220 with "ok, I'm done messing with this now :)" at http://paste.lisp.org/display/68220#2

21:16 rhickey_: I prefer (declare foo bar baz) preceding their use

22:18 Chouser: hmph. How much does performance matter when printing regex patterns?

22:22 rhickey_: Chouser: not much

22:24 aking: I 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:25 rhickey_: aking: (doc ns-unmap)

22:26 aking: rhickey_: cool - thanks. I also tried 'undef'.. was close :)

22:27 rhickey_: ns-unmap works for imports and refers too

22:54 yangsx: does 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:55 danlarkin: yangsx: can you clarify?

22:57 yangsx: danlarkin: 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:57 and vice versa

23:00 my slime-lisp-implementations contains both sbcl and clojure, and M-- M-x slime sbcl (or clojure) to run any one of them

23:04 danlarkin: Hm

23:09 the same thing happens to me... but that's with two slime clojures

23:09 yangsx: danlarkin: why two slime clojures?

23:13 danlarkin: working on two files at once

Logging service provided by n01se.net