#clojure logs

2009-10-27

00:01hiredmanhttp://pixel-shaker.fr/en/2009/09/representation-dimages-clojure-et-java-premiere-partie/
00:03somniumhow do you specify multiple constructors? variable arity, variable type
00:03somniumor different, not variadic
00:04hiredmanit turns out I missed redirecting a call to LispReader/read in LispReader/readDelimitedList so none of my incremental developed and tested code was ever really tested
00:04somniumbut this is good, thans
00:04hiredmanerm
00:04hiredmanhave you read the api docs?
00:04somniumyeah
00:05hiredmanthere is a :constructors keyword
00:05somniumyes
00:05hiredmanand that didn't jump out as a way to implement constructors?
00:07somniumostensibly yes, it did connect that :constructors and the vectors that followed were linked in a meaniful way
00:08somniumbut it didn't jump out how to do [Object Object String] [] [Object String Interface] [] [Object ...]
00:08somniumhttp://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples/Java_Interaction#genclass
00:08somniumand this didn't help
00:09somniumthough it did compile in slime, only to blow up in ant
00:09hiredmanhttp://clojure.org/compilation
00:11somniumnote the most complicated constructors invocation in the examples
00:15hiredmanhow much more do you want the constructor to do?
00:15somniumso much more man, so much more
00:16hiredman~laugh
00:16clojurebotha ha
00:17Licensersomnium: does your driver support sorting?
00:17somniumI like clojure to be clojure and java to be the jvm, and the nasty 25 classes in one package interface didn't map well to the examples I found
00:17somniumLicenser: not yet, it seems it has be done with the cursor
00:17Licenserhmm there is a sort function at least in the console client
00:18somniumif the javadocs there's a skip and limit function defined for find
00:18somniumbut its not found when I inspect the class
00:19somniumI'll wrap the cursor once I get this proxy business sorted, then skip, limit, sort etc. should be easy
00:19somniumtry doing (clojure.contrib.repl-utils/show (.find some-collection))
00:19hiredman,(set (map #(.getName %) (.getMethods String)))
00:19clojurebot#{"compareTo" "equalsIgnoreCase" "subSequence" "trim" "codePointBefore" "compareToIgnoreCase" "getClass" "isEmpty" "length" "getChars" "toCharArray" "valueOf" "charAt" "indexOf" "notify" "toString" "codePointCount" "replaceAll" "substring" "intern" "matches" "copyValueOf" "lastIndexOf" "replace" "concat" "wait" "getBytes" "toLowerCase" "codePointAt" "startsWith" "toUpperCase" "format" "contentEquals" "notifyAll" "offsetBy
00:24hiredmanmy reader is dog slow
00:27somniumcan't you just copy the one from SICP?
00:28hiredmanI am copying the one from LispReader.java
00:28Licenserwell I just self sort ^^
00:28somniumdoes he do reader macros?
00:28hiredmanI don't type hint anything
00:28hiredmanyeah, it's all reader macros
00:28hiredmanjust not user extendable
00:29somniumhas there been some opposition to a heredoc or a """ ?
00:29somniumit seems to keep resurfacing but never gets anywhere
00:29hiredmanthere is a read table, if a character like '(' is in the read table control is passed to the matching reader macro
00:30somniumI got close to doing a string rearrangment of parentheses to make clojure like ruby
00:30somniumit always screwed up when the nesting got deep
00:30hiredman:(
00:30hiredmanit?
00:31somniumit was more like, I wonder how hard this would be...
00:31somniummacros written with it even worked for simple things
00:32somniumit might attract some people, just to show flexible it can be without even reader macros, I was thinking
00:32somniumthat was before clojure.walk, maybe I'll try again
00:33somniumI think I screwed myself with this proxy class, it won't let me override a superclass method
00:41scottjIs there a shortcut for doing something other than first argument with -> or is (-> "string" (#(str "prepend" %))) the way to do it?
00:43hiredman,(doc ->>)
00:43clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
00:43hiredman,(->> "foo" (format "prepend %s"))
00:43clojurebot"prepend foo"
00:48scottjhiredman: thanks
00:52piccolinoIs it bad style to put a question mark at the end of a boolean variable? Is that for functions only?
00:52hiredmanI do that
01:18piccolinoIs there a way to write a linefeed character literal? I can't do \linefeed nor \lf, and gooling is coming up short for me...
01:29piccolinoNevermind, found char.
01:37Licenser(doc defn)
01:37clojurebot"([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or attrs added to the var metadata"
01:37Licenser,(doc defn-)
01:37clojurebot"([name & decls]); same as defn, yielding non-public def"
01:51hiredman,\newline
01:51clojurebot\newline
01:52hiredman,\return
01:52clojurebot\return
01:52hiredman,(str \newline)
01:52clojurebot"\n"
01:52hiredmanpiccolino:
01:52Rayneshiredman: Don't you use Vim for Clojure development? (or do I just need to sleep more often?)
01:53hiredmanI do
01:53RaynesI've decided to move away from Emacs for a while to see what all the fuss is about Vim.
01:54RaynesI've been using it all day. I think I might keep using it.
01:54RaynesIt's a little easier to remember individual commands than it is to remember key patterns. ._.
01:55hiredmana vim habit is hard to break, I often hit <esc>:wq while writing emails in gmail
01:56Licenserhiredman: I have a few word documents with :wq lines :P
01:56Raynes:>
01:56RaynesOnce I figured out how to split panes in different directions and switch through buffers, I was a-go.
01:57hiredmanI've noticed myself trying to use screen window switching commands in place of alt-tab
01:58Licenseryap that is bad
01:58Licenserevern worst when you switch between mac and PC
01:58hiredmanand irssi's channel switching stuff in place of screen's window switching
01:58Licenserespecially the german keyboard
01:58RaynesI'm using GVim until I get used to Vim.
01:58Licenserthe @ sign when typed wrongly will do horrible things
01:59RaynesGVim makes a Emacsist feel at home.
01:59Licenserif I use the widows key combo for @ on os X it will close a window, if I use the os x key combo on windows it will log me out ...
01:59hiredmanRaynes: I have to warn you, vimscript is horrible
01:59Rayneshiredman: Huh?
01:59hiredmanvim's scripting language
02:00RaynesI never did any custom Emacs scripting anyways.
02:00RaynesI just googled what I needed if I needed something.
02:01Licensernight Raynes
02:20Licenserwhat is the reason that there is no !=?
02:20Licenserso everyone can has fun with cons?
02:23arsatikihuh?
02:23arsatikiAre you looking for not= perhaps?
02:24Licenser,(doc not=)
02:24clojurebot"([x] [x y] [x y & more]); Same as (not (= obj1 obj2))"
02:24Licenseryap I'm looking for that :P
02:28bradfordstephensWhoa, there's people in here!
02:30Licenserbradfordstephens: and most of them even are helpfull is my experience :) clojure has a great community
02:30bradfordstephensI'm working through Paul Graham's book on Lisp now...my friend is one of "Those People" who kept insisting. So I gave in ;)
02:31Licenserheh
02:31Licenserfor me Clojure was the reason to bother with LISP
02:37kylesmithAre there any good genetic algorithm libraries in clojure? The first few hits on google don't look very appealing to me.
02:39seangroverequire 'rubygems'
02:39seangroverequire 'sqlite3'
02:39seangroverequire 'activerecord'
02:39seangrove# connect to database. This will create one if it doesn't exist
02:40seangroveMY_DB_NAME = ".my.db"
02:40seangroveMY_DB = SQLite3::Database.new(MY_DB_NAME)
02:40seangrove# get active record set up
02:40Licenserseangrove: ?
02:40seangroveActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => MY_DB_NAME)
02:40seangrove# create your AR class
02:40seangroveclass Update < ActiveRecord::Base
02:40seangroveend
02:40seangrove# do a quick pseudo migration. This should only get executed on the first run
02:40seangroveif !Update.table_exists?
02:40seangrove ActiveRecord::Base.connection.create_table(:updates) do |t|
02:40seangrove t.column :account_name, :string
02:40seangrove t.column :last_update_time, :timestamp
02:40seangrove t.column :last_update_id, :integer
02:40seangrove end
02:40seangroveSorry guys, emacs is going a bit wacky
02:40seangroveI meant to paste that into a different buffer, but emacs reconnected to irc and started popping up irc channels
02:41Licenser:P
02:41Licenserdef my_companies_secret_code ...
02:41seangroveHahaha
02:42Licenserhrm I hate the backtrace if it leaves out some function :/
02:44Licenseruh
03:23woobyanyone a vimclojure user?
03:34vyWhat's the prefered way to swap two elements of a seq, particularly a vec?
03:38arsatikiAny two items or e.g. first two?
04:02Fossihi
04:13vyarsatiki: Any two items.
04:22vyWhy Clojure complains that "clojure.lang.LazySeq cannot be cast to clojure.lang.IFn" for (let [{v :v} {:v (take 20 (iterate inc 0))}] (v 10))?
04:26jdzvy: because LazySeq does not implement IFn?
04:29vyjdz: What should I do to make (v 10) work?
04:29jdzvy: either use a vector or nth
04:29piccolinoIs there some function I can call to allow multiple forms to be evaluated and return the last one?
04:30piccolinoLike progn?
04:32jdzpiccolino: do
04:33piccolinoAh, there we go. Thank you.
04:38wavis_is there a way to do something like this:
04:38wavis_(let [oldns *ns* throw-away (clojure.lang.Namespace.)] (in-ns throw-away) (foo) (in-ns oldns))
04:38wavis_IE, avoid global state by sandboxing functions
04:39jdzwavis_: like (binding [*ns* (new clojure.lang.Namespace)] (foo))?
04:39wavis_binding requires declaring vars in the namespace first
04:39wavis_ohh sorry...
04:40wavis_i didn't know I could do that
04:41wavis_right... so constructing a namespace is still a problem
04:41jdzwavis_: how about create-ns
04:41jdz,(doc create-ns)
04:41clojurebot"([sym]); Create a new namespace named by the symbol if one doesn't already exist, returns it or the already-existing namespace of the same name."
04:42wavis_doesn't that leave the namespace lying around though, still resolvable?
04:43jdzwavis_: well, you have try/catch and remove-ns
04:43jdzwavis_: you'd actually want try/finally
04:45wavis_sounds kinda do-able, but the namespace would be global until removed, possibly creating a concurrency problem
04:45jdz,(doc gensym)
04:45clojurebot"([] [prefix-string]); Returns a new symbol with a unique name. If a prefix string is supplied, the name is prefix# where # is some unique number. If prefix is not supplied, the prefix is 'G__'."
04:46wavis_good call
04:46jdzwavis_: or go and look at clojurebot source
04:46jdzit definitely has a sandboxing in there
04:46wavis_where is that?
04:47jdzlike, google clojurebot?
04:47wavis_ok jdz. thanks
04:48jdz,(+ 2 2)
04:48clojurebot4
04:48jdz(+ 2 2)
04:48clojurebot4
04:48jdzhmm
04:48jdznvm
05:22adityohey nipra :)
05:22nipraadityo, Hello!
05:23nipraadityo, wass up :-)
05:24G0SUBadityo, nipra
05:25nipraG0SUB, Hello!
05:25AWizzArdomg
05:25AWizzArd;)
05:26adityo~max people
05:26clojurebotmax people is 185
05:27AWizzArdwtf, it was 191 yesterday
05:28AWizzArdclojurebot: max people is 191
05:28clojurebotAck. Ack.
05:28jdzclojurebot: max people is 255
05:28clojurebotc'est bon!
05:28jdzmake AWizzArd happy
05:28AWizzArdno, I'm going to cry, I want the real numbers
05:29jdzno, you're cheating
05:29jdz:)
05:29Chousukeclojurebot: forget max people
05:29clojurebotI forgot max people
05:29Chousuke~max people
05:29clojurebotmax people is 194
05:29ChousukeI think it's a special function that just looks like a factoid. :)
05:29Chousukeand the definitions were overriding it
05:30AWizzArdI need to get my own bot in here.
05:32AWizzArdI want to access my server S via https. On S a Jetty is running with a certificate that I created myself. Any ideas how I can make my jvm not throwing a SSLHandshakeException?
06:19Jetienhi! i have a general question. when i want to maintain a 2d state array, what is the better choice: 1. a vector of refs to vectors or 2. a vector of vectors of refs ?
06:21Jetienor should i use some java data type?
06:21Chousukeare the states all independent of each other?
06:21Chousukebecause the easiest option would be just to have a ref to a vector of vectors
06:25Chousukea ref containing refs makes it difficult to have a consistent snapshot
06:26Jetienyeah they are very independent of each other
06:27Chousukethe vector of refs approach can be fine if the refs or their values don't depend on each other.
06:28Jetienhm what do you mean by depend? in my case there are just integers
06:28Jetiens/there/they're
06:28Chousukeas in, to determine the value of one ref you need to read the others as well
06:28Chousukein general, you should keep the granularity low at first and increase it if it becomes a bottleneck.
06:28Jetienah i see, no not the case
06:29Chousukecoordinating many refs at once is difficult, and a vector of vectors of refs is really little better than a mutable 2d vector :/
06:29Jetienhow does this approach perform anyway? is it not better just to use some java data type?
06:30Chousukedepends on what you need, I guess.
06:30Jetienhm huge in size like 1000x1000 with a lot of changes
06:30Chousukewith java data types Clojure can offer no assistance
06:31Chousukehmm.
06:31Chousukeand it'll contain integers?
06:31Jetienbut only one thread
06:31Jetienyes
06:31Chousukethen I suppose having a million refs would be unacceptable overhead, memory wise.
06:32Jetienand time wise?
06:32Chousukeprobably.
06:32Jetienhm okay
06:33Chousukeand if it's single-threaded there won't be much concurrent access to protect against.
06:34Chousukeso if you just use an array you'll only have to be careful not to depend on any previous value of the matrix
06:34Jetieni always wondered how a ref to vector performs if there are a lot of changes.. does the garbage collector clean up immediately?
06:34Chousukeit should be fine.
06:34Chousukeif your changes are done as a batch you can also use transients
06:35Jetienactually i never used concorrent programming ;) i'm all in for the lisp + java thing
06:35Jetienlet me google "transients"...
06:36Chousukethe array will likely perform best, but you will also not get all of the advantages immutability
06:36Chousuke~transients
06:36clojurebothttp://clojure.org/transients
06:37Chousukebasically a local mutable version of a persistent collection for making a lot of changes, with a fast operation for transforming it back into an immutable one again.
06:40Jetienah that's nice...
06:40Jetieni think that's what i'm looking for
06:41woobyJetien: http://clj-me.cgrand.net/2009/10/15/multidim-arrays/
06:41Jetienthanks
06:41woobyno problem, i was trying to figure this out myself the other day
08:27vyWhat's the best way to model a matrix in a functional style in Clojure? Using a 1D vectors and mapping 2D coordinates to 1D coordinates via abstraction functions?
08:29woobyvy: i've done it that way, here's another: http://clj-me.cgrand.net/2009/10/15/multidim-arrays/
08:29woobyas to what's best, i don't know enough to know ;)
08:30yasonvy: how large matrices? for what purpose?
08:32yasonvy: if you're doing simple 2D/3D stuff with your matrices, you could just use a vec of suitable length (like 6 entries for 2 x 3 matrix in 2D space) and use destructuring in defning the basic matrix ops since you pretty much know what you're going to add/multiply
08:33vyyason: I'll issue quite much col/row swap operations on a matrix collection of size ~100 where matrices are of size ~1000x1000.
08:33yasonvy: that's a bit too much for destructuring :)
08:36yasonvy: [Disclaimer: I'm a beginner] You probably want speed too so you could consider make-array even though it's mutable. The functional approach would probably be to make the high-level functions pure -- even though you did mutations inside some matrix operation
08:37octewhen running emacs slime with clojure i get "Lisp connection closed unexpectedly: connection broken by remote peer
08:37octe"
08:37octeused to work..
08:37octeanyone have any clue what it could be?
08:38yasonocte: slime/swank crashed?
08:38yasonocte: sync to the latest sources and see if it reproes
08:39octeyason: i sycned slime and swank-clojure to the latest
08:39octeshould i sync clojure too?
08:52vyIn a `struct-map' call, Clojure complains that "clojure.lang.PersistentStructMap cannot be cast to clojure.lang.PersistentStructMap$Def", what could be causing this error?
08:56arsatikivy: please post the code to a pastebin
08:59chouservy: you need (struct-map foo ...) where foo is the name you gave in a (defstruct foo ...)
09:05vyarsatiki: chouser: Thanks. I think I figured out the problem.
09:25yasonocte: IIRC there's a different swank/slime for Clojure 1.0 and trunk
09:25yasonocte: but if you're using the latest Clojure, then you probably should have latest slime/swank
09:53chouserhuh. Proposal: Moratorium on Python language changes: http://lwn.net/Articles/357996/rss
09:54chouser"frequent changes to the language cause pain for implementors of alternate implementations"
10:03cemerickyeah, I saw that. The writing was on the wall years ago, tho.
10:03chouser90% of the comments on lwn are negative.
10:05cemerickthe ISO standardization notion at the end is *hilarious*
10:05spuzI don't understand that article. If you're changing python every month it doesn't imply that you need to change Jython every month does it?
10:06chouserI think it's interesting to consider Clojure's related position in light of cinc.
10:07rhickeychouser: in what way?
10:07cemerickspuz: I think that's a red herring. The language has been largely frozen for years, it's just been window dressing for some time.
10:07spuzchouser: why, how much is cinc going to affect users?
10:07chouseronce cinc is done, the amount of work to create a Clojure host-port will be pretty small compared to the amount of work to create Jython
10:07spuzI see
10:08chouserand with that small creation work comes smaller maintenance work. It should be rather less effort to keep the ports in sync.
10:08rhickeythe biggest difference is that a Lisp has so little in the language/compiler proper - most is libraries
10:09chousermany changes that would count as "grammar or language semantics" won't require any porting work at all
10:09notallamashouldn't pypy do that, too? you only need to implement the part for pypy requires.
10:09chouserright, because they're implemented in the core "library"
10:10chouserbut even changes on the scale of "defclass" which are likely to be much rarer will still be largely discreet pieces and comparatively little effort, I think. Well, I hope anyway.
10:10djorkindeed, it's pretty hard to make a "breaking change" to the syntax of a Lisp
10:10notallamai thought that was the entire point of pypy, actually: to make porting python easier.
10:11cemerickI thought it was an optimization and 'alternative feature' (e.g. continuations) playground.
10:11djorkalthough Clojure's reader is more complex than any other Lisp I've seen
10:12notallamacomplex meaning it has 3 different kinds of brackets?
10:12djorkwell yeah, that and a lot of the reader dispatch macros
10:14djork() [] {} #{} ' ^ @ # #"" #' #_ #() #^ ^# #^{} ` ~ ~@
10:14djorkbut the read table is a nice implementation
10:15djorkI wish I could extend it
10:16djorkbut maybe not :)
10:16chouserdjork: you're not the only one to express interest. :-)
10:17djorkI guess I shouldn't trust myself with the ability to add reader macros if I can't trust other people
10:21arsatikidjork: what does ^# do?
10:21djorkoops maybe not that one
10:22chouser#^ is pretty much the same as #^{}
10:22tmountainis there a summary table online somewhere with all the reader macros in it?
10:23chousertmountain: http://clojure.org/reader
10:24notallamahow would user reader macros work with namespaces? presumably you'd want a way to use a namespace minus a reader macro.
10:25chousernotallama: that's similar to rhickey's main objection
10:26chouserI had a proposal to solve the namespace issue and address some percentage of reader macro use-cases, but I think it was seen as sort of a "worst of each" compromise.
10:28djorkI think it could cause maintainability and readability issues to let people add custom reader macros. Regular macros are powerful enough.
10:28djorkit starts to look like Perl with too many of them
10:31ambienti wouldn't necessarily have a problem with encapsulated reader macroes that implemented a DSL
10:31ambientmeaning, I would find that thing probably very useful
10:31djorkprobably
10:31chouserthink xpath or a custom regex implementation
10:31djorkgranted pretty much anybody that is working with Clojure code is working on it by themseves
10:32djorkor how about XML-in-Clojure
10:32djorklike, literally XML
10:32cemerickoh, god, no
10:32djork:)
10:32djorklike Scala
10:32cemerickseriously, no.
10:32djorkI rest my case
10:32vyWhat's wrong with (defn distinct-rand-int-seq [n m] (first (remove #(apply = %) (repeat #(repeat m (rand-int n)))))) that Clojure complains that "Don't know how to create ISeq from: foo$rand_int_seq__2939$fn__2944"?
10:32ambientarray slicing operations would be nice with reader macroes afaict, as little as I know about them
10:33chousercemerick: but weren't you just calling for literal Java? you could do that with a reader hook
10:33djorkinline Java?
10:33djorkinteresting idea
10:33chouserambient: I don't think a reader macro helps much there -- maybe slightly more terse than (slice x 4 5)
10:34cemerickchouser: Big difference between simplifying integration with the host language and choosing to elevate a particular data representation to a first-class entity.
10:34chousercemerick: right, I'm just saying a reader hook allows both
10:35cemerickjava-in-parens would surely require a reader mod, but I don't think that's an argument for a generalized hook.
10:35chouservy: I'm not sure repeat does what you think it does.
10:35djorkyeah
10:36ambientchouser i should look more into lisp implementation of Matlab or Numpy style array processing, but I don't believe that it would be so readable nor concise
10:36djork,(repeat 10 (rand-int 10))
10:36clojurebot(2 2 2 2 2 2 2 2 2 2)
10:36djork,(repeat 10 "hi")
10:36clojurebot("hi" "hi" "hi" "hi" "hi" "hi" "hi" "hi" "hi" "hi")
10:36vyhrm...
10:36chouser,(repeat 3 #())
10:36clojurebot(#<sandbox$eval__3820$fn__3822 sandbox$eval__3820$fn__3822@1558d62> #<sandbox$eval__3820$fn__3822 sandbox$eval__3820$fn__3822@1558d62> #<sandbox$eval__3820$fn__3822 sandbox$eval__3820$fn__3822@1558d62>)
10:36djorkhah
10:36djork,(take 10 (repeatedly #(rand-int 10)))
10:36clojurebot(2 5 9 0 4 0 3 3 9 6)
10:39octeugh.. my slime setup still gives me "Lisp connection closed unexpectedly: connection broken by remote peer"
10:39octerun latest of.. everything
10:39octeanyone have any idea how to debug it?
10:42vywhat does *inferior lisp* buffer tell?
10:43octehttp://pastebin.ca/1645194
10:44octethat's all
10:44patricius_would Clojure ever be able to be as 'efficient' as Erlang in terms of "process spawning"?
10:44octehttp://pastebin.ca/1645195 <- slime-events
10:44patricius_I'm asking since Clojure uses 'real threads' as opposed to Erlangs 'green threads'
10:45vyocte: M-x slime-abort-connection M-- M-x slime clojure (when asks for an extra inferior lisp, say no.)
10:45djorkpatricius_: I think Clojure and Erlang have different priorities
10:46djorkpatricius_: Clojure is better at balancing computation on multiple cores, Erlang is better at distributing computation across multiple servers
10:46patricius_djork: clojure is for parallelism and erlang for massive concurrency?
10:46ambientpatricius_ the way I understood it, agents use 'green threads', but I haven't really studied or used them in depth
10:46octepatricius_: that seems to work
10:47octeerr
10:47octevy: that seems to work
10:47octedoesn'
10:47octet hnmm
10:47octesays Connected. Hack and be merry!
10:47octebut doesn't give me a repl buffer
10:47octeand sending soething to it gives an error
10:48octeerror in process filter: slime-dispatch-event: Elisp destructure-case failed: (:write-string "hi
10:48octe")
10:48octeerror in process filter: Elisp destructure-case failed: (:write-string "hi
10:48octe")
10:48octenil
10:49lisppaste8rhickey pasted "playing with defclass" at http://paste.lisp.org/display/89364
10:51rhickeystill todo: Seqable, Counted, toString, Associative...
10:52vyocte: See http://paste.lisp.org/display/89365
11:03djorkrhickey: how much work for defclass is "under the hood?"
11:03djorklooks like IObj and ILookup?
11:04chouserthose are just interfaces
11:04djorkoh right
11:05rhickeydjork: not sure about your question, defclass and deftype build on defclass* which is a generic exposure of code generation capability that had been locked inside fn
11:05djorkoh ok
11:05octevy: still doesnt work, but now i get some errors when doing the connection with M- prefix
11:05octehttp://paste.lisp.org/display/89366
11:06chouserdefclass* doesn't do closures though, right? so fn will still need compiler help?
11:07ambientto implement a repl in a swing window would i just have to read, eval, loop? :p
11:07rhickeychouser: there is a minor partitioning around closure, defclass* roots the environment at the field set, fn and newnew don't
11:07rhickeynewnew is still there and shares all of the benefits, like bridge generation
11:07chouserrhickey: ok. can they share gen code?
11:07rhickeyoh yes
11:07chouserah, fantastic.
11:08chouserambient: yep. it's been done a couple times.
11:08ambientcool, thanks. i just thought that I was being blindsighted by something obvious :)
11:08rhickeywhen/if I expose volatile again it will likely be for defclass* only
11:09chouserthis will be such a clean bytecode-gen api, I wonder if other languages will use it.
11:09chouserimplement my-new-toy-language in clojure instead of java+asm
11:09ambienti'd think Forth was better for that ;)
11:27gerry_hello
11:28Licenseraloa
11:31gerry_i'm looking at hickey's paste code, (:d x 42) used for what?
11:33djorkwhat's the best way to reload a lib from a repl?
11:34djorkoh :reload
11:37chousergerry_: that's a ILookup by keyword :d, with 42 used as the "not found" value.
11:37gerry_it seems not work
11:37chouserI haven't tried it. what does it return?
11:38gerry_nil
11:38chouserhm.
11:39gerry_(:d x 42) return 42, but (:d x) return nil
11:40chouseroh, that's correct
11:40chouser:d doesn't exist in x, so (:d x) should return nil and (:d x foo) should return foo
11:41gerry_(defclass one [#^int a #^String b])
11:41gerry_i got " Can't type hint a primitive local " error msg
11:43gerry_chouser: you are right
11:43headiusthat's the defclass syntax?
11:43headiuswhat is #^ doing there?
11:44chouserheadius: defclass barely exists yet. http://paste.lisp.org/display/89364
11:45chouserheadius: the #^int a attaches metadata {:tag 'int} to the symbol a, which defclass then interprets as the type it should make field a to be.
11:46headiusI see
11:46headiusis that a clojurism or a lisp thing (the #^ syntax)?
11:47chouserheadius: I believe #^ is not in other lisps
11:50gerry_rhikey's paste code works here, good job, congr richkey!
11:51stuartsierra#^ is a Clojure reader macro to attach metadata to the *following* symbol or data structure
11:51headiusok
11:54Licensermuhaha I forked my first github project!
11:56djorkcongrasturbations
11:56Licenserthank you djork and it's even in clojure :P
11:57djorkdid you fork your own project or someone else's? :)
11:57LicenserI forked somnium mongodb driver
11:57Licenserbecause I spend the day in airplains and took the time to fix some problems I had with it
11:57Licenseror started to fix :P
11:57Licenserso I figured why not try out how it works
12:53yurasi would like to change behavior of function accept-fn of contrib/server-socket. what is the idiomatic way to make it if i dont want to copy&paste whole server-socket server? is there a way?
12:55Chousuke~def server-socket
12:55clojurebotexcusez-moi
12:55Chousuke;(
12:55yuras~def create-server
12:57Chousukehmmh
12:58yurasbasically i want to make it passing socket object into function, i know i can rewrite it completely, but thinking about the better way. the thing that i need to know ip address of remote socket
12:59ChousukeI don't think there's a better way
12:59fabehi beginners question: is their a sum function like in python ?
12:59Chousukefabe: it's + :)
12:59Chousuke,(apply + [1 2 3 4])
12:59clojurebot10
12:59fabe(+ coll) ?
12:59ambient,(reduce + [1 2 3])
12:59clojurebot6
12:59Chousukeor that
12:59fabek thx
13:00arsatikiis there a significant performance difference either way?
13:00arsatikioh wait, I have a repl. I can check for myself.
13:00Chousukewell, + uses reduce internally
13:00ambientsuch micro-optimazion likely has no value
13:00Chousukeyeah
13:01Chousukeoften, apply is better though.
13:01Chousukefor example, (apply str '[foo bar whatever]) is faster than (reduce str '[foo bar whatever])
13:03arsatikiyeah. no value whatsover =)
13:03Chousukestr uses a stringbuilder internally in the apply case, but using reduce will force it to create temporary strings
13:03tmountainon my box, reduce is faster in this case (not that it matters much)
13:03tmountain(time (reduce + (range 1 10000000))) "Elapsed time: 804.801736 msecs"
13:03tmountain(time (apply + (range 1 10000000))) "Elapsed time: 3275.64601 msecs"
13:04hiredmanthat is +
13:04Chousukehmm, that might actually be because of chunked seqs
13:04hiredmanChousuke is talking about str
13:04Chousukeperhaps using apply will lose the chunkiness information of range, so the reduce in + can't take advantage of it
13:05tmountainI need to read up on chunked sequences
13:05tmountainso many new concepts coming down the pipe that it's hard to keep up ;-)
13:06ambienti thought the chunkiness was mostly automatic, at least I haven't had to burden my brain with it
13:06ambientat least I shouldn't ought to
13:06Chousuke(letfn [(foo [a b & therest]] (chunked-seq? therest))] [(apply foo (range 1000)) (chunked-seq? (range 1000)])
13:06Chousuke.,(letfn [(foo [a b & therest]] (chunked-seq? therest))] [(apply foo (range 1000)) (chunked-seq? (range 1000)])
13:06Chousuke,(letfn [(foo [a b & therest]] (chunked-seq? therest))] [(apply foo (range 1000)) (chunked-seq? (range 1000)])
13:06clojurebotUnmatched delimiter: ]
13:06arsatikitmountain: fascinating. I can't reproduce that at all (I get 800 +- 20 msec with both)
13:06Chousuke:P
13:06Chousukehm
13:06ambienthaha :D
13:06Chousukegah
13:06Chousuke,(letfn [(foo [a b & therest] (chunked-seq? therest))] [(apply foo (range 1000)) (chunked-seq? (range 1000)])
13:06clojurebotUnmatched delimiter: ]
13:07arsatikitmountain: do you have a cutting edge clj perhaps?
13:07Chousuke...
13:07tmountainClojure 1.1.0-alpha-SNAPSHOT
13:07Chousuke,(letfn [(foo [a b & therest] (chunked-seq? therest))] [(apply foo (range 1000)) (chunked-seq? (range 1000))])
13:07clojurebot[true false]
13:07Chousukehuh
13:07Chousukeinteresting.
13:08ChousukeI would have expected the opposite
13:08arsatikitmountain: right. I have 1.0.0
13:09chouser,(chunked-seq? (seq (range 1000)))
13:09Chousuke,(time (reduce + (range 1000000)))
13:09clojurebot499999500000
13:09clojurebot"Elapsed time: 771.331 msecs"
13:09clojurebottrue
13:09Chousuke,(time (apply + (range 1000000)))
13:09clojurebot499999500000
13:09clojurebot"Elapsed time: 1472.001 msecs"
13:09arsatikihuh
13:09tmountainI'm guessing clojurebot is bleeding edge?
13:09Chousuke,(time (reduce str (range 10000)))
13:09clojurebot"0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
13:10clojurebot"Elapsed time: 1562.735 msecs"
13:10Chousuke,(time (apply str (range 10000)))
13:10clojurebot"0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
13:10clojurebot"Elapsed time: 30.616 msecs"
13:10Chousukefunky, huh :P
13:10tmountainwow
13:10arsatikiyeah
13:10ambientthe basics of string concatenation
13:10Chousukein the str case it's obvious why apply is so much faster, but the + case is surprising
13:11hiredmanclojurebot: clojurebot is not a benchmarking platform
13:11clojurebotc'est bon!
13:11ambientreduce is (f (f (f (f str)))) apply is (join str-a str-b str-c)
13:12Chousukeambient: the (f (f (f ...))) one is iterate though. :) reduce is (f str3 (f str2 (f str1 init)))
13:13Chousukethough the parameter order is the other way around :P
13:13hiredman,(time (reduce #(.append %1 %2) (StringBuilder.) (range 10000)))
13:13clojurebot#<StringBuilder 0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
13:13clojurebot"Elapsed time: 1415.392 msecs"
13:14Chousuke,(time (reduce #(.append #^StringBuilder %1 %2) (StringBuilder.) (range 10000)))
13:14clojurebot#<StringBuilder 0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
13:14clojurebot"Elapsed time: 9.241 msecs"
13:14hiredmanzounds
13:14Chousukeavoiding reflection = important
13:14ambientChousuke yes, but i was trying to illuminate the fact that reduce is recursive and apply iterative, at least in this case, AFAIK
13:14ambienthmm, or is iterative the word im looking for
13:14hiredmanerm
13:15hiredmanreduce is iteriation implimented via recur
13:15ambientthe point is that reduce does string=string+stuff at each step and apply does string=a+b+c+d+e+f
13:16hiredmanambient: but str has to use a loop that is just like reduce internally to process all the args
13:17ambientstr can do (let [new-string-len (+ (length a) (length b) (length c))] ...)
13:18fabewow getting your head around functional programming is harder then i thought took me an hour to to write my first small programm :)
13:18ambientwhereas string=string+stuff doesn't know the final result and thus has to do O(n) operation at each step of iteration
13:18hiredmanambient: no, it can't
13:18hiredmanstrings are immutable
13:19ambientwell then, create a new string which is the old string plus some other stuff. same diff
13:19hiredmanso you can't just declare a string of length n and fill it in, and you would still have to use a reduce-ish looking loop
13:19ambienti see
13:20ambientbut clojure strings are java strings, i read that somewhere
13:20hiredmanand java strings are immutable
13:20ambientso perhaps the innards are still mutable
13:20hiredmannope
13:20arsatikiI tried to do a faster integer sum with type hits but ran into a snag. How do I tag primitive types?
13:20chouserThe difference is StringBuilder is mutable and so can cheat
13:21arsatikiUsing #^int says "Unable to resolve classname"
13:21chouser(apply str ...) uses a StringBuilder internally where (reduce str ...) can't
13:21hiredman~performance
13:21clojurebothttp://clojure.org/java_interop#toc46
13:22hiredmanarsatiki: that's for you
13:23chouserhiredman: have you considered a way to tell clojurebot to direct an answer at someone? don't know what the syntax would be.
13:23rhickeydeftype is alive!
13:23arsatikihired: tnx. Turns out that was a bad idea :)
13:24hiredmanclojurebot: tell so and so about something
13:24clojurebotGabh mo leithscéal?
13:25chouserrhickey: so cool. I won't have a chance to port finger trees for a couple days, but I'm looking forward to it. Should be a great fit.
13:26chouserrhickey: ought to be able to use 'new' to implement defclass interfaces until protocols are ready? or am I jumping the gun?
13:27rhickeychouser: I'm not sure what about what you;ve already done would have to change
13:28chousergen-interface stays for now?
13:28rhickeybut generally, yes, you can always wrap an interface in a protocol
13:28rhickeyI'd like a definterface that matches deftype/defclass syntactically
13:28rhickeybut same plumbing as gen-interface
13:28chouseryeah, ok.
13:29chouserso right now each node and digit data is stored in a newnew closure
13:29chouserwith hand-written accessors as needed
13:29chousermoving that to deftype would be a win I think
13:30rhickeyaccessors used outside the node?
13:32chouserused by other instances of the same class, yes.
13:33chouserspecifically, the pre/mid/suf triplet that makes up a deep-node.
13:33rhickeyok, so with defclass you can get .field access to other instances of same type, with deftype only :field access
13:33rhickeyin either case no manual accessors needed
13:34rhickey(defclass gives you :field as well)
13:34chouserright. so deftype's dynamism would have been lovely during development, but now I'd probably go straight to defclass
13:35rhickeythat's the idea, although for many use cases you;d never need to go to defclass, swapping defclass for deftype and . for : is a breeze
13:35chouserright, I've already crossed an ugly line or two trying to wring performance out of finger trees, so defclass for me.
13:36chouserthe one area I haven't worked on performance is the measure/reduce stuff, but I have a vague notion that deftype/defclass may be great there too.
13:37chouserright now, users pass in a map of vectors of fns: {:size [(constantly 1) + 0] :str [str str ""]}
13:38chouserwell, two fns and a seed value
13:38chouserbut it probably ought to be either a map or a plain list of instances that implement IMeasureReduce or something
13:39chouserhm, except I don't know the types involved, and primitives would be really nice is I could find a good way to store them...
13:49leafwis there any way to pretty-print maps of maps with indentation?
13:49chouserleafw: clojure.contrib.pprint
13:50Chousukecontrib has a pretty-printer. maybe you can use that?
13:50RaynesHow would I filter through a sequence, removing every other element of the sequence?
13:50chouser,(partition 2 1 (range 10))
13:50clojurebot((0 1) (1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9))
13:50leafwchouser, Chousuke: I called (pprint {:a 1 :b 2 :c {:f 11 :g 44} :r 34}) and printed all in one line.
13:50chouser,(partition 1 2 (range 10))
13:50clojurebot((0) (2) (4) (6) (8))
13:50chouser,(map first )(partition 1 2 (range 10))
13:50clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$map
13:50leafwI am trying to figure out where are the docs
13:50chouser,(map first (partition 1 2 (range 10)))
13:50leafwthere may be options.
13:50clojurebot(0 2 4 6 8)
13:51RaynesThanks.
13:51Chousukeleafw: contrib documentation is on github
13:51Chousukelinked in the wiki
13:52Chousukehttp://richhickey.github.com/clojure-contrib/pprint-api.html here. :)
13:53leafwthanks.
13:55leafwwoah, pprint doesn't indent by default and the docs are just ... way too low level
13:57leafwso, despite all the effort put by the author, I find pprint useless. Dead-brain examples would be nice.
13:59hiredman,(doc *pretty-print*)
13:59clojurebotNo entiendo
13:59chousertry pprinting a bigger map.
13:59hiredmanuselesss
13:59chouserI'm pretty sure it's done a nice job intedenting without any special options for me.
13:59hiredman~def *pretty-print*
13:59clojurebotI don't understand.
13:59leafwhiredman: (doc pprint)
14:00hiredmanleafw: *pretty-print* is one of pprint's tuning vars
14:00hiredmanthe docs say bind to true if you want pretty printing
14:00hiredmanbut the source reveals that it defaults to true
14:01hiredmanmaybe play around with miser-width
14:02leafwhiredman: I read the pprint_base.clj code and I I saw that too: all one can do is limit the width.
14:04hiredman,(take-nth (range 10) 2)
14:04clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
14:04hiredmanbah
14:04hiredman,(take-nth 2 (range 10))
14:04clojurebot(0 2 4 6 8)
14:07leafwto concat two vectors? I keep forgetting this simple things
14:07leafwit's not conj, neither conc or concat
14:07Chousuke(into vec1 vec2) works
14:08leafwinto ... reads like misusing it, but thnaks
14:08Chousukenot really :)
14:51yurashow to make hash map from sequence? like (a 2 b 4) -> {a 2, b 4}
14:53leafwyuras: a combination of zipmap and interleave ... it can be done.
14:55chouser,(apply hash-map
14:55clojurebotEOF while reading
14:55chouser,(apply hash-map '(a 2 b 4))
14:55clojurebot{a 2, b 4}
14:56leafwthere, eev easier.
14:56yurasoh, blame me
14:59yurasspeaking of shortest ways. i made transformation of ((1 2) (3 4)) -> {1 2, 3 4}
14:59yurasthis way
14:59yuras(apply hash-map (reduce concat '((1 2) (3 4))))
14:59yurasis that the shortest one? :)
15:00yuras,(apply hash-map (reduce concat '((1 2) (3 4))))
15:00clojurebot{1 2, 3 4}
15:01chouser,(into {} '((1 2) (3 4)))
15:01clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map$Entry
15:02chouser,(into {} '([1 2] [3 4]))
15:02clojurebot{1 2, 3 4}
15:02chouser,(into {} [[1 2] [3 4]])
15:02clojurebot{1 2, 3 4}
15:02chouseryuras: the inner things must be lists and not vectors?
15:02yurasthat what re-split returns
15:03chouser,(into {} (map vector '((1 2) (3 4))))
15:03clojurebotjava.lang.IllegalArgumentException: Vector arg to map conj must be a pair
15:03chouser,(into {} (map vec '((1 2) (3 4))))
15:03clojurebot{1 2, 3 4}
15:03yurasoh man, you are wizard
15:04chouserAWizzArd: <-- no he's the wizard apparently. :-)
15:06djorkinto is magic
15:09yurasyeah, digging the sources
15:10yurasis there a way to peek sources of function from repl?
15:11djorkI dunno but it's a nice idea.
15:12yurascheat sheet contains source as doc fun, but its not resolved in 1.1 snapshot
15:13djork,^#'into
15:13clojurebot{:ns #<Namespace clojure.core>, :name into, :file "clojure/core.clj", :line 4561, :arglists ([to from]), :doc "Returns a new coll consisting of to-coll with all of the items of\n from-coll conjoined."}
15:13djorkoh god it's perl
15:13djorkso there you get the file and line
15:13djorkand you can go from there probably
15:13leafwsuppose I have an input stream with clojure code to evaluate. What is the best way to do it? Perhaps load-reader ?
15:14yurasoh. (source x) is in (use 'clojure.contrib.repl-utils) !
15:14djorkyay, I thought it might be
15:14yuras,(source into)
15:14clojurebotSource not found
15:15djorkaw
15:15djorkclojure src must not be in the classpath for the bot
15:16djorkmaybe it could be if we ask nicely?
15:17yuras~def into
15:18yurasi guess its like that and no more
15:19djorkis it just me or is into not tail-recursive?
15:19djorkcould it blow the stack with a big enough from?
15:19chouser'recur' is illegal outside a tail position
15:19djorkoh ok
15:19djorkI must not understand tail position
15:19chouseryet another reason to love it
15:20djorkif you have (if foo bar), foo is in tail position?
15:21chouseryes
15:21chouserno
15:21yurasits not
15:21chouser(if test then else)
15:21chousertest is not in tail position, but then and else are
15:23yuraseven after python, clojure operations on data look like huge boost, so many and so powerfull
15:23djorkerr yeah that's what I meant
15:23djork(if test foo bar) foo is in tail position
15:23chouserdjork: yes
15:24djork(if test (bar (foo)) bat) foo is not in tail position
15:24chousercorrect
15:25chouser(if test bar (bat (foo))) foo is still not in tail position, even though it's "last"
15:26djorkright
15:26yurasb/c foo is applied earlier than bat?
15:26djorkbecause it's the *returning* call that is in tail position
15:26djorkand there can be many tail positions
15:26chouseryes
15:26djorkOK that clicks now!
15:27djorkI never made the connection between tail call and returning
15:28chouser(do x y z tail) (if x tail tail) (let [a b c d] x y z tail)
15:28hiredmanwell, let is do + bindings
15:28chouser(fn [a c] x y z tail) (loop [a b c d] x y z tail)
15:29hiredman,(lett [x 1 y 2] (+ x y))
15:29clojurebotjava.lang.Exception: Unable to resolve symbol: lett in this context
15:29chouser(cond a tail b tail c tail)
15:32hiredman,(lett [x 1 y 2] (+ x y))
15:32clojurebot3
15:32hiredman,(macroexpand-1 '(lett [x 1 y 2] (+ x y)))
15:32clojurebot((clojure.core/fn [x] (sandbox/lett [y 2] (+ x y))) 1)
15:33hiredmanexplodes if you try to recur across it, which the real let doesn't
15:46tomojhow do you name your structmaps?
15:46chouserwhat's the best possible stack trace behavior for macro expansions?
15:46tomojI find I want to call my local variables the same thing I used as the name of the structmap
15:47hiredmanI like <foo> with foo being the name of the factory function
15:47tomojwow, I hadn't realized <foo> was valid, nice
15:48hiredmanit might not be technically, but it works
15:48chouserI suppose a sort of nested stack? Where you could see the filename and line number of each level of the macro expansion?
15:48chouseri think that would be desirable. is it possible?
15:49hiredmanhmmm
15:49tomojwith my structs named <foo> I don't have to use silly local variables like my-foo or the-foo :D
15:50hiredmanI think according to http://clojure.org/reader <foo> is not technically legal
15:50somniumtomoj: what's wrong with f? :)
15:50tomojhuh
15:50hiredman,'!foo!
15:50clojurebot!foo!
15:50tomojI wonder why it works, then
15:50hiredman,'|foo|
15:50tomoj,'<foo>
15:50clojurebot|foo|
15:50clojurebot<foo>
15:50chousermuch is permitted that is not supported
15:51hiredmantomoj: the actually implementation is very lax in what it allows
15:51hiredman:/
15:51tomojwell I like <foo>. easy to search/replace if it stops working someday.
15:51hiredmanhmmm, |foo| is not legal either
15:51hiredman-foo-
15:51chouseryou could use Foo
15:51hiredman,-foo-
15:51clojurebotjava.lang.Exception: Unable to resolve symbol: -foo- in this context
15:52somnium,(let [&$!# '<foo>] &$!#)
15:52clojurebot<foo>
15:52hiredman:P
15:52hiredmanclojurebot: much is permittted
15:52clojurebotRoger.
15:52somniumreally, I don't get why the perl community isn't all over clojure
15:53arbschtsomnium: &$!# that.
15:53somnium:)
15:54tomojI hate uppercase
15:56yuras,(into {} (for [[k v] '((1 2) (3 4))] [k v]))
15:56clojurebot{1 2, 3 4}
15:56yuras,(into {} (for [[k v] '((1 2) (3 4))] [(keyword k) v]))
15:56clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: No matching method found: intern
15:56hiredmankeyword takes a string
15:57yurasarhg
15:57yurasthanks
16:06somniumdoes this do copy-on-write: PersistentHashMap.create(new java.util.HashMap()); ?
16:06Chousukeprobably not.
16:06somniumhmm
16:06chouserhow could it?
16:07somniumpresumably there's something in the map
16:07chouserjava.util.HashMap could change and PHM wouldn't know
16:09chouserbut anyway, no. it uses temporary transients to build a PHM copy of the juHM at the moment the PHM is created.
16:09Chousuketemporary transients :)
16:10somniumwhat about: PersistentHashMap.create(some-mutable-java-map-from-the-db-with-mutable-stuff-in-it);
16:10chouserChousuke: yeah, maybe that was a bit unnecessary. :-)
16:11chouserIf you've got a non-temporary transient you're already in trouble
16:11chousersomnium: PersistentHashMap.create doesn't do anything deep, so you'd get a PHM of mutable things.
16:12somniumok, thanks
16:12chouser,(let [m {:a (into-array [1])}] (aset (:a m) 0 99) (-> m :a first))
16:13clojurebot99
16:16somniumis there anything like an into-with (a la merge-with) in core or contrib?
16:19chouserwhat would it do?
16:20hiredmansounds like reduce
16:20hiredman,(reduce conj #{} '(a b a c d g g w))
16:20clojurebot#{w a c b g d}
16:20somniumit does, doesn't it
16:21chouser,(into #{} '(a b a c d g g w))
16:21clojurebot#{w a c b g d}
16:21chouserI still don't get it.
16:22somniumI was thinking [ x y & fs] (let [f (apply comp fs)] ... (conj x (f y)))
16:22hiredmanchouser: yes, but with reduce you can specify to the function
16:22hiredmanthat's called map
16:23hiredman,(into #{} (map inc (range 10)))
16:23clojurebot#{1 2 3 4 5 6 7 8 9 10}
16:23somniuminto isn't lazy
16:24hiredmancorrect
16:24djorkI think I want to implement a slideshow lib. Would that fit in contrib?
16:24chousernothing that returns a vector can be lazy
16:24djorkOr is that too high level?
16:24hiredmanthe only that is lazy are seqs, into produces things that arn't seqs
16:24somniummap is lazy
16:24somniumso it wouldn't be exactly the same, or I am I confused?
16:24djorkPLT Scheme has the Slideshow language. Clojure could do the same thing.
16:25Chousukewhat does that do?
16:25djorkChousuke: you mean Slideshow?
16:25Chousukeyes
16:26djorkit lets you define slideshow presentations (think Powerpoint) in Scheme
16:26hiredmansomnium: map returns a seq
16:26hiredmanalways
16:26hiredmanseqs can be lazy, so map is lazy
16:26somnium(source map)
16:27hiredman~def map
16:27somnium~def into
16:27hiredmanI already told you the difference
16:28hiredmanSequences are the only non-explicitly lazy thing in clojure
16:28hiredmanmap returns a sequence, into returns whatever type of collection you prime the pump with
16:29hiredman,(into {} '([a b] [c d]))
16:29clojurebot{a b, c d}
16:32chouserI can never ever remember which arg comes first for 'with-meta'
16:33chouserHm, the opposite order that #^ uses. Maybe that'll stick this time.
16:35arsatikihere's my mnemonic: with-meta consists of two words, the latter of which is meta. it takes two arguments, the latter of which is meta.
16:35hiredmanchouser: just think of it as a call to the .withMeta method
16:35chouserarsatiki: ok! thanks guys, maybe next time I can avoid running 'doc' again.
16:36danleijust use emacs
16:37djorkheh, yes, slime solves all of my argument-order woes
16:37tomojexcept for struct
16:39chouseremacs has already caused me more pain than any piece of software has the right to.
16:39somnium:)
16:40chouserthen again, so has a bunch of software I still use, so I guess I should quit whining.
16:40danleiyes, it did that to me, too. but it also gave me more pleasure than any other :)
16:40djorkI picked up Emacs to cut down on pain.
16:40djorkEditing Lua on Windows.
16:40djorkWith no other significant tools.
16:41danleiwhen emacs is set up, everything is fine. it's just that it takes a lifetime :)
16:41hiredmanlua is a neat little language
16:41hiredmanI love that the lua build process doesn't involve autotools
16:45djorkLua is truly lovely. The function environment features is really cool. Clojure could use something like it for sandboxing.
16:45djorkbut it goes a bit too far for clojure, probably
16:46djorkwoah, paged things in github have vim shortcuts
16:46hiredmanmy mp3 player has a lua interpreter
16:50djorka lot of things do... it's like sqlite
16:51chouserooh, are there lua bindings for sqlite?
16:51hiredmanthere must be
16:51chousergah, what am I saying. I retract the question.
16:52leafwxD
16:52hiredmanhttp://github.com/hiredman/odds-and-ends/blob/master/lisp.lua
16:52chouserclojure is great for embedding in existing Java apps to make them scriptable, dynamic, whatever. We just need a version that will do the same for C-based apps.
16:53hiredmanI'm pretty sure I never finished the interpreter
16:53tmountainchouser: won't that be a real possibility once clojure in clojure is done?
16:53chousertmountain: maybe, but there would still be real engineering work to do.
16:54leafwis there any simple way to take two maps and return the common keys?
16:54chouserleafw: ignoring the values?
16:54leafwshort of #{(keys m1) (keys m2)}
16:54leafwyes
16:54leafwjust the keys
16:54leafwthat wouldn't work ...
16:55leafw (into (keys m1) (keys m2)) perhaps
16:55chouserleafw: that gets you both
16:55chouser(filter #(contains? m1 %) (keys m2))
16:55hiredmanleafw: look at clojure.set
16:55hiredmanor
16:56chouser,(filter #(contains? {:a 1 :b 2} %) (keys {:b 3 :c 4}))
16:56clojurebot(:b)
16:56leafwthanks :)
16:56hiredman,(doc clojure.set/intersection)
16:56clojurebot"([s1] [s1 s2] [s1 s2 & sets]); Return a set that is the intersection of the input sets"
16:56leafwprobably clojure.set would have an intersection
16:56leafwthere, thanks
16:57hiredmanhttp://github.com/hiredman/clojure/blob/readerII/src/clj/clojure/reader.clj started pulling stuff out into macros
16:57chouserbut you'd have to make a set from the maps which would be inefficient.
16:57hiredman,(.keySet {:a 1})
16:57clojurebot#< [:a]>
16:58hiredmanand most clojure.set functions just call seq on the sets anyway :(
16:59leafwchouser: I am not concerned about efficiency right now, thanks.
17:17leafwI am getting an error trace that makes no sense: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj (identify.clj:1
17:18leafw ... where at identify.clj:1 there is only a commented out line
17:18leafwno other lines of the exception stack trace refer to the file itself.
17:18kotarakleafw: you call meta somewhere on a string
17:19kotarak... maybe by passing a string to something expecting a symbol.
17:19leafwthanks kotarak -- checking
17:22leafwkotarak: you are right. In a defn, I had the string before the fn name.
17:22leafwthe doc string, that is.
17:22leafwI would have never guessed so from the Exception stack trace.
17:22kotarakleafw: IObj is the meta interface
17:23chouserthat's a compile-time exception which often has to be read a little differently
17:24chouserthe final exception which is usually listed first (not the root cause, listed last) should have a file name and line number in the message itself
17:24chouserjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IObj (<filename>:<line number>)
17:25kotarakchouser: which, as leafw wrote above, is not always the correct spot... ;P
17:25chouseroh
17:25chouseryou're right
17:25chouserhmph
17:26chouserleafw: was the bad defn in identify.clj?
17:26leafwsame for missing [] for the arguments of a fn that takes no arguments: the stack trace points to the right line, but that's all the help it provides.
17:26chouserwas the message cut off at :1 or was there a close paren there?
17:26leafwchouser: yes
17:26leafwat :1 there was a comment.
17:27chouserwell, pointing to the right line can be a huge help.
17:27chouserleafw: was there a close paren after (identify.clj:1 ?
17:28leafwchouser: yes, my bad copy/paster.
17:28chouserhmph.
17:28chouserwhen I tried it just now I got the correct line number. I wonder what's different about your case.
17:28dakronehey everyone, can someone help me understand how to get (str-utils2/replace "1d6" #"(\d+)d(\d+)" #"\1") to work with replacing regex groups?
17:28leafwtry it: create a file with (defn "bla bla" fn-name-here [] (printl "hello"))
17:29leafwI have no idea :)
17:29chouserleafw: yeah, I did that, but it pointed me at exactly the right line.
17:29kotarakOT: Is there a Windows/VimClojure user around?
17:30hiredmandakrone: I kind of doubt replace takes two regexs
17:30hiredman,(require '[clojure.contrib.str-utils2 :as s2])
17:30clojurebotnil
17:30dakronehiredman: according to the docs the replacement is allowed to be a pattern
17:30hiredman(doc s2/replace)
17:30clojurebot"([string pattern replacement]); Replaces all instances of pattern in string with replacement. Allowed argument types for pattern and replacement are: 1. String and String 2. Character and Character 3. regex Pattern and String (Uses java.util.regex.Matcher.replaceAll) 4. regex Pattern and function (Calls function with re-groups of each match, uses return value as replacement.)"
17:31chouserdakrone: (str-utils2/replace "1d6" #"(\d+)d(\d+)" "\\1x\\2")
17:31kotarakclojurebot: regex
17:31hiredmandakrone: [regex regex] is not listed as an allowed pattern
17:31clojurebotSometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.
17:31chouserthat double-escaping on replace is gross, but I don't know what would be better
17:32dakronehiredman: okay, I read it wrong, I need to use a function then?
17:32hiredmanchouser: are you sure that is right?
17:32chouserhiredman: worked here
17:32hiredmanok
17:32chouseror this, but it might get you in more trouble later: (str-utils2/replace "1d6" #"(\d+)d(\d+)" (str #"\1x\2"))
17:32dakrone(replace "foo" #"(\d)" (fn [g] g)) would work then?
17:32hiredmangenerally java uses $1 $2 for groups instead of \1 and \2
17:32chouseroh!
17:32kotarak,(s2/replace "1d6" #"(\d+)d(\d+\)" "\\1x\\2")
17:32clojurebotUnclosed group near index 12 (\d+)d(\d+\) ^
17:32chouseryeah, do that: (str-utils2/replace "1d6" #"(\d+)d(\d+)" "$1x$2")
17:33kotarak,(s2/replace "1d6" #"(\d+)d(\d+)" "$1x$2")
17:33clojurebot"1x6"
17:33leafwI have an autogenerated .clj file with 350000 lines, describing a map. And it fails to load. This map was pprint from an actual clojure map. Is there an internal limit to how big a clojure file can be to be loaded?
17:33dakronekotarak: awesome, that works
17:33dakronethank you very much
17:33kotarakdakrone: well, that's just what chouser said. :)
17:34kotarakleafw: what is the error you get?
17:34leafwkotarak: let me paste it somwehere
17:34hiredmanthe reader (written in java) has recursive calls to read, so at somepoint you will blow the stack
17:35lisppaste8leafw pasted "error loading gigantic .clj file with a map in it" at http://paste.lisp.org/display/89392
17:36leafwhiredman: the map is not very deep, only 4 or 5 levels max
17:36leafwi.e. map of maps etc.
17:37hiredmanleafw: does it contain references to lineage/identify$eval__224
17:37hiredman?
17:38leafwnot that I know of
17:38leafwthe map should be plain data
17:38leafwno functions
17:38hiredmanwell, uh, can you grep it?
17:39leafwthere is no "identify" neither "defn" neither "lineage" in it
17:39hiredmanwell, certain things like various reader macros can cause the reader to try and interpret something as a classname
17:39leafwthere are String literals like this: "BLD6 [lineage] #550"
17:39hiredmanare you sure the output is well formed?
17:40leafwAFAIK, whatever is inside the "" ought to be ignored
17:40hiredmanyes
17:40leafwI can't be sure, was geenrated from pprint
17:40leafwbut ok, I'll grep some more
17:40hiredmanwell just dump a subset of your data through pprint
17:41hiredmanis there a reason you are using pprint? if you aren't going to personally read the file, why bother pretty printing
17:41leafwvim via vimclojure colors it all correctly, that's a good sign.
17:41hiredman:(
17:41kotarak:)
17:41leafwhiredman: the reason was that I have to go through it a bit to see that its printing the right thing.
17:41hiredmanleafw: can you replicate the whole thing outside of vimclojure?
17:42leafwhiredman: you mean running it standalone, not through nailgun? Sure, that is eactly what I did.
17:42leafwI am using latest master. Perhaps I should fall back to clojure 1.0
17:42spuzdoes clojure have functions for getting data over http? Ie. making a call to a webservice API?
17:43kotarak*pfew* *wishingsweataway*
17:43hiredmanspuz: java.net.*
17:43bradfordwhat is the best way to send a fn across process boundaries and get the correct interned var on the other side?
17:43hiredmanbradford: magic pixie dust
17:43bradfordargh!
17:44bradfordI'm playing with lots of symbol, var and ns stuff
17:44leafwwhat a show stoppe.
17:44kotarakbradford: (let [the-val *var*] (fn [foo] (binding [*var* the-val] ...)))
17:44spuzhiredman: URL.openStream?
17:44jdzwell, a function is just an instance
17:44bradfordspuz: loot at contrib.http
17:44leafwhiredman: I'll try printing without pprint
17:44kotarakbradford: or the yet-to-be-included bound-fn macro
17:44jdzand instances can be serialised/deserialised, right?
17:45bradfordkotarak: what the hell is that? :-)
17:45hiredmanfns and vars are completely different
17:45bradford(let [the-val *var*] (fn [foo] (binding [*var* the-val]
17:45bradford ...)))
17:45kotarakbradford: that's the magix pixie dust
17:45hiredmanvars are just storage
17:46hiredmanspuz: sure
17:46hiredmanjdz: a fn can close over data
17:46jdzhiredman: and how does that not make it an instance?
17:47hiredmanjdz: it doesn't
17:47bradfordaren't fns just using vars as part of namespace resolution? symbol name represents fn instance, which is bound to the var in the slot in teh global namespace map that is identified by the namespace/symbol combo?
17:47kotarakbradford: say you need *out* bound to something special in function foo in another thread. Then you do (let [saved-out *out*] (fn [] (binding [*out* saved-out] (foo)))) And use the created fn to start the other thread.
17:47hiredmanit just makes instanciating a new fn complicated
17:47spuzbradford: Why didn't I think of checking clojure.contrib? :)
17:48leafwinternal println was worse: String got printed as its contents, not as a double-quoted String. IS there any other preferable way of getting a {} into a file for later storage?
17:48hiredmanleafw: don't use println
17:48kotarakleafw: prn
17:48leafwhiredman: ok
17:48kotarak,(print "foo")
17:48clojurebotfoo
17:48kotarak,(pr "foo")
17:48clojurebot"foo"
17:48hiredman,(doc pr)
17:48clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
17:49bradfordwhen i load a new process now, i resolve by looking up symbols from namespace and fn string...like so
17:49bradford(defn retrieve-fn [namespace sym]
17:49bradford (let [ns-sym (symbol namespace)]
17:49bradford (apply use :reloadall [ns-sym])
17:49bradford ((ns-resolve ns-sym (symbol sym)))))
17:50hiredmanbradford: why?
17:50bradfordthe issue now is that the client code (the code that is distributing functions onto remote processes) would like to extract the symbols for the ns and fn from teh fn instance itself.
17:50kotarakbradford: ??? doesn't namespace/sym suffice?
17:50leafwhiredman, kotarak : same error java.lang.ClassFormatError: Invalid this class index 3171 in constant pool in class file ini/trakem2/vector$eval__64 (SAT-lib-2.clj:1)
17:51hiredmanhmmmm
17:51hiredmanwell that is a different classfile
17:51leafwno, sorry, the ns was different
17:51hiredmanare these aot compiled classes?
17:51leafwthe file itself has just a map in it
17:51leafwa big, large map
17:52bradfordso, given a fn instance, what is the simplest way to get its namespace and symbol?
17:52hiredmanyeah, I mean the namespace calling load
17:52kotarakbradford: ah. You are talking about *processes* while I was thinking *threads*. Nevermind.
17:52Chousukebradford: it may not have any
17:52dakroneI understand how to do something like (dotimes [d dice] (roll-dice sides)), but I don't understand how to collect & operate on the results of all the calls, can someone explain how to add all the results together to me?
17:52bradfordright, im talking processes
17:52kotarakbradford: a fn instance doesn't have that.
17:53bradfordso i can only get it from the var, right, i.e. ^#'foo
17:53chouseryes, named vars know their namespace and name
17:53kotarakdakrone: (take dice (repeatedly #(roll-dice sides)))
17:53chouser(not all vars are named)
17:53hiredmanindeed
17:54bradfordso can i look up a var from an instance that hte var is bound to?
17:54dakronekotarak: awesome, very elegant, thank you much
17:54hiredmannope
17:54leafwok, then time to report a bug in 1.1.0-alpha-snapshot
17:54hiredmana var is just a sort of pointer to some object
17:54bradfordso none of this: (fn [x] (:ns (meta (find-var x))))
17:54bradford
17:55chouseryou could walk through ever var of every namespace looking for a value that matches
17:55chousermaybe you'd find one. maybe not.
17:55bradfordi suppose i could just quote the function and lass the symbol around rather than the fn instance itself
17:56rhickeyis the code on the remote site? if so why not just send the vars?
17:56rhickeyare you actually serializing fn bytecode?
17:56hiredmanwhy not just send the whole .clj file
17:56bradfordyes, the jar is on every machine with teh same code
17:56leafwrhickey: is there any know limitation in file size when load-file a very large .clj file?
17:57hiredmanbradford: what!?
17:57rhickeythen sending the var itself will unify with the var on the other side, since named vars are interned
17:57bradfordhiredman: this is hadoop
17:57rhickeynote, that is not the same thing as the symbol, the var itself
17:57hiredmanbradford: so why bother?
17:58hiredmanI don't see why you need to do all this lookup stuff, if you have the samecode on every machine
17:58chouserpresumably he wants to tell the other process which function to apply to a given task or data
17:58rhickeyjust send vars
17:59rhickeythat's what they are for, they do this already
17:59bradfordright, i am just sening around ns/sym for function lookup
17:59bradfordso i jsut send the var
17:59rhickeywhen read that var will be ready to call if it has the fn on the remote side, no lookup
18:00bradfordas in... (eval-remote #'foo)
18:00rhickeysimple reading #'rest will get you the var object
18:00rhickey,(read-string "#'rest")
18:00clojurebot(var rest)
18:01rhickey,((read-string "#'rest") [1 2 3])
18:01clojurebotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn
18:02hiredmanand clojurebot doesn't allow eval
18:02rhickeyack, yes, you will have to eval it
18:02bradfordand this works because of the way var-lookup / interning works?
18:03rhickeybut no lookup, since vars look themselves up when interning
18:03rhickeyright, every var with the same intern name is the same (identical) var
18:03leafwso, there are no known file-size limitations for load-file? How can a 6 Mb .clj file fail?
18:03bradfordright, that's waht i mean, the interning process is built to do this lookup, so i shold be using it to do lookup rather than doing it myself
18:03rhickeyi.e. (identical? (eval-remote #'foo) (eval-remote #'foo)) -> true
18:04rhickeyalso identical to foo loaded remotely
18:04rhickeyin same ns
18:04rhickeybradford: yes, let interning do it
18:05bradfordgreat, this should simplfy some hadoop code we have.
18:05rhickeyalso note that the var is callable
18:05chousercould use 'resolve' instead of 'eval' -- would that be a poor choice?
18:05rhickeyso vars are a good way to communicate about fn identity rather than value, presuming they are stored in fns
18:06hiredmanrhickey: maybe you could weigh in on leafw's read problem?
18:07rhickeyif it's a data file you'll hit the constant pool limit for class files, use read for data files, not load
18:08leafw( hiredman: I can wait. The current conversation is instructive)
18:09rhickeychouser: resolve is about symbols, not vars, but could resolve a fully-qualified symbol to get var, yes
18:09rhickeyleafw: that's for you above ^^ use read, not load, for data files
18:09hiredmanoh
18:10hiredmanoh!
18:10hiredmanI see read vs. load
18:10leafwrhickey, hiredman : thank you.
18:11leafwand you mean read and not load-reader?
18:15hiredmanload-reader and load both go through the compiler
18:15leafwload-reader also fails. Ok.
18:15leafw(just tested)
18:19leafwyay read survived, with a PushbackReader that had 4096 size.
18:26yuraswhat is the opposite fun of (keyword x)?
18:27somniumyuras: you're probably looking for 'name
18:27djorkhey are there better ways to configure jline?
18:27djorkI'm missing a good bit of the features I am used to
18:28djorklike Emacs-style editing (C-d delete, M-b or M-f jumping)
18:28leafwI am impressed by the way at how fast clojure can parse a 6 Mb map from a file. Its almost subsecond.
18:32hiredmanClojure: It's More Fn
18:32StartsWithKdjork: you can configure jline if you write your own clojure launcher with jline api, there was/is a project that does that on google code, but i can't remeber the name of it or thoes is still exist
18:33djorkJline docs are nonexistent as far as I can tell
18:33StartsWithKdoes*
18:33somniumhiredman: will that be the T-shirt slogan for clojure-conf '10 ?
18:33hiredmanchouser could put that on a shirt
18:34djorkhah nice
18:34hiredmanclojurebot: zazzle?
18:34clojurebotexcusez-moi
18:34hiredmanhttp://www.zazzle.com/clojure+tshirts
18:35somniumthat logo would look good on coveralls
18:36StartsWithKdjork: http://wrost.blogspot.com/2009/08/clojure-tab-completion-on-windows.html maybe this will help
18:36leafwcontinuing ... what is the best way to create a sorted map from an existing map? sorted-map requires elements unpacked from a list, so (sorted-map (interleave (keys m) (vals m))) cannot work. So how?
18:37djorkthat site is the only site on the entire internet that documents jline.words
18:37leafw(I am trying to avoid (TreeMap. m), which would work, but adds a java dependency)
18:37rhickey,(into (sorted-map) {:c 1 :b 2 :a 3})
18:37clojurebot{:a 3, :b 2, :c 1}
18:37leafwinto. The magic word of the day. Thanks.
18:38yurasinto made my day today. very magical thing and yet works nicely
18:38leafwinto seems to emulate the constructor that most java collections have, combined with the addAll
18:42kotarakbtw: does anyone else have problems with the group? My posts take sometimes over six hours to show up. :(
18:43leafwhaven't noticed anything like that kotarak, but I have not checked properly.
18:44rhickeykotarak: I moderate several times a day, and I think chouser does as well
18:44kotarakIt started sometime ago, when I was suddenly banned. :(( chouser fixed that. But since then I have trouble with terrible delays.
18:44leafwanother quirk: clojure.set/intersection can't work with a key set obtained from a map: clojure.lang.APersistentMap$KeySeq cannot be cast to clojure.lang.IPersistentSet
18:44StartsWithKi am using clojure 1.0.0, to do unit test i have to load 16 test namespaces and there dependencies, it takes 4 seconds to load them? is this normal? (there is no aot)
18:44rhickeywe've had a problem with spammers spoofing legit members. I had to moderate myself!
18:44kotarako.O
18:44hiredmanStartsWithK: 4 seconds from a cold jvm?
18:45StartsWithKhiredman: no, only to (require) test namespaces
18:45hiredmanhmmm
18:46hiredmanwell, you have to go to disk to load each file, and each file has to be read and compiled
18:46StartsWithKi know, but still, 4 sec to load something like 32 files
18:47hiredmanclojurebot has the largest set of namespaces of any of my projects, and it takes a few beats to load, but I've never checked to see where that time is spent, could just be waiting to make the irc connection
18:47leafwand a pseudo-quirk: I would expect the collection returned by vals on a sorted map to implement List interface, since it's ordered. But java.util.TreeMap doesn't either.
18:49leafwsame for the sorted keys.
18:50leafwand I am wrong: it does!
18:50leafw,(ancestors (class (vals (into (sorted-map) {:a 1 :b 2}))))
18:50clojurebot#{java.lang.Object clojure.lang.Seqable clojure.lang.IPersistentCollection java.util.Collection clojure.lang.ASeq clojure.lang.IMeta clojure.lang.Streamable clojure.lang.Sequential java.lang.Iterable clojure.lang.IObj :clojure.contrib.generic/any clojure.lang.Obj java.util.List clojure.lang.ISeq}
18:51StartsWithKthere is total of 34 namespaces and 16 namespaces with tests, non compiled
18:51jhawk28another favorable article from Tim Bray: http://www.tbray.org/ongoing/When/200x/2009/10/27/Recur
18:53StartsWithKfunny thing is, i (read) every file of my project, at least until i hit first ns declaration in it, and it takes 1ms to do that for all the files
18:53StartsWithKso i think its a compiler
18:57djork"But it seems obvious to me that recur is better than tail-call-optimized recursion." true dat
18:58djorkso don't take his word for it
18:58hiredmanI need to finish messing around with my reader so I can start messing around with the compiler
19:00StartsWithKa new reader? in clojure or java?
19:00hiredmanclojure
19:01hiredmanyeah
19:01StartsWithKthat would be nice, clj->html, lint, formating..
19:01hiredmanjust rewriting LispReader.java into clojure/reader.clj
19:02spuzI have a question about code style. In java I often declare local variables even if they are only referenced once so that I can break up the code and also make it more self documenting. In clojure which of the following styles is preferred?
19:02lisppaste8spuz pasted "Local variables in clojure" at http://paste.lisp.org/display/89396
19:02hiredmanhttp://github.com/hiredman/clojure/blob/readerII/src/clj/clojure/reader.clj a few missing pieces and needs to be cleaned up and better build integration
19:04hiredmando you really want to self-document google's auth api?
19:04spuzhiredman: ?
19:05hiredmanyou are basically documenting google's auth-token api
19:05hiredmanfrom the client side
19:06hiredmanwhich, I mean, who cares? if you have some hairy function it's nice to break it up into chunks, but if it is just hitting some other standard api, *shrug*
19:07spuzI wouldn't say it's a standard API, it's not as if you can hover over it and see what it expects as arguments...
19:07hiredmanspuz: I can just google it
19:07spuzheh
19:07hiredmanI would document what is userdetails is supposed to be
19:08spuzit's not just the auth api, it's all of the parameters which have to be pieced together into the request string
19:08hiredmanwhich is just a detail of the api
19:08spuzyep ok
19:08jhawk28hiredman: line 189 - misspelling ;)
19:09hiredmanjhawk28: huh?
19:09hiredmanin eval-reader?
19:09jhawk28allowed instead of allow
19:09hiredmanah
19:09hiredman*shrug*
19:09jhawk28hehe
19:09hiredmanI guess that is important
19:10StartsWithKhiredman: will the final reader also be regex based?
19:10hiredmaneh?
19:11hiredmanI'd hardly call it regex based
19:11spuzhiredman: so would you say it's fair to say that in clojure or any lisp, the way to document your code is to break it up into smaller functions, rather than into local variables?
19:11hiredmanit uses 4 regexs in 4 or 5 functions
19:12StartsWithKhiredman: yes, your right, i just looke at the top of the file
19:12hiredmanspuz: no
19:12jhawk28any idea when a function will allow more than 20 parameters?
19:13hiredmanI would just say who cares about the details of google auth? if you are doing something interesting or tricky, break it up and document it by all means
19:13spuzhiredman: that sounds like a yes :p
19:16StartsWithKhiredman: this style you use with <string> sufix and such, is that something special in clojure 1.1 or new naming convention?
19:16hiredmanif you are passing a map, I recommend map destructering
19:17Chousukejhawk28: max parameter count will actually go *down*, not up :P
19:17Chousukejhawk28: if you need more, use a rest parameter
19:18hiredmanStartsWithK: nameing convention
19:18hiredmanLispReader has two static methods with the same name that vary on the type of the first param
19:19StartsWithKi have some macros that have more than one variant, so foo expands or to foo-1 or foo-2, is foo<1> prefered in general?
19:19StartsWithKits hard to find any style guides on clojure code :)
19:20hiredmanI dunno
19:20hiredman<foo> might not technically be a valid symbol
19:20Chousukeit is.
19:21ChousukeStartsWithK: I'd find more descriptive names than -1 and -2 :P
19:21hiredmanare you sure? clojure.org/reader says alphanumeric plus a handful of symbols
19:22hiredmanwhich don't include < or >
19:22Chousukeexcept < and > exist as functions :)
19:22hiredmanso does /
19:22Chousukeyeah, but that receives special treatment anyway
19:23hiredmanStartsWithK: aslong as you are consistent, I just like <1> visually
19:23StartsWithKChousuke: its hard when they are only used to parse two different syntax variants of the same macro, so foo -> (or foo-1 foo-2) -> foo* is the best i can think of in such a case
19:24hiredmanI'm not sure I even need those particular macros
19:24hiredmanbut I am sticking with a direct translation of LispReader
19:24StartsWithKi don't think it gets more descriptive with that, i tried something like foo-with-only-properties-defined foo-with-properties-and-dependencies, but that is just too long
19:24Chousukeso wait, you're actually working on your reader now ?:P
19:25hiredmanyeah
19:25hiredmanI stopped working on my old gen-class reader
19:25ChousukeI still have to find that bug with my reader :P
19:25StartsWithKhow will clojure use reader in clojure?
19:25hiredmanI've been grinding on thew new fractal letfn reader for the past week
19:26somniumyou guys should agree on some tests and benchmarks so you can compete :P
19:26ChousukeStartsWithK: it's not easy but it's possible.
19:26StartsWithKold one will need to be there to bootstrap it?
19:26Chousukeonly once )
19:26StartsWithKor will clojure keep its a jar of older version for that?
19:27hiredmanI have ant compile java+clj, compile my reader, then delete compiled clojure (keep the compiled java), then recompile clojure using my compiled reader
19:28hiredmanmy clojure prints "falling back to java reader" to System.err at startup if it can't load the cinc reader
19:28ChousukeI don't think I'll have time to work on mine for a while
19:29hiredman:(
19:29Chousukeand that bug I'm seeing... I have *no* clue.
19:29hiredmanmy syntax reader doesn't work either
19:29Chousukethe stacktrace mentions macroexpand and definline and whatnot but nothing there looks wrong.
19:30Chousukeso I bet its some error that just build up until it finally triggers there.
19:30Chousukebuilds*
19:30hiredmanyeah
19:30ChousukeI think it might be because I'm using a syntax-quote macro instead of just expanding it at read time.
19:31Chousukebut that would suck.
19:31hiredmanit turns out I had a bunch of bugs, and because of my incremental fall back to LispReader they weren't exposed until I replaced read-delimited-list
19:31Chousuke;(
19:31hiredmanwhich exposed two or three bugs in other readers, which drove me crazy
19:31Chousuke:)
19:32ChousukeI think I might be encountering additional problems due to the pushbackreader (ew state :()
19:32hiredmanbecause for a while I thought I was just missing something in read-delimited-list
19:32ChousukeI originally wrote the reader to work on a seq of characters
19:32hiredmanhmmmm
19:32Chousukethen adapted it a bit to use a pushbackreader
19:32hiredmanwouldn't it be easy to just turn a pbr into a seq of chars?
19:33Chousukeyeah, but turns out you need some "read-ahead"
19:33Chousukeat least one character
19:33Chousukefor example, if the input is "foo\n" then to read the symbol foo you need to consume the \n too
19:33Chousukebut that confuses the repl )
19:33Chousukeso you need to put the \n back
19:35hiredmanyou just cons the character back on :P
19:35Chousukehiredman: except that won't work.
19:35Chousukehiredman: as it's gone from the *stream*, which the repl uses
19:35hiredman:(
19:36Chousukealso for some reason attaching line metadata to objects causes the init method code to grow to ~90k which is over the 64k limit
19:36hiredmanhmmm
19:37Chousukeif I change the metadata attaching function to identity, it works :P
19:37Chousukebut I get no line metadata.
19:38Chousukebut not having line metadata makes it so much harder to debug ;(
19:38RaynesI think I just found the thing that will make me stop using VimClojure. :\
19:39RaynesThe weirdness of namespaces.
19:40StartsWithKRaynes: what weirdness?
19:40RaynesYou can't just open any file apparently, it tosses an error because of namespace crap. I have to open the file (it has to be on the servers classpath) and then \rf the file, and then close and then reopen the file. Apparently.
19:40somniumhuh, just tried to build 1.0 branch of contrib with clojure 1.0 and it blew up
19:42RaynesAt least, according to this: http://www.mail-archive.com/clojure@googlegroups.com/msg10657.html, it's the expected behavior. It's annoying behavior to me. :\
19:44RaynesIt's a bit of a dream killer.
19:45technomancyif you ever feel bummed out by the fact that clojure is a relatively new/immature language, I recommend http://planet.lisp.org to set you right again.
19:45technomancyparticularly things like http://trittweiler.blogspot.com/2009/10/0affff.html
19:46RaynesAre you talking to me? >_>
19:46technomancysort of
19:48RaynesNothing to do with Clojure. I have no earthly idea why VimClojure works like that. I was just trying it out anyways. I just doubt I'll continue using it if this is supposed to be a "feature".
19:52tomojcome to the dark side
19:59Raynestomoj: If you were implying that I should use Emacs, I already do. I've just been playing with Vim for a few days to see what all the fuss was about. But after discovering this retarded little 'feature', I'm not sure what the fuss /is/ about.
20:00tomojthere's fuss about vimclojure?
20:01somniumI like vim, but I never managed to get vim clojure to work after two tries
20:01somniumis the clojure-1.0 jar on google code broken?
20:01leafwsomnium: it's no big deal really.
20:01tmountainanybody know if there's a library floating around to do https requests?
20:03StartsWithKtmountain: apache commons httpclient can
20:03tomojI imagine java can help cook one up pretty easily
20:03tomojah, :)
20:05jhawk28tmountain: the Jetty client can too, but it doesnt support https through a proxy
20:06tmountainI'm trying with technomancy's client now, and pointing it at https://www.google.com/ gives me a 302 moved response
20:06tmountainI wonder if that's verification that it works...
20:07technomancyword of warning: that is not a particularly well-tested library.
20:07technomancyI'm only now starting to use it in real code as of like a week ago.
20:07tmountainno worries, I'm using it for a pet project
20:07tmountaintrying to hack together a google wave bot in clojure
20:07technomancyperfect; that's exactly what it was designed for
20:08technomancy(pet project, not wave)
20:08tmountainyeah, it seems to work fine at the level I'm using it, so I don't forsee any problems
20:09tmountainrewriting old Java code in Clojure really makes you realize how much unnecessary ceremony Java has
20:10tmountainlike... I can just rip out these 15 lines and replace them with this one-liner
20:10tmountainit's crazy
20:11technomancyif that's surprising you either haven't been doing java very long or you've been doing it waaaaay too long. =)
20:13somniumtmountain: I just had the opposite experience, I needed to write a little java proxy class and was amazed at how excruciatingly painful it was after getting used to clojure
20:17jhawk28tmountain: you probably need to import the cert into the store
20:20tmountainI think you guys misunderstood me
20:20tmountainI'm saying Java code is too freakin' long
20:20tmountainheh
20:21funkenblattmisunderstanding implies that they actually read what you wrote
20:21yuras:)
20:21funkenblattwhich i think may be assuming too much
20:21yurasi found even python code too long after clojure idioms
20:22tmountainagreed
20:29yurascan somebody help me to make this func more clojurish http://gist.github.com/220108 ? or is it already okay?
20:39somniumyuras: you could use reduce instead of loop
21:42bmidgley2are there any working applet demos out there?
21:43chouseryeah, there was a thread on the group recently
21:46bmidgley2chouser: the google group? I couldn't find it
21:47chouserok, I'll look.
21:49chouserhttp://en.wikibooks.org/wiki/Clojure_Programming/Examples/Creating_an_Applet
21:52tomojcomes up for me when googling "clojure applet"..
21:52tomojmaybe my google knows I want to see that
21:53tomojone might wrap some reads in a dosync to ensure a consistent snapshot, even though there's no writes, right?
21:56rlbIs there already something that lets you get a sub-command's stdout as a java stream? i.e. (line-seq (:stdout (sub-process ["find" "-type" "f" ...])))
21:57chousertomoj: yes
21:58tomojthere's the thing in java
21:58bmidgley2ok, I guess I need a newer java6... none of the examples I found would run
21:58tomojif it's wrapped in clojure I haven't seen it
21:58chouserrlb: I don't think so. there's shell-out in contrib, but it reads the whole output before returning to help uncomplicate resource management
21:59rlbright -- I need a stream
22:00rlbperhaps I'll look in to it...
22:00chouseryou can consult the source there to see how to go about it
22:01chouserI've considered tweaking it to allow for an api like (with-process-stream [] ...)
22:01bmidgley2hmm... http://www.xenoage.com/extern/zongblog/eartraining/ gives me "Loading Java Applet Failed..."
22:01bmidgley2in firefox on osx 10.5.8
22:01chouserrlb: that would close and clean up when you leave that dynamic scope. Would that fit your use case
22:01bmidgley2java 1.6.0_15
22:02chouserbmidgley2: yeah, macs give clojure applets trouble.
22:02bmidgley2too bad
22:02chouserbmidgley2: there's some discussion here: http://tinyurl.com/yfbbfjs
22:02bmidgley2our usergroup is in a clojure discussion now
22:03rlbchouser: might.
22:03tomoj,(line-seq (java.io.BufferedReader. (java.io.InputStreamReader. (.getInputStream (.exec (Runtime/getRuntime) "echo hello")))))
22:03clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
22:03tomojdarn
22:03chousertomoj: but note that leaves the streams open and the process running or in a zombie state
22:04rlbchouser: though perhaps I'll handle this particular problem differently -- might skip the sub-process and have clojure handle everything. Though I think I'll still want a way to get a lazy sub-process stream eventually.
22:04tomojchouser: noted
22:04tomojhmm
22:04tomojI don't see any "echo" is ps -A
22:05rlb(Someone will need to wait() on the sub-process unless that's handled elsewhere.)
22:06chouserhm
22:06chouserthat was my understanding as well, but the process does seem to be gone
22:07rlbPerhaps java handles that indirectly.
22:11bmidgley2aha!
22:11bmidgley2I have 1.6.x at the command line but only 1.5.x in the browser
22:13slashus2bmidgley2: Look at your java preferences in your utility folder.
22:15bmidgley2it has a 64-bit java se6 first in the list for the applet plugin
22:15bmidgley2does the browser choke on 64 bit plugins
22:16slashus2try the 32 bit java 6
22:17bmidgley2I don't have that in my list
22:17bmidgley2downloading the latest java for osx... we'll see
22:21chouserI think I may have been misreading the java docs
22:22chouserI think the Process instance may wait for the process and handle the clean up for you.
22:24chouserIf that's the case, then the streams are as safe to use as any other stream and shell-out could be a lot less picky.
22:28tomojso is my line above bad or not?
22:30chouserit's bad.
22:30woobyhas anyone investigated using simple build tool to compile/package clj stuff?
22:32somniumwooby: ant works for me
22:32somniumwooby: and netbeans will generate a build.xml for you if you create a clojure project, though I haven't done it more than twice
22:33hiredmanant has some annoying issues
22:33hiredmanI really wish ant would not rebuild a dependency unless something was changed
22:34woobyyeah i'm not so much into ant
22:34woobyi really got used to sbt, and the dep handling especially
22:34woobythe transparent ivy goings-on
22:34hiredman<3 make
22:34woobymake pretty much rules
22:35chousertomoj: this is apparently good enough though: (with-open [s (java.io.BufferedReader. (java.io.InputStreamReader. (.getInputStream (.exec (Runtime/getRuntime) "echo foo"))))] (vec (line-seq s)))
22:35hiredmanI see a lot of work going into maven+clojure
22:35hiredmanbut I haven't tried that out
22:35somniumI wonder how jruby-rake would do
22:38tomojchouser: I see, thanks
22:40hiredmanxml xml xml everywhere
22:40hiredman~xml
22:40clojurebotXmL is case-sensitive
22:41hiredman~xml
22:41clojurebotxml is like violence; if it's not working, you're not using enough of it.
22:41wavis_zomg hiredman, that made my evening
22:42rlbDoes clojure specify anything about the evaluation order of args?
22:42chouseryep, they go in order
22:42rlbi.e. do you need a let when order is important?
22:42hiredmanl-to-r
22:43rlbhiredman: guaranteed?
22:43arohnerrlb: yes
22:43hiredmanreally? I know that is how it works, but is that specified somewhere?
22:43arohnerall lisps I know of do left-to-right
22:43arohnerscheme specifies it
22:44hiredman*snort*
22:44arohnerCL probably does too
22:44rlbarohner: I don't think it does.
22:44chouseryeah, I'm pretty sure it's guaranteed. eval order of literal maps is not guaranteed
22:44rlbFrom r5rs: "The operator and operand expressions are evaluated (in an unspecified order)"
22:45hiredmanI know I read somewhere that some lisp goes the opposite order, but that was some old paper
22:45rlbIn the case I care about, it's critical i.e. (vector (read-from-stream) (read-from-stream) (read-from-stream)), etc.
22:45hiredmanthere have doubtedly been lazy evaluation lisps
22:46rlbPerhaps I'll just use a let for now and worry about that later...
22:46hiredmanrlb: I tihnk it would be clearer to put it in a let regardless
22:47arohnerhttp://www.lispworks.com/documentation/HyperSpec/Issues/iss279_w.htm
22:47tomoj"The subforms in the cdr of the original form are evaluated in left-to-right order in the current lexical and dynamic environments."
22:47tomojCL
22:49hiredmanclojurebot: what does the hyperspec say about evaluation order?
22:49clojurebotwhat is wrong with you
22:49hiredman~botsnack
22:49clojurebotthanks; that was delicious. (nom nom nom)
22:50arohnerhttp://lib.store.yahoo.net/lib/paulgraham/acl2.txt
22:50hiredmanclojurebot: hyperspec?
22:50clojurebothyperspec is not applicable
23:05rlbIs it possible to do a precise read from java - the equivalent of read(fd, buffer, 32)?
23:05tomojhas anyone seen NullPointerExceptions on trying to print something?
23:06rlbThis has to be binary, and a single read, not a sequence of character reads.
23:06rlb(I'm trying to read data from a device on /dev/input/event*.)
23:06tomojI mean like this: (class foo) => c.l.PersistentStructMap, (str foo) => NullPointerException
23:06rlbIt's trivial in C, but I'm not sure how to get clojure to do it.
23:08tomojoh it's because one of the values in the map is a lazy seq
23:08tomojthe backtrace is unfortunately not at all helpful
23:36rlbNevermind -- got it, (.read stream byte-array-size-n) seems to work.
23:46Licensersomnium: aloa
23:49wwmorganhow can I test whether an object I have is an array?
23:53scottjwwmorgan: there are vector? and type
23:53scottjwwmorgan: and seq?
23:55wwmorgantype is what I'm looking for. Thanks
23:58hiredmanok