#clojure log - Feb 05 2008

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

8:59 scramflot: general question about syntax: (defn make-adder [x]

8:59 (let [y x]

8:59 (fn [z] (+ y z))))

8:59 in the above example, for instance.

9:00 is what is in the [] following the definition of a symbol (or whatever) always a parameter?

9:00 and, seeing as how it is an [], is that a vector?

9:06 And, for instance, do the parameters to the definition of a vector always have to be passed in by a [] (vector?)? or can it rather be an {}?

9:09 bgeron: iiuc, x and z are parameters

9:10 * bgeron thinks he has way less clue than rhickey about this

9:18 scramflot: well, I think I'm tracking that.. but in the let's [], an assignment seems to be happening, while in definitions it's more like parameters. Anyway, I've got to go, but I'll be back and I'll check back on the logs to see if there've been any comments.

11:49 correction... perhaps assignment is the wrong word. let's [] is doing "bindings" ..

16:40 jgracin: wow, 10 users! most of them are blackdog, but this is a record on #clojure, nevertheless. ;-)

17:08 scramflot: and so jgracin

17:08 leaves

17:09 Anyone get the syntax file to work for vim on ubuntu?

17:10 LunarCrisis: I've got one working on gentoo

17:12 scramflot: my vim/gvim doesn't seem to use ~/.vimrc or ~/.vim/syntax

17:13 So I tried modifying /usr/shr/vim/syntax and .vimrc there, and no worky

17:13 I am pretty worthless though, so that could have something to do with it

17:15 um, I mean /usr/share/ blah blah

17:29 LunarCrisis: hmm

17:30 your .vimrc doesn't work at all?

17:30 perhaps you should ask in #vim

17:33 scramflot: aye

17:43 is "accessor" a built in symbol?

17:53 That's pretty cool: (defn string-from-byte-sequence [coll] (reduce strcat (map char coll)))

18:24 Wondering if rhickey would want the reference moved over from the website to the wikibook

19:39 hmm.. so what do you guys think? rich hickey said he wanted to docs moved over, right? After all, there is a section on the site named "Reference".. I'm just going to submit the page I've migrated and if he wants he can just take it off or ask me to

20:43 rhickey: Hey, I added a page to the wikibook

20:44 rhickey: was that the material copied from the Clojure site?

20:44 scramflot: yea

20:45 I see it's gone.. guess you removed it?

20:45 rhickey: That's not ok - the Clojure site is copyrighted - please don't copy it. The wiki is for new original material.

20:45 scramflot: ok.. ma'bad

20:48 It's just that there was a section called "reference," just like on your website, so i figured you'd want it moved over. It's not like I was trying to steal or anything though, obviously.

20:49 rhickey: I didn't put the reference placeholder there, someone else added it

20:50 scramflot: oh. well, I didn't put it there. I was just trying to help you out. I don't want you to think there was any impropriety on my part.

20:51 rhickey: I put some advice at the top now so people will know not to do that.

20:59 scramflot: rhickey: now that you're here... when [] is used for binding, like in (def a [b] b), is that actually a vector or just syntactic notation?

21:00 ermm. not binding

21:00 I mean parameters

21:00 rhickey: the names in the vector get bound to the corresponding parts of the argument

21:01 scramflot: but one wouldn't see (def a (b) b) ever?

21:03 or even (def a {b} b)

21:09 travisbrady: i'm a complete newb (i'm a python programmer with some haskell experience) and i'm working through the Getting STarted page

21:09 and in trying to run: java -cp jline-0.9.91.jar:clojure.jar jline.ConsoleRunner clojure.lang.Repl src/boot.clj

21:10 i get: Exception in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner

21:10 i assume this is a CLASSPATH issue, but i can't really make heads or tails of it

21:10 scramflot: travisbrady: rplace jline with it's absolute path

21:10 travisbrady: anyone know what that is off hand?

21:10 scramflot: replace

21:11 In fact, put all absolute paths in there, then make a shell script to just run it.. much easier

21:11 rhickey: scramflot: there's no structural binding in def

21:11 scramflot: rhickey: yea, I think I messed up my example

21:12 travisbrady: is JLine included with the clojure zip? or will i need to install that?

21:12 scramflot: (def a [b] b) (a 1) doesn't return 1, right?

21:13 travisbrady: anyway, great job Rich and team with the clojure site and docs

21:13 scramflot: no, there should be a link to it on the page where you saw the line

21:13 travisbrady: scramflot: ok, thank you

21:13 rhickey: there's no team :)

21:14 scramflot: (def a [a b c]) actually binds the vector to a

21:14 rhickey: binds a to the vector, yes

21:14 travisbrady: rhickey: just wanted to be inclusive

21:15 rhickey: excellent job to you then

21:15 scramflot: (defn nice [a] a) (nice 1) returns 1 then

21:15 rhickey: right

21:16 travisbrady: if you can deal with emacs, clojure mode there is much more powerful than jline

21:17 travisbrady: rhickey: yeah, i'm setting that up now

21:18 scramflot: so, I guess what I'm asking is.. would this work? (def b [1]) (defn nice b (b)) -> 1 .. because b is a vector?

21:19 or.. no

21:19 cause defn doesn't evaluate until you pass it values

21:19 rhickey: right

21:20 it is a macro that processes forms

21:20 the form b is not a macro, it's a symbol

21:20 er, is not a vector

21:20 scramflot: right right

21:21 could one expand a symbol into a vector at the time of macro processing?

21:21 rhickey: no

21:22 scramflot: I guess what sparked the question in my mind was the bit about eval and programmatic evaluation

22:08 trying to list the files in a directory:

22:08 (import '(java.io File))

22:08 (defn ls-f []

22:09 (let [file (new File "home/john/tmp")])

22:09 (. file listFiles))

22:10 CompilerExecptoin: Unable to resolve symbol: file in this context

22:11 And here's the code I'm trying to move over: http://www.rosettacode.org/rosettacode/w/index.php?title=Walk_Directory_Tree#Java

22:11 (eventually it'll walk the directory

22:11 )

22:11 rhickey: let only binds file until its closing paren

22:14 scramflot: oh

22:14 misread the swing app example.. thanks

22:18 If listFiles returns an array, do I have to parse that a certain way? Or can I just leave (. file listFiles) as the last expression and have the function return an array?

22:21 user=> (defn ls-f [] (let [file (new File "/home/john/tmp")] (. file listFiles))) has Clojure talking about parse errors

22:22 CompilerException: REPL:27: listFiles

22:23 rhickey: I appreciate your enthusiasm, but I think you need to spend some more time with the Clojure docs, and double-check your work before asking here

22:23 e.g. (. file (listFiles))

22:28 scramflot: but there's no args. "(. instance-expr instanceFieldName-symbol)" I do see now that the swing app does use the parens for everything. I'll try to keep the chatter down.

Logging service provided by n01se.net