#clojure logs

2008-10-23

00:08AWizzArdis (ensure ref) basically a lock?
00:19arohner`is there a good way to prevent "overwrapping" your arguments because of &rest args?
00:19arohner`i.e. (defn foo [& args] args) (foo (foo (foo 1))) => (((1)))
00:20arohner`or am I doing something wrong by getting into that situation?
00:30AWizzArdWhat would you expect should (foo (foo (foo 1))) return?
00:31arohner`I'm not sure. I'm just not aware of a clean solution to the problem
00:32arohner`I could say "if the rest argument is already a list, don't add another list around it", but that is very ugly
00:33AWizzArdI don't see the problem
00:33AWizzArdIf you do [& args] it means args will be a list.
00:36AWizzArdAsking "IF the rest argument is already a list .." makes not too much too much sense as it will always be one.
00:37arohner`I'm not sure if/where the problem is. All i know is that I'm passing arguments from one rest parameter to another, and I end up with big nested loops.
00:37arohner`i.e. that (foo (foo (foo 1))) example. I started with 1 by itself, and ended up with (((1)))
00:38AWizzArdoh, maybe you want to magically have the parens around the argument to be removed?
00:38AWizzArd(some-function rest) ==> as if you said: (some-function 10 20 30) and not (some-function (10 20 30))?
00:39arohner`yeah, sort of
00:39AWizzArd(apply foo (foo 1)) ==> 1
00:39arohner`I'm not sure what the right solution is
00:39AWizzArdyou need to apply these arguments, that's the right solution
00:39AWizzArdyou can not solve it otherwise
00:39arohner`huh. ok.
00:39arohner`I'll try that
00:39arohner`thanks
00:40AWizzArdapply is a "magic function" that you can not implement yourself for the current "level" of programming.. You would need to provide one for an interpreter inside your language.
00:40AWizzArd(+ 1 2 3) = (apply + '(1 2 3))
01:12Lau_of_DKMorning all! =)
06:31alvin-xwhen I run this snippet: http://paste.lisp.org/display/69045 with clojure.lang.Script, I see the output from println, but not data gets to the file on disk; if i do a (. output flush) or (. output close) the string does get to the disk....
06:31alvin-xis this a java thing or a manifestation of clojure's lazyness?
06:31alvin-x. out* not output
06:32tWipI think that's just bufferedwriter
06:32alvin-xprobably
06:39alvin-xit happens at the FileWriter level too; no output without flush/close.
06:43tWipwhat os?
06:43alvin-xwin32
06:44tWipdoesn't windows lock files that are open for writing?
06:46alvin-xi'm not sure; have to dig in MSDN. i just expect all buffered data to be written out on process exit.
06:46cemerickthat's definitely not something to be relied upon
06:48alvin-xisn't that supposed to happen in unix/posix at least?
06:49alvin-xmy process cleanly exited --- didn't die by a fatal signal or exception;
06:50cemerickI don't know about posix exit semantics, but no VM I've worked with will guarantee that anything is cleaned up before it exits.
06:51alvin-xhm
06:51cemerickActually, most specify that you should expect buffered data, finalizers, etc., won't be flushed/run/whatever
06:52Chousukedoesn't cost anything to just close everything at the end anyway :)
06:54alvin-xnot easy to know where "end" is sometimes, without a destructor mechanism...
06:55alvin-xno matter, i'll just flush whenever i write
06:55cemerickthat's what finally blocks/forms are for
06:56cemerickflushing on every write essentially eliminates the benefits of buffering
06:59alvin-xis there some form in clojure that i could use to ensure file closing?(with-open ?
07:01alvin-x:)
07:02cemerickyeah, with-open will automatically close the Closable object you bind in it
07:02cemerickI don't think there's a form that will autoflush, but most (if not all) outputstream impls flush on close iirc
07:04alvin-xha, this will work for JDBC too. nice.
07:05jaohi. in slime, when i compile a file (C-cC-k) and get errors, the compiler-notes window pops, but i cannot navigate from there to the error locations. is that normal?
07:05cemerickalvin-x: yes, indeed
08:38rhickeyanyone want to tackle a simple pprint for Clojure?
08:47jdzthat would be nice as hell :)
08:47cemerickand very helpful in enclojure
08:47alvin-xand probably non-trivial
08:48jdzwell, one could learn a lot from CL's pretty-printer
08:48rhickeya first cut could be much less ambitious yet useful
08:49jdzlike support for print-width and print-length
08:49jdzand depth
08:49rhickeyjdz: yes
08:49hoeckand printing 'foo instead of (quote foo)
08:51rhickeyI just don't see when I'll get time to do it myself
08:51jdzi could try doing it, but must finish a paper in a week...
08:51jdzand then there is some work queued after that...
08:51rhickeyWow - Clojure group just crossed 700 members and 5k messages
08:54Chousukeit says here it has 698 members.
08:54rhickeyMy admin screen says 712
08:54ChousukeI guess it hasn't updated yet, then
08:55ChousukeI just added myself.
08:55cemerickdb consistency isn't key on g-g :-)
08:56jdzcemerick: consistency does not like concurrence
08:58ChousukeI keep dreaming of making a roguelike game in clojure but I don't have enough time to get started :/
08:58cemerickI'd say that scalability is more the driving factor, but sure :-)
08:58Chousukeit'd just be so much fun to include a repl in-game
09:39lisppaste8j-dot pasted "*ns* binding" at http://paste.lisp.org/display/69052
09:40j-dotDoes anyone know why, in the code I just pasted, the 'bar var is set in the 'user ns instead of the 'foo ns?
09:41j-dotHow do I go about def'ing a var in another namespace from within a 'do or 'binding expression?
09:42wwmorganj-dot: (resolve 'bar) is nil when I run it. Could you have def'd it in user earlier?
09:43Chouseryeah, it's because *ns* controls the namespace resolution at compile time, so the original value is used when compiling that whole expression. By the time you actually bind and use in-ns to set it, it's too late.
09:44j-dotah, I see ... thanks, Chouser
09:44rhickeyj-dot: you need to control the ns where the code is compiled - the entire expression is compiled in the user ns, and def resolved there, then you execute the expression, getting runtime effects that don't matter
09:44j-dotThat makes sense, thanks
10:08rhickeylooking at proposed do-with, what is the preference - add do-with or breaking enhancement to doto (you'd just have to add . before method names)
10:09H4nsrhickey: better modify doto than having two things that do something subtly different in the base language
10:09ChouserI'd be content with a breaking change
10:09H4ns(certainly, i don't have a large code base that will break)
10:10Chouseresp. if it's coming at roughly the same time as a bunch of other simple structural breaking changes (like vectors for binding in if-let, deseq, etc.)
10:10Lau_of_DKGood afternoon gents
10:10ChouserLau_of_DK: hi
10:25walters_rhickey: is the asm code in clojure a permanent fork or is it safe to use the system asm library?
10:27charliekiloaplogize upfront ... I'm watching Cojure for Java Programmers ...I got everything installed (Clojure, Aquamacs, clojure-mode), can bring up inferior-lisp, butr CAN'T figure out how he does that two frames trick with evaluate line in clj document in the inferior-lisp evaluator ... what's the magic key combination?
10:28Lau_of_DKThe default in emacs is Ctrl-X Ctrl-X I believe
10:29rhickeywalters_: it's not really a fork, just a snapshot, using a more current version is really a matter of compatibility between ASM versions - what are you trying to achieve?
10:29tWipI think it is C-M-x
10:29walters_rhickey: we (Fedora) try to avoid shipping duplicated source
10:31rhickeywalters_: do you ship multiple versions of things?
10:31walters_rhickey: yeah, asm2 and asm3
10:31Chousukecharliekilo: two frames? do you mean how inf-lisp is at the bottom and the file buffer is at the top?
10:31charliekiloneither C-X C-X or C-M-x does not work for me ... is that part of Emacs or clojure-mode
10:32Chousukedo you have the clojure repl running?
10:32charliekiloChousuke: yep ... like he does in the video ... top has (. Math PI) and I'm truying to have 3.14... show up in bottom
10:33ChousukeC-x C-e works for me
10:33rhickeywalters_: the clojure asm is just a subset, just what's needed for Clojure runtime, done for size and ease of building
10:33charliekiloChousuke: the bottom has 'user=>' running and I can eval stuff there ...
10:33walters_rhickey: aright, i may try to do a patch then to optionally build vs system asm
10:34rhickeywalters_: ok
10:34Chousukecharliekilo: then you should be able to use C-M-x or C-x C-e to evaluate forms in any buffer that's in clojure-mode
10:34Chousukecharliekilo: if your buffer is in clojure-mode you should see a clojure menu in the menubar when the buffer is active
10:36charliekiloChousuke: ahh ... it top window one was not in clujure mode ... it works now ... awesome!! ... thanks alot !!!!
10:39rhickeywalters_: are you going to use jarjar or something to allow multiple libs to use different ASMs?
10:40walters_rhickey: that one is a bit of a mess; i think language implementations should probably use a private classloader for now; hopefully the Java 7 module stuff will sort this out somewhat more
10:41rhickeywalters_: I think private classloader is a non-starter, as classloader issues usually push up to library consumers, containers etc
10:41gnuvincerhickey: the "Differences with other lisps" page mentions that the Clojure reader is side-effect free. I'm curious about the kind of side effects the CL reader has; it seems like this ought to be a pure function, take in a stream of characters and produce a data structure.
10:41rhickeythat's why you see private-packages ASM
10:42rhickeygnuvince: the CL reader interns symbols
10:42walters_rhickey: well, you could only use the separate classloader for the compiler, the generated bytecode would still be loaded in the main classloader, i think that would avoid most issues
10:43rhickeywalters_: it gets really sticky, but the consumer often dictates classloaders, so I've been striving to reduce any dependencies on my own
10:43walters_rhickey: understood, yeah
10:44rhickeyI don't see a compelling reason not to sub-package ASM, it's so small
10:57lisppaste8Lau_of_DK pasted "Euler52 - Sequences" at http://paste.lisp.org/display/69055
10:57Lau_of_DKGentlemen, I have a case here, were all my debug-steps work as they should, but when I try to produce the end result by parsing a seq of seqs, I get an incorrect output. Can somebody show me the error of my ways ?
11:01ChouserLau_of_DK: can you include an example of find= working?
11:02Lau_of_DKWorking?
11:02Chouseryou have an example of it producing incorrect results, right? Can you include and example of it producing correct results?
11:03Lau_of_DKNo, because if it did produce correct results, we wouldnt be having this discussion :) But its a modded version of this: http://clj-me.blogspot.com/search?q=Google and it seems to work well for cgrande
11:03ChousukeLau_of_DK: nitpick: n-seq could be simply (iterate #(+ n %) n), no?
11:04Lau_of_DKIf you replace the + with a * then yes :)
11:04Lau_of_DK(btw., I like nitpicking, good to learn those things)
11:06Chousukewell, + is the correct function to get what your comment has. with * you get: (take 4 (mul-seq 3)) -> (3 9 27 81)
11:07Lau_of_DKoh ok
11:08Lau_of_DKbut, n-seq / map producdes the correct sequence
11:08Lau_of_DKIf you check the link to Euler, Im searching for the first hit where 1x n and 2x n ... 6x n, use the same digits
11:08Chousukemapping works but the multiplication is unnecessary. :)
11:08Lau_of_DKso it needs to be (1 2 3) (2 4 6) (3 6 9) ...
11:11Chousukewhoops. accidentally evaluated a lazy sequence in the repl ;(
11:11Chousukean infinite one, too
11:13ChouserChousuke: not uncommon, unfortunately.
11:13rhickey*print-length* patch welcome
11:14drewrIf I have a data structure of JdbcConnections that I set as available or unavailable in a ref, how what's the best way to block when all of them are busy?
11:14drewrs/how //
11:15drewrMy gut is that Clojure will handle this automatically, but I want to make sure I set it up right.
11:17rhickeydrewr: use j.u.concurrent for workflow: http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html
11:17rhickeymaybe Semaphore?
11:18rhickeybut there is so much presumption in your question
11:18rhickeyanother architecture is to put a fixed pool of resources in a queue - pull one off to work, put it back when done, will block on empty queue
11:18rhickeyI think that's better
11:19Chouserrhickey: you could just about maintain a todo list of things you're *not* going to do, that others could. pprint, *print-length*, due diligence on vector binding forms, etc.
11:20drewrrhickey: Thanks, that sounds like the behavior I want.
11:21rhickeyChouser: yes, definitely, just need to choose where. So far all of the free trac-like things I've seen allow anyone to enter tickets, e.g. Google Code
11:21Chouserrhickey: By the way, I spent last evening staring into Numbers.java. I think I get it now -- pretty clever set of indirections.
11:22rhickeyChouser: yeah, that still needs profiling
11:23rhickeybut so far perf is dominated by boxing rather than branching
11:23ChouserBefore understanding what was going on there, Clojure script was doing (+ 1 (/ 5 2)) -> "15/2"
11:23Chouserthat's close enough, right?
11:23rhickey:)
11:29Chouserunless the todo list is going to be terrbily long or have high turnover, you might just keep a text file in clojure-contrib, or a message pinned to the top of the google group.
11:33Lau_of_DKNo insights into my paste? :)
11:36ChouserLau_of_DK: I've got it loaded in a repl, but haven't learned anything helpful yet.
11:39rhickeyClojure's ToDo list: http://richhickey.backpackit.com/pub/1597914
11:40rhickeyI didn't realize the thing I was using had public viewing ^^^
11:40Lau_of_DKChouser, thanks, its good to know you're on it ! :)
11:40Chouserrhickey: heh.
11:40drewrrhickey: Nice!
11:40rhickeyI'll split off requests for implementations into it's own list
11:42rhickeyits
11:43Chouserah, that's good. Now I can know when to stop bugging you about patches I've sent in. :-)
11:44drewrLooks like LinkedBlockingQueue will do exactly what rhickey described.
11:56drewrhttp://bc.tech.coop/blog/081023.html
11:57drewrBit of JSwat example at the end.
12:13H4nsanother common lisper on the band wagon :)
12:16ChousukeLau_of_DK: I think I found the problem
12:17Chousukeat least, I managed to modify the algorithm so that it produces 142857 which seems to be the correct answer.
12:18Lau_of_DKCan you enlighten me and annote ?
12:19ChousukeLau_of_DK: your recur in find= seems incorrect
12:19hircusLau_of_DK: hiyas
12:20Lau_of_DKhircus, hey man :)
12:21Lau_of_DKOk Chousuke, please annote so that I can try and understand
12:21hircustried #76 yet?
12:21Lau_of_DKNot yet
12:21Lau_of_DKI'm almost done with < 50's
12:21hircuspretty much the SICP count-change problem, but with the number of choices being high enough that it's impossible to brute-force it
12:21Chousukeafter the first iteration seqs becomes ((2 3 4 5 6) (2 4 6 8 10 12) (3 6 9 12 15 18)), so you keep dropping the first element from the first sequence and sorting them until all the firsts match
12:21hircusah, you're doing it sequentially; I just scatter-shot the problems :)
12:22Chousukewhich in this case happens at 6 :/
12:22Lau_of_DKoh
12:22Lau_of_DKoh yes I see, its only the first seq that I (rest)
12:22Lau_of_DKHow did you cure it?
12:23ChousukeI did (recur (map rest seqs))
12:23Lau_of_DKyea Im trying that now
12:24Lau_of_DKThanks Chousuke, I really appreciate you putting in the work, I had starred myself blind on it
12:24Lau_of_DKHow long did it take to compute on your system ?
12:24Chousukehmm now I got a stack overflow error.
12:24Lau_of_DKHow did you reach 142857 ?
12:26Chousukeapparently the sorting is needed to keep it from overflowing the stack
12:27Lau_of_DKYea, for some reason, otherwise its quite redundant
12:27Lau_of_DKMine is still computing
12:27Chousukereally weird
12:28Chousukeis sort destructive?
12:28Chouserno
12:29Chousukewell what
12:29Chousukelisppaste8: url
12:29lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:31digash`http://www.google.com/trends?q=clojure&amp;ctab=0&amp;geo=all&amp;date=ytd&amp;sort=0
12:32lisppaste8chousuke pasted "weirdness" at http://paste.lisp.org/display/69058
12:32digash`i like this trend
12:33Chouserdigash`: nice. This will be fun to watch: http://www.google.com/trends?q=clojure%2C+lisp
12:33ChousukeI also modified n-seq to be just (iterate #(+ % n) n)) but the rest is the same
12:35Lau_of_DKChousuke, you really should anote, instead of pasting a new, gives better overview
12:35Chousukeah right, forgot the annotation capability.
12:36hircusLau_of_DK: oh wow, Petite Chez Scheme actually computes #76 by brute force
12:36hircustrying to work out a cleaner solution
12:37Chousukebut still that doesn't make sense. :/
12:37Chousukewhy does a let affect recur so that it doesn't overflow the stack?
12:38danlarkincertain forms can become reentry points or whatever
12:38Lau_of_DKhircus, looking forward to seeing it
12:38danlarkinI don't know if let is one of them, though
12:39hircusLau_of_DK: #78 is very similar and can't be brute-forced, so yes, will have to do it :) I just need pen and paper to work it out
12:40lisppaste8Chousuke annotated #69055 with "Weirdness" at http://paste.lisp.org/display/69055#1
12:40Lau_of_DKhircus, have a look at that paste
12:41Lau_of_DKChousuke, I should have asked, sorry, I pasted in your name, a complete copy of your other paste
12:41Chouserlet is not a recur target. I can't figure out what's going on.
12:41hircusweird!
12:41Lau_of_DKChousuke, that one where you say "this works", doesnt return on my system, I dont get a reply
12:42hircuss1 & etc were not even used at all?
12:43Lau_of_DKno, not in Chosukes attempt
12:43hircus..
12:43ChousukeLau_of_DK: it does on mine
12:43Lau_of_DKreally, what is your secret?
12:44Lau_of_DKbecause using your exact code... does not return :)
12:44lisppaste8Chousuke annotated #69055 with "my n-seq" at http://paste.lisp.org/display/69055#2
12:44ChousukeLau_of_DK: try with that.
12:45hircushow should n-seq.. oh
12:46Lau_of_DKoh, sorry me
12:46Lau_of_DKsilly me
12:46Lau_of_DKeven
12:46hircusLau_of_DK: was your n-seq eagerly-evaluating?
12:46Lau_of_DKno, it was lazy
12:46hircusso.. still not sure what was the problem
12:46Lau_of_DKoh wait
12:46hircussort will force evaluation, right?
12:46Lau_of_DKtypo - I was fiddling with it a minute ago, corrupted it
12:47Lau_of_DKsort (in this case) only deals with the head
12:47hircusthat's the only difference I could think of
12:47hircusyes, but sort forces evaluation of the entire sequence
12:47lisppaste8Chouser annotated #69055 with "also works" at http://paste.lisp.org/display/69055#3
12:47Lau_of_DKanyway, the Euler is solved, but it raises a question about stack-usage
12:47Chouserhircus: I think that proves your hypothesis.
12:48hircusChouser: the last paste? looks like it
12:48Chousukeso it was being too lazy? :/
12:48hircusa bit surprised that lazy sequences are put on the stack, but hey
12:48Lau_of_DKChouser, you run doall on infiniate sequences?
12:48Chouserthis isn't the final answer.
12:48ChouserLau_of_DK: no
12:49Chouserdon't run sort on infinite seqs either. :-)
12:49Lau_of_DKAmericans...
12:50hircusseems easier to do #52 by converting to strings, anyway
12:50Chousuke(map n-seq [1 2 3 4 5 6]) is a finite sequence of infinite sequences; the doall just forces the n-seq to be called.
12:50Lau_of_DKhircus, can you run it in 2 secs with strings ?
12:50hircusfor a number, convert to a string then to a seq of chars then sort
12:50hircusaha, no
12:50Lau_of_DKChousuke, OH!
12:51Lau_of_DKI didnt know that
12:51hircusactually, I can
12:51hircus0.174secs in Python
12:51Chousukeremoving the doall from find= and putting it in the find= call like so (find= (doall (map n-seq [1 2 3 4 5 6])) will work
12:51hircusstart it at 125874, though, no need to start from 0 :)
12:52Chousukewhoops, missing a parenthesis
12:52ChousukeI wonder if irssi has a syntax highlighting plugin :/
12:54Hunhmm... one could use emacs rcirc + multi-major-mode for this
12:56Chousukethis stack overflow problem looks like something that might bite again if there's a lot of laziness :/
12:56Lau_of_DKChousuke, I believe youre right
12:57Lau_of_DKI had to take off, but I'd like to thank everybody who helped bring me up to speed, youve been a fantastic help!! Have a good evening
13:01gnuvinceHas it been discussed here how to translate the "classical" Haskell solution for sieve of erasthesomethings to Clojure? In Haskell it's usually: let { primes = sieve [2..]; sieve (x:xs) = filter [n | n <- xs, n `mod` x /= 0] }
13:09gnuvincehmmm
13:09gnuvinceare LazyCons really lazy?
13:24leafwcan one make a function that takes multiple sets of arguments (easy). but where some of these are private? I.e. [x] is private, but [x y] is public.
13:25gnuvinceleafw: I don't think you can. Use a nested function for that.
13:25leafwok
13:25leafwthanks
13:26leafwbut aren't nested functions public? Perhaps defined only in a let, I guess
13:27leafwoh, or with #^{:private true}, I guess
13:34leafwcan't a function refer to itself within its own declaration?
13:35lisppaste8leafw pasted "fibonacci" at http://paste.lisp.org/display/69060
13:36leafwfirst one works, second fails to compile
13:36wwmorganleafw: try using a named anonymous function
13:36leafwsorry: named anonymous function?
13:37leafwisn't that what the let is doing in this casE?
13:38lisppaste8wwmorgan annotated #69060 with "compiles" at http://paste.lisp.org/display/69060#1
13:38gnuvinceleafw: let don't allow recursion.
13:39leafwthanks people. That (fn this [...] ) is new to me.
13:57Hunleafw: you could do it like the second one by implementing the y-combinator
13:59gnuvince@url
13:59gnuvincelisppaste8: url
13:59gnuvincelisppaste8: url?
13:59lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
13:59lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
13:59leafwHun: show me
14:00gnuvinceleafw: did you try the infinite fib list solution?
14:00lisppaste8gnuvince pasted "How's this implementation of rests?" at http://paste.lisp.org/display/69061
14:00Hunleafw: i don't have a running clojure on this machine, so this might not work
14:00Hun(defn y (fun)
14:00Hun (fn [& args] (apply fun fun args)))
14:03lisppaste8Chouser annotated #69061 with "Another "rests"" at http://paste.lisp.org/display/69061#1
14:04leafwHun: haven't ever used the y-comb
14:05leafw've read about it, that's all.
14:05leafwyour impl looks .. will trye
14:05Hunthe basic idea is that the function gets itself as its first arg
14:05Hunwhich is what y does on the fn
14:05Hunend the function defines where to recourse
14:06leafwandinitial args to the fun are passed how?
14:06leafwtrying
14:09Hunthey are passed through to the function. that definition might not work, depending on how apply works in clojure
14:10AWizzArdMoin
14:57lisppaste8jochu annotated #69060 with "Using an infinite lazy seq" at http://paste.lisp.org/display/69060#2
15:38leafwwoah : jochu, that was awesome.
15:39leafwalthough I don't understand it.
15:40leafwlazy-cat concats two sequences, but you give it an array [0 1] and then the result of a mapping that involves sums, but I don't see how it sums the right pair of numbers.
15:41leafwsomehow, the lazy-cat is defining the fibonacci sequence itself, in abstract form. This is briliant, reads almost like prolog
15:42Chouseryeah, impressive. The summing is of each fib and fib offset by one (via rest)
15:45duck1123how can I retrieve just the doc-string of a function? (doc) prints it, but doesn't return anything and (meta) doesn't return it either.
15:46wwmorganduck1123: (with-out-str (doc doc))
15:47wwmorganalso (:doc ^#'doc)
15:48duck1123that's what I wanted
15:48duck1123thanks
16:00AWizzArdrhickey: Thanks for your comments about Currying Rich. I still think we could do it, with something else instead of #(). Maybe �() or something like that.
16:02ChouserAWizzArd: I don't know how to type that thing.
16:02duck1123that's going to be hell to type
16:02ChouserAnd although it looks ok in the browser, in this window it just shows up as the rectangle used when a font doesn't have that glyph.
16:03AWizzArdyou all still use this 1886 keyboard layout yes? ;-)
16:03cemerick� is option-6 on Macs, fwiw
16:03AWizzArdThis qwerty stuff
16:03AWizzArdShift 3 I guess on qwerty maybe?
16:03Chouserserved me well so far
16:03H4nsAWizzArd: it is not ascii, forget it.
16:04AWizzArdH4ns: why not doing unicode? I would like to have greek symbols in my source. My keyboard layout can produce them so easily.
16:04H4nsAWizzArd: you certainly don't want things in the base language that only germans can type with reasonable effort
16:05rhickeyI was thinking of something like this for apply/curry: #(@ + 5), where #(@ ...) means (fn [& args] (apply ... args))
16:05AWizzArdWell sure, and the � is just an example. It can be anything else that makes sense. My point is just: let us have currying.
16:05rhickey@ being special as first form in #()
16:05duck1123we should start using ? in code instead of #()
16:06H4nsAWizzArd: your point is: rhickey, implement currying! :)
16:06rhickeybut not sure about more symbol overload
16:06rhickeycurrying is overrated
16:06H4nsi like partial application a lot, but i don't need no fancy syntax for that.
16:06rhickey#() is pretty neat as is
16:07AWizzArdH4ns: well yes, I showed my implementation of it in Google Groups. I just can't implement reader macros.
16:07duck1123rhickey: the doc-string for -> has a redundant 'macro' in it.
16:08AWizzArd!(rgb _ 123) or having the @ or $(..) or whatever.
16:10rhickeythere's already partial and #(), this doesn't seem pressing
16:12gnuvincecurrying is, in my opinion, one of the two pillars of unreadable Haskell code.
16:12rhickey:)
16:12Chouserheh
16:13gnuvincethe other is succinct function composition
16:13gnuvinceCheck the forums of Project Euler, especially answers from the French Jedai
16:14gnuvinceit's 3 lines of nothing but function composition of curried functions with a bunch of curry, uncurry and flip thrown in for good measure.
16:18AWizzArdI see partial as not too useful. The whole idea behind currying is to have syntactic sugar, to save a few keystrokes. So, (partial ..) is too long imo.
16:29duck1123what is the difference between a var quote and a normal quote?
16:30duck1123nvm, I found it
16:35Chouser(partial foo) seems a _bit_ nicer than (fn [& x] (apply foo x))
16:36Chouserand even a bit nicer than #(apply foo %&)
16:48meredyddChouser: Also, doesn't (partial) date from before the introduction of #(...)?
17:08Chousermeredydd: I think so
17:11schwartzwaldwhat do clojurers think of scala?
17:11schwartzwaldclojure is an alternative, not a replacement for java right?
17:12ChouserI came to clojure seeking refuge from Scala's type system.
17:12kotarakscala seems to be more verbose in syntax than Clojure or ML...
17:12schwartzwaldor it would be a reasonable to write JAVA(enterprise)-stuff in clojure? i tried scala bu it felt pretty heavy and unflexible, like java
17:12AWizzArdChouser: yes, but $(foo) is even nice than #(apply foo %&) or (partial foo)
17:12schwartzwaldyes scala seemed great on paper but it didnt feel good
17:12AWizzArdClojure is a functional programming language. It makes sense to have currying.
17:13Chouserschwartzwald: I don't know why you wouldn't be able to write whatever you want in Clojure. It's pretty practical.
17:14kotarakAWizzArd: How do you distinguish: (defn foo ([x] ...) ([x y] ...)) $(foo z)?
17:14Chouserkotarak: apply does that for you.
17:15AWizzArdapp.. yes
17:15Chouserif you replace $(foo z) with (partial foo z)
17:15kotarakChouser: I was asking for currying. When I curry, how do I decide which form to use?
17:16AWizzArdkotarak: can you be more specific?
17:16kotarak(foo z) is legal. (foo a b) is also legal. What does $(foo z) mean, the first or the curried second?
17:16AWizzArdbtw, I want to replace $(foo z) with (fn [& args] (apply foo z args))
17:17AWizzArdif you want to curry away some earlier args you would do it this way: $(foo _ z)
17:17AWizzArdjust read in google groups, it's explained there
17:17AWizzArdhttp://groups.google.com/group/clojure/t/36c77eec86a0930b
17:18AWizzArdI used #(foo _ z) in that posting, but rhickey gave good arguments why to leave #() untouched so far. Now I suggest to think about having some other character. And that could even be recycled for a later addon like an infix reader for math.
17:19AWizzArdWe just need some other symbol than #. It could be a $ or a ! or maybe <foo _ z>.
17:20AWizzArdI would implement it myself as a reader macro, but at this point CLJ doesn't allow us to access the *readtable*, so read macros need to be written in assem... in Java.
17:20wwmorganAWizzArd: you could implement it as a non-reader macro too, right?
17:21AWizzArdyes, and I did that, just click the link
17:21AWizzArdIt's also not bad, but I think ($ < 5) is not as nice to read as $(< 5)
17:33emacsenrhickey, so, I've been reading about Lisp50, and here's the problem Clojure has. All the great language designers are weird looking. There's even a site my gf sent me to: Language designer or serial killer. You have to match the photo with the description. You look like a normal, regular (non-geek) man. Thus, I'm afraid, Clojure may be doomed to failure.
17:33emacsen;)
17:34Hunpopcorn and tacos for everyone!
17:37emacsenHun: It's mainly a joke. I actually disagree with McCarthy. Languages /do/ need a single face, at least in the beginning.
17:38Huntrue. i also believe that anybody needs a big beard. not that i have one though :/
17:38emacsenbeards are really optional. that's more a Unix thing
17:39wwmorganhttp://blogs.microsoft.co.il/blogs/tamir/archive/2008/04/28/computer-languages-and-facial-hair-take-two.aspx The English really makes it hilarious
17:45danlarkinI wonder when I'll become a famous language designer
17:48waltersthe fact that matz grew a beard just for that article is awesome
19:29blbrownhttp://groups.google.com/group/clojure/browse_thread/thread/f07b1a70eab5f8e2 anyone have an answer for this one
19:34Chouserblbrown: you want that for all functions defined after a certain point? Or just certain functions?
19:34blbrownChouser, ideally of them. And the ability to print when a function is called is just one example. E.g. I might want to time how long a function executes
19:38blbrownChouser: going to leave me hanging?
19:40Chouserblbrown: I think it's possible, but it's hacking around at a level I don't have much experience with.
19:40Chouserso I'm trying some things.
19:41shooverWhat about using the ns-* functions to get all the symbols in a given namespace. You could test a symbol's metadata to see if it's a function, then rebind thread-locally using binding and set!. Of course, that will only hold as long as you're in the binding scope.
19:41blbrownthey say in lisp, you can use macros to achieve what I want
19:41blbrownshoover: that is an idea
19:41Chousershoover: ooh, that's better than what I'm trying.
19:43shooverRich always mentions binding when people talk about logging and timing, so it should work
19:44Chouseryeah, now that you describe that, I think I may have seen code for it go by on the google group
19:45shooverblbrown: and you can wrap all that binding stuff in a macro, so there's your lisp way
19:45blbrownshoover: you have some code or examples I can look at. I will give you a reddit karma point if you code up something in 10 minutes
19:48shooverChouser will beat me now that he knows what to do :)
19:49Chouserhehe
19:50shooverlisppaste8: url
19:50lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
19:50lisppaste8shoover pasted "wrapping an existing function" at http://paste.lisp.org/display/69085
19:50lisppaste8Chouser pasted "trace" at http://paste.lisp.org/display/69086
19:50shooverno macro there, but it shows the binding process
19:53shooverChouser: nice, with the var-get and trace-fn
19:53blbrownIf you have used ASM, I did it with asm (and obviously reflection) but I was also looking for the clojure way. http://asm.objectweb.org/
19:54blbrownChouser, shoover: thanks guys
19:54shooverI thought there was something in the metadata to flag a fn, but I don't see it now that I look at my ^#'bar
19:55Chouser:arglists ?
19:56shooveryeah, that's close enough, as long as it doesn't have the macro flag
20:36emacsenanyone know if there's audio/video of lisp50?
20:37rhickeyThey recorded it, but I don't know that it's available yet
20:37emacsenk
20:43lisppaste8Chouser annotated #69086 with "trace namespace" at http://paste.lisp.org/display/69086#1
20:46Chouserblbrown: That's as far as I'll mess with it.
20:46ChouserI imagine you could make is so that the details of trace-wrap could be passed in.
20:48blbrownChouser, that is cool, thanks
21:03duck1123is anyone here familiar with compojure
21:04duck1123I'm trying to figure out how I can create a folder under app/ and have a file in there named other than the folder's name
21:22chrisdonerhickey: what is the font used in your Clojure for Lisp Programmers presentation (up on Blip.tv)? it's gorgeous and I want it!
21:24danlarkinchrisdone: looks a lot like Monaco to me
21:28rhickeychrisdone: yes, monaco for the code
21:29duck1123_is it possible to have clojure files named other than the name of the last folder?
21:29chrisdonedanlarkin, rhickey: thank you :-)
21:30danlarkinduck1123: it sure is
21:31duck1123I'm trying to set up my namespaces for compojure, but it keeps wanting me to name it the same as the folder name
21:31crathmansince the wiki says that sicp is not optimal for learning clojure, figured I'd be a contrarian.... :-)
21:32crathmanchapter #1 has been translated to clojure - http://www.codepoetics.com/wiki/index.php?title=Topics:SICP_in_other_languages
21:33duck1123otherwise I get: Could not locate Clojure resource on classpath: mycyclopedia/view/view.clj
21:33danlarkinduck1123: having not used compojure I can't comment on any naming scheme it enforces
21:33danlarkinduck1123: but I can say the limitation isn't one imposed by clojure itself
21:33duck1123I don't think it really imposes anything other than what clojure does
21:35duck1123the wiki pretty much says to do the same thing: Now we have to create a file in the classpath with the filename "example/ourlib/ourlib.clj".
21:36danlarkinwell I've been using files that are named differently than their containing directory, but perhaps I'm doing things different
21:37duck1123do I have to explicitly add the folder to the classpath, or do you happen to have an example?
21:37duck1123I noticed that clojure.contrib uses the same pattern
21:50Chousernaming the .clj the same as its folder allows the .clj to be loaded via the ns macro, require, use, etc.
21:51duck1123_so if I wanted to name it something else, I couldn't use the ns macro
21:52Chouseryour file could still use ns, but nothing else could load your file using ns.
21:52duck1123_so how would I load it? That may almost be acceptable in this very limited senario
21:53Chouseryou could use load or load-file
21:53duck1123_this file would only ever be loaded by one other file, I would go the proper route for anything else
22:25ericthoranything change on the gen-class front recently? I have a clojure gen-class extending a java class. I have a mypackage/ClassName/ClassName.clj...
22:26ericthorand the function names are (defn ClassName-extendedClassFunc[this])
22:26ericthorI can create an instance of the class but when I call any function I'm getting an AbstractMethodError...this used to work?
22:30Chouserwas it working since the fn names changed to ClassName-fnName?
22:32ericthorChouser: it worked as fn names are classname-fnnames
22:32ericthorChouser: has that changed since?
22:34ericthorChouser: might be time to redo my genclass stuff...going to turn in. Thanks for the help
22:34ericthorChouser: I probably just have some out of sync clojure stuff
22:35ChouserThere were changes to genclass in August, but none since.
22:51larrytheliquidif i have a map that has a certain key, and a function that takes a parameter that would ideally be the same name as the map key, is there a convention to distinguish the two?
22:51larrytheliquidie: description vs description-param
23:02ChouserI don't think I understand. It's common to use keywords for map keys.
23:03Chouserdoes that help?
23:06larrytheliquidsay i have something like (defstuct my-data :description), and then (defn do-something [description] ... )
23:07larrytheliquidinside do-something description would shadow the description method in the struct
23:09Chouserah, for structs!
23:10larrytheliquidah nevermind, i didn't realize that the symbol in the struct :description would be part of the method name too
23:10larrytheliquidso no conflicts
23:10Chouserum, no convention I'm aware of.
23:10larrytheliquidthe colon*
23:10larrytheliquidthe colon takes care of the difference
23:11Chouserok, good.
23:14ChouserI can't get definline to work. Anyone know how to use it?
23:22duck1123has anyone here managed to get slime working with compojure?
23:23duck1123I can get standard clojure working, sbcl works, but I keep getting that stupid progn error when I try to use compojure