#clojure logs

2008-10-05

01:08duck1123how hard would it be to modify the documentation system to include a direct link to the actual source code
01:09duck1123even better, it could use javascript or something to color code, and display inline
02:12danlarkinduck1123: that would be neat
05:02Pupeno1lisppaste8: url
05:02lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
05:02lisppaste8Pupeno pasted "synthetize" at http://paste.lisp.org/display/67955
05:03Pupeno1Is there a better way to write that code? 5 lines of code and 2 are almost the same.
05:05Hunyou could use pg's old aif-macro. that makes it at least a bit shorter
05:05Hunwhat does synthesize-content return? if it's just nil, what goes wrong when nil is used for :content?
05:12Hunhmm... intentional variable capture seems to be hard in clojure
05:13lisppaste8Hun pasted "Nonworking aif for clojure" at http://paste.lisp.org/display/67956
05:23lisppaste8H4ns annotated #67955 with "dry" at http://paste.lisp.org/display/67955#1
05:26hans_dang. Pupeno1, seen my paste annotation?
05:27Huni saw it
05:27lisppaste8hoeck annotated #67955 with "into" at http://paste.lisp.org/display/67955#2
05:28H4nshoeck: also nice
05:29hoeckH4ns: more general, allows applying more "optional" keys
05:30H4nshoeck: that is true. also, less visual clutter
05:30Hunhmm... is intentional variable capture just hard in clojure or doesn't work at all?
05:31hoeckH4ns: but the conj approach suits better when there will be only one optional entry
05:31hoeckHun: its possible, use ~'foo in your macro
05:34lisppaste8heock annotated #67955 with "conj" at http://paste.lisp.org/display/67955#3
05:36H4nshoeck: you don't like [], {} for a reason?
05:37H4nsnever mind me.
05:48Pupeno1Thanks for the annotations.
05:49Pupeno1The reason why I'm avoiding having content when it's nil is because I need to see the data and understand it, and having a content nil there makes it harder to read and understand the data.
06:04lisppaste8H4ns pasted "Trivial HTTP server" at http://paste.lisp.org/display/67958
06:04H4nswow. having mastered the initial hurdles, using java libraries from clojure really is straightforward
06:25Pupeno1I really need a pretty print, isn't there one anywhere?
06:29gsdoes this help: http://blog.thinkrelevance.com/2008/9/16/pcl-clojure-chapter-3
06:30gsif you scroll down a bit he uses the 'format' function to print the output
06:30Pupeno1gs: might do.
07:34pmfIs there a significant difference between (.method obj args) notation and (. obj (method args)) notation? I'm asking because I'm using a custom variant of doto that works not only on Java-methods, but also on regular (i.e. Clojure) functions that take an obj a first arg, allowing to do (doto-2 obj (.someMember args) (pr) (.someOther)).
08:09glark(defn $ [pred]
08:09glark `(lambda (x) (,(first pred) x ,(first (rest pred)))))
08:09glarkwhy isnt that working? it works in common lisp
08:09glarkshould expand ($ '(< 10)) to (lambda (x)(< x 10))
08:10glarkobv not needed in clojure bc fn is short
08:10glarkbut i am oractiticng ninjaskills
08:10H4nscomma is white space in clojure, use ~ instead
08:12H4nsoh, and yes, lambda is fn in clojure. are you sure that you've read enough of the introductory material? :)
08:18rhickeyglark: the ninja way would be #(< % 10)
08:21Hunreal ninja is (rcurry < 10) :)
08:22glarkok thanks
08:22glark(defn $ [pred]
08:22glark `(lambda (x) (~(first pred) x ~(first (rest pred)))))
08:22glarkdoesnt work either. for soem reason it puts user in there...
08:22glark(user/lambda (user/x) (< user/x 10))
08:22glarkwhen doing ($ '(< 10))
08:23H4nsglark: lambda does not exist in clojure
08:23glarklol im stupid haha
08:24glark(defn $ [pred]
08:24glark `(fn [x] (~(first pred) x ~(first (rest pred)))))
08:24glarkjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
08:29glark(defn $ [pred]
08:29glark `(fn (~[(first pred)] x ~(first (rest pred)))))
08:30H4nslisppaste8: url
08:30lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
08:30H4nsglark: use that for code pastes
08:31rhickeyHun: I disagree - curry is not very ninja at all - can only bind args in order - rcurry is a great example of its limitations
08:32Hunwhen the functions are uncurried variadic, one can implement rcurry pretty easy... though it's ugly
08:33rhickeyHun: and binding the middle arg of three?
08:33Hungot me there :)
08:34rhickey#(foo %1 42 %2)
08:35Hunone could do a nasty hack and implement an ncurry, but that's even uglier than rcurry
08:35rhickeyHun: then I'd say what about first and third of four?
08:36Hunwould work with ncurry twice. it'd create a lambda with & args and splice them around the call
08:37rhickeymore proof
08:37Hunbut your solution is nicer
08:40fonduehm, shouldn't this return false? (def a 1) (def b 1) (identical? a b)
08:40lisppaste8rhickey annotated #67956 with "aif" at http://paste.lisp.org/display/67956#1
08:41rhickeyHun: aif that works ^
08:42rhickeyClojure tries to help with aliasing, so you need to explicit cause 'it to escape
08:42Hunok
08:44rhickeybut anaphora are discouraged in Clojure, they don't nest
08:44Hunmaybe i should stop thinking CL when writing clojure :)
08:45rhickeyfondue: while they are not guaranteed to be identical?, they're not prohibited either
08:45rhickeyidentical? also use very infrequently in Clojure
08:45rhickeyused
08:47fondueok, was just following the data structures screencast and typing things into my own repl for kicks, you seemed to get (identical? "foo" "foo") to turn up as false too, I got true
08:47fonduebut I'll just ignore it :)
08:48Hunequality is generally a hard problem
08:48rhickeyfondue: for strings the rules have changed since the screencast and identical? is guaranteed for string literals
08:49fondueright
08:49rhickeyidentical? is not about equality
08:49Huntrue
08:50rhickey= in Clojure has sound semantics, at least when applied to Clojure objects and immutable Java ones
08:51rhickey= pretty much implements egal, per Heny Baker: http://home.pipeline.com/~hbaker1/ObjectIdentity.html
08:53Huncool. didn't know that paper yet. => reading
08:53H4nsin german, "egal" means "does not matter" which is slightly confusing :)
08:54rhickeyH4ns: interesting
08:54fondueyes, I was enjoying =, I just thought it was odd that identical? didn't point out that they were different objects, which seemed to be its main purpose
08:54fondueas a side note, that is probably the best answer I have ever gotten in proportion to how basic the question was
08:55rhickeyfondue: but it does do exactly that, but the language doesn't say that two 1's that occur in different places will be different objects
08:55fondueso it's employing a bit of cleverness and using the same object, since they're immutable anyway? they're both pointing to the secret 1-object?
08:55rhickeyright
08:56rhickeybut not guaranteed
08:56fondueright
08:57H4nsrhickey: a class name in a new expression can't be computed, right? i tried (new (if <expr> <some-class-name> <another-class-name>) ...)
08:57rhickeyhad an interesting look at the cost of that optimization during the JVM summit - bottom line is that with proper escape analysis it might be better to allocate a new boxed 1 every time, sinc ethe test and cache lookup complicate the fast path
08:58rhickeyH4ns: right, Clojure is designed to be compiled - you can get runtime behavior by using reflection explicitly - see also clojure.lang.Reflector for useful reflection helpers like invokeConstructor()
09:00rhickeybut better in your case (if expr (This. ... ) (That. ...))
09:01H4nsrhickey: thanks, will look at that. coming from clos, i have a hard time coming back to a static object system.
09:01fonduean interesting optimization that, exactly the kind of emergent cleverness this new (to me) way of thinking seems to encourage
09:11rhickeyH4ns: understood, although that dynamism is infrequently used. In any case, it is generally more useful, if someone is going to hand you something to create, for them to hand you a constructor-fn than a class name/object - like #(java.util.ArrayList. %&) - that way your code isn't hardwired to new, and the resulting call is fast - no reflection
09:14glarkrich: what is your opinion aout haskell and python?
09:14glarkis it possible to create an objectsystem in clojure btw?
09:15rhickeyglark: haskell is inspiring, python just ordinary, but serves its users
09:16rhickeyglark: hopefully some next-generation object system
09:16prunedtreerhickey : is there a way to iterate in clojure that isn't ridiculously slow that I missed ?
09:17prunedtree(or ridiculously low level like loop)
09:17rhickeydoseq dotimes
09:17prunedtreeare ridiculously slow. slower than interpreted languages
09:18prunedtree(well, probably faster than ruby/python/etc... but slower than, say, Lua for instance)
09:19rhickeythe things you've been doing have been highly imperative - if you find loop too low level build higher level things with macros
09:19prunedtreeand 100x slower than some JITs. I think it's the whole lasy sequence thing
09:20prunedtreeit's great on paper but disastrous on the JVM. no lamba lifting, no strictness analysis. feels like haskell without GHC magic :/
09:21H4nsrhickey: the library i am using tries to be friendly by supplying a lot of tiny wrapper classes around base class functionality. i'll just use the base classes and provide a convenient functional wrapper around that. i'm very willing to not use classes and inheritance in my clojure programs.
09:21H4nsbut now for some family business. enough progress for today.
09:24glark(defn $ [pred] `(fn [x] (~(first pred) x ~(first (rest pred)))))
09:25glarkwhat am i missing?
09:29Hunyou're defining a function that looks like a macro?
09:29rhickeyglark: are you trying to write a macro?
09:31glarkit works as a defun in commmon lisp
09:31glark(defun $ (pred)
09:31glark `(lambda (x) (,(car pred) x ,(car (cdr pred)))))
09:31glarkjust an exercise
09:31glarkpointless kind of but...
09:34Hunin CL that would also just return a list
09:35rhickeyis your problem the qualified user/x - you should be using auto-gensyms:
09:35rhickey(defn $ [pred] `(fn [x#] (~(first pred) x# ~(first (rest pred)))))
09:35rhickey($ '(< 10)) -> (clojure/fn [x__2553] (< x__2553 10))
09:36rhickeyClojure ` is not a hygiene free-for-all like CL
09:36rhickey:)
09:41glarkok thanks
09:41glarkstill get java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
09:41glark though
09:43rhickeyglark: when you are trying to use the result? That's because it's just a list of forms - unless you write a macro or eval it it's not going to turn into code
09:43Hunare you trying to call that directly?
09:43Hunyou get a (non-evalled) sequence back
09:48glark(defmacro $ [pred] `(fn [x#] (~(first pred) x# ~(first (rest pred)))))
09:49glarknow it does hwt i wanted but when i wrote in cl i thought it has to be a macro but then i could do it so i assumed it wuld work inclojure too
09:49rhickeyglark: please paste complete working CL
09:50alecAre the slides from the boston talk available in non-movie form? I don't see them on the website or in the files area of the Google group
09:50rhickeyalec: good point, I'll put them up, just a sec...
09:52rhickeyhttp://groups.google.com/group/clojure/web/clojureforlispers.pdf
09:54alecthanks!
09:55rhickeyalec: sure, although slides alone don't substitute for the talk (but should take less than 3 hours to read :)
09:57glarkhttp://hpaste.org/10917
10:01glarkrhickey ^^^
10:01alecglark: are you trying to recreate haskell's associativity-changing operator, and if so, why do that in a language that doesn't do infix?
10:02glarkwait it is not working when used with filter
10:02glarkno it wa sjus syntactic sugar for (lambda (x)(< x y))
10:02glarknot really needed since clojrue has its own
10:03glarkbut dont see how the clojure-system works
10:04glark(clojure/fn [x__1837] (< x__1837 10)) is what i get
10:04glarkwhen using defn, i watn a list, data as code...
10:07Hunare you confusing Common Lisp with Emacs Lisp? this is the only still alive lisp i know where this works
10:08glarkys emacslips +re clrequ
10:08glark+ require 'cl
10:10Hunthat's an ugliness of elisp that you can funcall a list there imho
10:10Huneverywhere else you need a macro or an eval between
10:12glarkok but it is still not working here
10:12glarkuser=> (filter ($ '(< 10)) '(12 3 4 55))
10:12glark(12 3 4 55)
10:14Hunsame happens with my implementation, too
10:14Hun(defn $ [pred]
10:14Hun #((nth pred 0) % (nth pred 1)))
10:14Huni don't understand that one
10:14Chouserglark: what does (macroexpand '($ '(< 10)))
10:14Chouserer, what does that return?
10:16Chouser(filter ($ (< 10)) '(12 3 4 55)) seems to work
10:16Hunhmm
10:17Hunit works when i do a (list < 10) instead of a '(< 10)
10:17Hun(filter ($ '(< 10)) '(12 3 4 55)) => (12 3 4 55)
10:17Hun(filter ($ (list < 10)) '(12 3 4 55)) => (3 4)
10:18Chouserrunning macroexpand on those is enlightening
10:18Huni have no macro in there, just a defn and a fn
10:18Chouseroh
10:19Hunah
10:19Chouseroh, I see. I was looking at glark's macro implementation
10:19Hunlist evaluates the < to clojure._LT___
10:19Hunthe quote doesn't and includes a plain <
10:19Hunwhich somehow can get called though
10:20Hun('< 3) => nil
10:21Hun('< 3 5) => 5
10:21Hunwith more it throws an exception
10:21rhickeyglark: so, the code you've posted won't work in CL, as someone said auto-eval of lists may be an emacs lisp thing
10:22rhickeyso, this must be a macro - you want to manipulate code as data, then have the compiler continue to evaluate it
10:23Hunrhickey: what does happen back there? i seem to call a symbol and it works... can't find anything about that
10:24rhickeysymbols, like keywords, are functions of associative things, like maps
10:25rhickey('a {'a 1 'b 2}) -> 1
10:27Chouserand apparently (get 3 5) simply returns nil
10:27rhickeywhen 'called' on something non-associative, return nil - found nothing
10:27Hunok. but i don't understand what it's doing to those numbers a few lines up. with 2 args it seems to return the second one
10:27rhickeyChouser: no (get '< 3) returns nil
10:28rhickeysorry (get 3 '<)
10:28Chouserthe third param then is the notFound value
10:28rhickeyright, the second case is the default value case
10:28rhickeyif you can't find '< in 3, return 5
10:29Hunah, now i get it. i would have expected it to complain that 3 is not a collection
10:31rhickeyHun: others expected nil and won, apparenty :)
10:31rhickeyapparently
10:31Hunhehe
10:32rhickeyiirc that behavior was useful in destructuring at least
10:33Chouserso that's a completely different problem from glark's, where by quoting the arg '(< 10), first and (first (rest...)) were operating on (quote (< 10)) instead of (< 10)
10:34Hunit then always returns the second arg (the number 10) which is always true
10:34Hunand therefore filter returns the original seq
10:34rhickeyChouser: yes, there's lot of confusion here solved by using macros - the right tool for this job
10:36Chouserwell glark's was a macro (in the end) but I guess the idea of quoting the arg was left over from when the implementation was a fn
10:38glarkwell its still not working damn. thanks fo the tips though.
10:38Chouserglark: works for me
10:40glarkchouser: which one and how do you call it?
10:41lisppaste8Chouser pasted "glark's macro" at http://paste.lisp.org/display/67975
10:42glarkah v nice
10:43rhickeydon't ignore his "or of course the easiest:" at the bottom, that is the Clojure way to do this
10:45ChouserI hardly ever get to write macros in clojure -- there's almost always already an easier way to do it.
10:48glarkty very much all
10:48glarkim mostly in this to learn more about macros and stm
10:48glarkgonna port ,y spamfilter to clojure now as an exercise
10:58glarkhow do i do progn in clojure?
10:59Chouser(do ...)
11:00ChouserIf I remember progn correctly. ;-)
11:08Hunyep
11:15blackdoghi Chouser how is clojurescript? I tried to tweak it a little, (prn (+ 1 2 3 4)) -> 8 :p, i added a clojure.lang.Numbers.add,
11:15blackdog(+ 1 2) gives the correct answer
11:16blackdogdoes that mean an issue in the PersistentList reduce?
11:20Chouserblackdog: yeah, I just noticed yesterday that add and minus were missing.
11:21Chouserhm! not sure.
11:21ChouserI'd have to look at the JS produced, but mine is all broken at the moment.
11:21blackdogok, i used svn from yesterday,
11:22blackdoganyway, it looks really interesting and i understand basically waht's going on, so i'll try a little hacking on it
11:22Chouserblackdog: cool.
11:23ChouserAs you noticed, there several bits of runtime support missing, and the parts that are there are not well tested.
11:23ChouserI think the JS-emitting part is pretty solid, though we may be able to make performance and size improvements.
11:25blackdogyegge's js2.el is complaining about lack of ; in the bodies of most of the output
11:25blackdognot too important i guess
11:26blackdogmaybe for compression tools it is though
11:31Chouserhm, I wonder if the
11:31Chouserhm, I wonder if the \n interspersed with , is a bad idea
11:32Chouserlike, it could be interpreted as end-of-statement
11:46StartsWithKChouser: Will you provide any way to extract parts of boot.js that are needed by clojurescripts?
11:50blackdogi think that's ultimately important, it's one of GWTs selling points
11:50blackdogremoving unused methods, classes
11:53ChouserI've been hoping I could get all of boot.js and clj.js compacted and gzipped down to around 20KB or so.
11:53blackdogthat would be amazing,
11:55ChouserI'm currently at about 25KB, but that's without compacting clj.js at all, or using short names in boot.js
11:56Chouserof course clj.js is also missing entire classes, so we'll see.
11:56blackdog50K in total for runtime and boot will make it very competitive
11:57StartsWithKdon't forget most of us will use something like jquery with clojurescript
11:57StartsWithKso, total size i my opinion should be mesured when packed with jquery
11:57StartsWithKbut this will be awesome when finished :)
11:58ChouserjQuery's what, 9KB or so?
11:58blackdog19K
11:58blackdogi think compressed
11:59ChouserI've already got code in tojs to skip some parts of boot.clj (agents, etc.) so exposing that functionality somehow isn't out of the question, though it's complexity I'd rather avoid if possible.
12:00StartsWithKanyone got proguard (http://proguard.sourceforge.net/) to work with clojure?
12:00StartsWithKthat would reduce applet sizes too
12:01StartsWithKwhen aot clojure->java that should work just fine i think
12:01StartsWithKis finished*
13:22Chouserblackdog: The bug turned out to be in ArraySeq.reduce -- fixed, thanks!
13:22blackdog cool thanks
13:22blackdogis it on svn?
13:35StartsWithKhow can i dispatch on interface?
13:39blackdogmaybe use bases or supers in the dispatch function for your multimethod?
13:39StartsWithKi can do (supers obj), and ill get set, but then i will have to dispatch for exact combination of interfaces
13:41rhickeyStartsWithK: just use class as your dispatch function and the interface as the dispatch value
13:42Chouserblackdog: yes, it's in svn.
13:46StartsWithKthanks
13:54StartsWithKand how could i dispatch on method signature? like in scala i can say type HasEventListener = { def addEventListener(e: Event) } and then i can write
13:55StartsWithKimplicit def ext(o: HasEventListener) = { do_something() }
13:55StartsWithKi should use reflection for something like that?
14:10rhickeyStartsWithK: you mean dispatch based on the presence of a method in the target? why would you do that?
14:20StartsWithKrhickey: swing has bunch of addXXXListener methods, but they are bund to some interface, in swt you have addSelectionListener(SelectionListener l) defined on multiple classes with same behavior but they don't share common base class or interface
14:21rhickeybut that is not a dispatch issue - you can call (.addSelectionLister x ...) on any x that supports that method
14:23StartsWithKi have this new (doto) that can also use (defmulti patch) multimethod to 'add' new methods to some class
14:24StartsWithKnow i dispatch inside patch based on class, but i would like to restrict that to classes that have some base class and methods with eact signature
14:26StartsWithKsame thing is inside jetty, there is a lot of classes that have void addHandler(Handler h), they all do the same, but there is no common interface
14:30rhickeybut you really have code that needs to say, if this thing supports handlers add one?
14:33StartsWithKhttp://pastebin.com/m5ea79f29 there is no addHandlerCollection method in jetty, i dispatch on base Handler class to inject this method, but that is wrong, not all Handler subclasses have addHandler
14:34StartsWithKups, there is no addHandlerList method
14:41rhickeyStartsWithK: you are making up your own language there, injecting methods etc. The simple answer is to determine whether or not a class supports a method you'll have to use reflection. If you know the set of classes without a common base interface you'd like to group together, you can use the new ad-hoc hierarchy support:
14:41rhickey(derive SomeHandler ::SupportsAddHandler) etc
14:43rhickeythis allows you to superimpose a parent, which you can use in dispatch, and while it requires enumeration of the relationships, it's not duck typed like the Scala - you make a concrete decision
14:44Chouseron the other hand, having creating a dispatch function that does the reflection to do duck typing wouldn't be *that* hard.
14:44Chousers/having//
14:45StartsWithKrhickey: do you consider it a bad sytle, this extended doto macro? It is 100% compatible with clojure/doto
14:46StartsWithKChouser: like when multimethod is dispatched i could check with reflection for existance of method and create new (derive) on the spot, that could work
14:46rhickeyStartsWithK: yes, because I can't understand your program anymore - I'd expect to find any called methods in the Javadoc for the classes
14:48rhickeythis isn't really dispatch at all, it's just a predicate - hasThisProperty/method
14:49rhickeythe advantages of encoding as hierarchy are - non-duck, non-reflective
14:49StartsWithKyes, that could be a problem, i hope that at the end i will add something that will auto-generate documentation of patched (or shadowed) methods
14:50rhickeyStartsWithK: why not call it something else my-doto
14:51StartsWithKno problem there, i used it only in larger composition, like gui creation, so maybe (build) could work
15:25Chouserwe definitely need a sane way of prividing and maintaining "see also"s in function docs
16:01blackdogChouser: if I want to reference JQuery from a cljs or any JS global, what's the magic? it seems to be trying to resolve in my namespace
16:02Chouserit's ok for it to generate a resolveVar to get to a JS global
16:03blackdogsorry, don't understand how to get the global, this is what i have (.html JQuery "#nice" "woot")
16:04blackdogah
16:05blackdogclojure.JS.global?
16:05blackdogl.JQuery?
16:05blackdogoops
16:06blackdogclojure.JS.global.JQuery
16:06blackdognope, nevermind :P
16:09Chouser(.html JQuery "#nice" "woot") should work -- is it not?
16:09blackdogi'm not getting nice filled with woot on my page, but maybe there's something daft
16:10Chouserwhat JS is being generated?
16:10blackdogoh it may be that I'm not calling it in the ready function
16:10blackdogof jquery, so maybe the document hasn't been initalised properly
16:10blackdog(function __ritchie_fn_2653(){
16:10blackdogreturn ((clojure.JS.resolveVar("JQuery",ritchie)).html("woot"))}).apply(null,[]);
16:10blackdog
16:11Chouserok, I think that ought to work. The resolveVar should find window.JQeury at runtime, do JQuery.html("woot")
16:12blackdogwhat in FF ?
16:12blackdogin firebig?
16:12blackdogbug, doh
16:14Chouserwell, yeah you should be able to paste into firebug what you pasted here, and it should happen.
16:14blackdogi think it's me using query wrongly actually
16:14Chouserok. I don't know anything about JQuery. :-)
16:17blackdogwait, if I do this (.html JQuery "#nice" "woot"), then I want it to translate to JQuery("#nice").html("woot")
16:17Chouseroh!
16:18blackdogand it's dropping the "nice" i think
16:18blackdogno it's not
16:18blackdogok this is what i have now
16:18Chouserwell, you'd have to write that (.html (JQuery "#nice") "woot") or something.
16:18blackdogclojure.JS.resolveVar("JQuery",ritchie)).html("#nice","woot"))
16:19blackdogah ok, it's my clojire :)
16:19Chouserwell, except cljs isn't going to bahave well on (JQuery "#nice").
16:19Chouseroh, maybe it will!
16:20blackdogclojure.JS.resolveVar("JQuery",ritchie).apply(null,["#nice"])).html("woot")
16:20Chouseryeah, give that a try.
16:20blackdogbut i still don't see anything, which still may be down to the document not initialised
16:23Chouserwell, you can try hand-written JS in whatever context you're trying to do generate .js now.
16:24ChouserOnce you've got that working, swap in the generated JS and get back to me. :-)
16:24blackdogyep
16:38blackdogmy mistake, JQuery, should have been jQuery
16:38blackdoggetting some output now
16:40Chouserah, good.
16:43ChouserI freely admit there's plenty of work to go on getting all this to tie in nicely.
16:43blackdogok, next question if I want to call into namespace "test" and function setText from javascript how do i do it?
16:45Chouseryou say namespace, so I assume setText is defined in a .clj or .cljs file somewhere?
16:45blackdogyes, (ns test)
16:45blackdog
16:45blackdog(defn setText [t]
16:45blackdog(.html (JQuery "#nice") t))
16:46blackdogbut i'll need to call clojure functions from jquery events
16:46Chouserwell, this is the tie-in stuff that's not too pretty yet. You have to make sure that code is compiled to .js and that the .js is loaded into the browser page.
16:46blackdogyes, I've done that
16:47blackdogit's working in the browser
16:47Chouseroh, ok. Then you can call it from JS like test.setText(t)
16:47blackdogthat easy! awsome, i see there's a getMappings() function in there
16:47blackdogbut i didn't see anything else
16:47Chouseror from cljs like (test/setText t)
16:48ChouserI don't think there's any way to set a JavaScript object property from cljs yet -- we'll probably need that.
16:49Chouserbut you should be able to pass the setText function into jQuery if needed.
16:50ChouserI assume you realize you're in deep pre-release code here. :-)
16:51blackdogyes, no worries, i'm trying to help by applying it to things :)
16:54aperottehello everyone ... does anyone have any experience with enclojure on ubuntu?
17:03Chouseraperotte: well, nobody else is jumping in -- I have run enclojure on Ubuntu, but I don't use it regularly.
17:04blackdogChouser: this works in the browser ...
17:04blackdog(ns test)
17:04blackdog
17:04blackdog(defn setText [t]
17:04blackdog(.html (jQuery "#nice") t))
17:05blackdogand in the html
17:05blackdog<script>
17:05blackdog
17:05blackdog$(document).ready(function(){
17:05blackdogtest.setText("rocking")
17:05blackdog});
17:05blackdog</script>
17:05H4nslisppaste8: url
17:05lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:05blackdog
17:05blackdog
17:05H4nsblackdog: can you use the paste bin please?
17:05blackdogyes
17:05Chouserblackdog: great.
17:06blackdogdoes emacs have a lisppaste command?
17:07blackdogso i can select something and then paste it automatically?
17:07H4nsblackdog: not that i knew of it, but it's kind of a nice idea. let us know if you write or find it.
17:07blackdogjedit has one
17:08blackdogquite useful
17:08Chouserhttp://agriffis.n01se.net/nopaste/
17:08Chouser^^ I use that
17:08blackdogthanks
17:14aperotteChouser: I was having some difficulty, I'll try again. I just wanted to make sure that someone has had success before. Thanks
17:18StartsWithKblackdog: http://paste.pocoo.org/about/
17:18StartsWithKi don't know how well it works, never tried it myself
17:19blackdogStartsWithK: i think the link Chouser gave me is what i want i can call it direcrlt from emacs
17:20StartsWithKblackdog: they clame to have emacs support, but link is broken :/
17:20blackdogok :)
17:59blackdogChouser, jquery, clj.js, boot.js and a small test - 189K, with yui compressor
18:32Chouserblackdog: ouch
18:32Chousernot gzipped though?
18:43ChouserIf I turn off *debug-fn-names* when generating boot.js, and then run clj.js and boot.js through the YUI compressor, I get 130KB of javascript, which gzips down to 22KB
18:43blackdog0k cool, didn't know about that
18:45Chouserserving gzipped .js can be a bit tricky, though.
18:45blackdogoh, down to 22kb! wow
18:51Chouserof course that's without the html or jQuery
18:57blackdogChouser: are maps, vectors and lists implemented?
18:57danlarkinI'm sad that macroexpand can't expand an invalid macro
18:57H4nswill i ever learn that i need (format "foo") not (format nil "foo") in clojure? couldn't that have been renamed? *whine* :)
18:57danlarkinI want to see what I'm doing wrong :-/
18:58Chouserdanlarkin: PersistentHashMap, PersistentVector, and PersistentList should be -- no guarantees about buglessness, though
18:59Chouserjust search clj.js for \"PersistentList\" to find out if the class is implemented yet
18:59blackdogok
18:59ChouserSorted maps aren't there yet
19:00ChouserFeel free to implement anything that's missing. :-) I generally open the .java in one window and clj.js in the other, and just translate.
19:00H4nsChouser: clj.js is a clojure compiler in javascript?
19:01Chouserclj.js is clojure runtime in javascript (RT.java plus various other .java files)
19:01Chousertojs.clj is a clojure-to-javascript compiler written in clojure. :-)
19:01Chouserboth need to be renamed
19:01H4nsChouser: ah, ok. *shiver*
19:01H4ns:)
19:01blackdogthe compiler is really just the normal clojure compiler with callbacks no?
19:02ChouserH4ns: I know, I know.
19:02Chouserblackdog: sorta. It definitely leans very heavily on the normal clojure compiler.
19:02H4nsChouser: i guess it is a fun thing to do, and people love such things. like the ocaml thing in js, and parenscript.
19:03Chouserwell, writing code in clojure is so fun, and having to switch to JavaScript for the browser is a drag.
19:04Chouserthis lets you code for the browser but with macros, persistent data structures, destructuring, etc.
19:04H4nsChouser: sure, i understand that. it is just the debug aspect that makes me shy away from such things.
19:04Chouseryeah, pre-clojure I was pretty down on any to-javascript compilers.
19:04H4nsChouser: i may be just a lousy programmer, needing a debugger and all :) - i made my peace with javascript, and mochikit made that rather easy
19:05H4nsChouser: but maybe i'm becoming such a die-hard clojure hacker now that i'll choose clj.js in the future, too. javascript syntax is just a pain.
19:06Chouserthe debugging is as terrible as it could be. All the var and local names are repeated in the JS by default, so finding your place isn't too bad.
19:06Chousers/is/isn't/
19:06blackdog:)
19:06Chouserfreudian
19:07H4ns*chuckle*
19:07H4nsi guess once i'm over all this "i want proper error messages" thing, i'll feel more comfortable with the thought.
19:08Chouseryou still get a lot of the compile-time errors, since it's the same compiler
19:08H4nsthat actually is very nice. parenscript is more of a mock lisp.
19:26ChouserYUI compressor seems to introduce a bug
19:28blackdogdid you see this http://yuiblog.com/blog/2008/02/11/helping-the-yui-compressor
19:28blackdoggive's some hints about problems with --verbose
19:34Chouserinteresting -- points out some improvements I could make in tojs.clj
19:34ChouserBut it's screwing up my string literals, generating code with syntax errors in it.
19:37blackdogmmine is fine here
19:37blackdogwith the default options, no syntax errors in firebug
19:39blackdogi downloaded latest version
19:48ChouserI have 2.3.6
19:48blackdogmmm, i have 2.3.5
19:49blackdogthought i had the latest
19:49blackdogi'll try upgrading see if it fubars
19:49lisppaste8danlarkin pasted "defmacro" at http://paste.lisp.org/display/68005
19:51danlarkinso that macro does not work, but if I take out the last line, it does work
19:51danlarkinbut I want it to define the symbol _and_ add it to the v-list
19:51H4nsdanlarkin: expand into a do maybe?
19:52rhickeyright
19:52danlarkind'oh
19:53blackdogChouser: all is well with 2.3.6
20:06yangsxI cannot access http://clojure.blip.tv; is there any alternative URL to the videos there?
20:20danlarkinyangsx: works for me?
20:24yangsxdanlarkin: probably because of access restriction in China
20:25danlarkinyangsx: wow that's a real shame
20:26abrooksyangsx: Are there other video sharing sites (such as youtube.com) which are accessible?
20:26Chouseror even better, video.google.com, since then you can download the original
20:26abrooksChouser: I think you can download the .mov from Blip.
20:28yangsxabrooks: google's works for me
20:54abrooksrhickey: Have you thought of using Google Video? Was there anything in particular that pulled you to Blip.tv? Personally, I find Blip's lack of instant seek and thumbnail preview points fairly annoying. The player is not nearly as good as Google Video with regard to navigation as well. The screen casts are so excellent but it's hard to quickly pull up sections to share with friends (Google Video allows URI anchors to points ...
20:54abrooks... in the video).
20:58rhickeyI tried Google Video but the resolution is really low
20:58abrooksOh, hm. Good point.
20:58abrooksBlip does look really nice.
20:59abrooksI don't know of any Mac OS X screen capture programs which can capture to vector based Flash... there are several for X which are really nice.
20:59rhickeyThe best way to view is to download first
21:01abrooksrhickey: Yeah, I've often wanted to email someone a pointer to a particular section of a video as one can do like this: http://video.google.com/videoplay?docid=7760178035196894549#5m28s
21:02abrooks(The #5m28s is the anchor into the video timeline)
21:03abrooksrhickey: Would you be opposed to some of us downloading the original and uploading it to other video sharing sites?
21:08rhickeyabrooks: I'd prefer not
21:08abrooksOkay. :)
21:09rhickeyI agree the timeline pointers are neat. I'm terribly disappointed by the FLV format BLIP requires for the front page player. I can convert to the QuickTime in real time, FLVs take 8-16 hours to produce with Adobe's encoder
21:13yangsxrhickey: unfortunately, blip is not accessible to me from China :)
21:13rhickeyyangsx: I understand, still thinking about that
21:14yangsxrhickey: and one can download higher resolution video files from video.google.com, e.g. with clive
21:17rhickeyyangsx: what about itunes?
21:18yangsxrhickey: I haven't tried that, not sure
21:18rhickeythey are there
21:20H4nswhat could be the reason for a classnotfound exception, given that the jar is in place, contains the class and the classpath includes the jar? how does one debug such problems?
21:21rhickeyH4ns: is the class public?
21:22H4nsrhickey: yes. in fact, i used it already, it worked, and now it does not.
21:22rhickeywhat is different?
21:22H4nsrhickey: is there some debug flag that i can use to trace jar file/class name resolution in the jvm, preferably without being overwhelmed?
21:23H4nsrhickey: that is a very good question. i'd claim "nothing", but that obviously can't be the case.
21:31H4nsjava -verbose shows class loading information, and i was using the wrong script to start clojure
21:41yangsxI'm using Debian 64-bit. Is there a way to fetch files from the itunes with Linux. I'm still searching
22:17ozzileeDoes the Repl have any way to get at the most-recently returned object?
22:18Chouser*1
22:18ozzileeAh nice, thanks :-)
22:18Chousernp
22:20ozzileeHmm, what's a good way to do something like while (foo.next()) { foo.bar() } ?
22:20ozzileedoseq maybe?
22:20Chouserfoo.next() mutates -- is it an Iterator?
22:20ozzileeJdbc4ResultSet
22:22Chouser(doc resultset-seq) ?
22:23ozzileeHeh wow, that's amazingly specific to this problem. Nice.
22:23ChouserYeah, it's a bit unusual for boot.clj, but there you go.
22:25ozzileeAll right, goal accomplished for the night, clojure is speaking to postgres. Thanks for the help.
22:26Chousernp
22:58danlarkinH4ns: I see @planet_lisp is up, good job
23:00H4nsdanlarkin: thanks - well, it was kind of an end-to-end experience to test the deployability on freebsd and that. i still have a hard time being productive with clojure, but it is improving :)
23:00danlarkinwhat language do you use primarily?
23:01H4nscommon lisp. which is near enough to clojure to make things relatively confusing :)
23:01danlarkinhaha oh yes it must be fun for you
23:02H4nswhat language are you coming from?
23:02danlarkinpython
23:03danlarkinthat's what I use for my day job, anyway
23:03H4nspropably not a bad background for learning clojure either. are you planning to do something real with clojure?
23:06danlarkinwell yes, but it's pretty ambitious so it'll be slow going, especially while learning a new language
23:06H4ns:)
23:06H4nssame thing here.
23:07danlarkinthe parallelism language constructs will help immensely, though
23:07danlarkinthat's why I'm not doing it in python
23:09H4nsthat is what I hope will help me, too. I will also use a lot of java software as infrastructure, hoping that it holds up with the promises in terms of matureness
23:16danlarkinaccess to all of these existing java libraries is killer, though. that's the reason I hadn't started in CL yet
23:17danlarkinone of them, anyway
23:18H4nsyeah. at the moment i'm considering how to access all these libraries, though. handing pointers to mutable java objects into pure functions seems like not being the best way.
23:19H4nshand writing wrappers somehow does not seem like a good way, too. but i'm pretty sure that someone else already has thought about this. i'm just writing a group posting inquiring for some thoughts on this.
23:20danlarkinI suppose it could be done with a macro?
23:20H4nsdanlarkin: depending on what you mean by "it"
23:21H4nsmaking a macro that lets proxy look a little nicer for common cases certainly is not hard
23:21H4nscreating a useable functional interface from large framework classes looks like being harder.
23:25ChouserH4ns: don't be afraid of Java
23:27H4nsi'm not afraid, i just don't know my way around. calling getters does not frighten, but disgust me :)
23:29H4nsChouser: i'm really looking for the idioms of other, more experienced clojure hackers. if passing java objects without disguise is the way to go, so be it. i'd just not want to be missing something that makes things nicer.
23:35H4nsanyway, need sleep. cheers.
23:35Chouserg'night