#clojure logs

2010-05-01

00:00cemerickninjudd: yeah, don't let me bring you down. I just managed to eliminate a pile of java with some deftype usage, so I've got a shiny new hammer to drive nails with. :-)
00:00uberjarif clojure could use protobufs without having to write java to the filesystem.. that would indeed be pretty slick
00:01uberjaras far as bragging rights go @ least
00:01cemerickI have a sneaking suspicion that that's what chouser's got bubbling away at work.
00:01ninjudduberjar: you mean compile the protobufs on the fly?
00:01uberjaryeah.. like if I wanted to compile them from the repl to do some experimentation
00:03ninjuddhmm
00:03ninjuddwell, i can say that wrapping the google java code let me write a working protobuf implementation in a weekend
00:04ninjuddit would have taken much longer writing it from scratch, but i'm open to an all clojure implementation
00:05uberjarit would certainly give clojure the coolest protobuf library of any dynamic language.
00:05ninjuddthough at the time, deftype didn't exist, and there would have been no way to make it fast
00:05ninjuddand i wrote it becuase i needed fast
00:06hiredman,(doc add)
00:06clojurebot"clojure.contrib.accumulators/add;[[acc item]]; Add item to the accumulator acc. The exact meaning of adding an an item depends on the type of the accumulator."
00:06hiredman:D
00:07hiredmanreplaca: sweet!
00:07hiredman~def add
00:09ninjuddcemerick: did you say chouser is working on an implementation of protobufs?
00:09cemerickhe's hinted at it, I think
00:09cemerickfor work though, so it's apparently not trivial to get open-sourced, etc
00:10ninjuddoh
00:10ninjuddi did my implementation for work too, though my company is awesome when it comes to open source
00:11cemerickI don't know any of the details, so the same may happen there
00:12ninjudddo you think a deftype version could be as fast as the pure java version?
00:12ninjuddor even better, faster
00:13cemerickhrm
00:13cemerickparity is probably the realistic goal
00:14cemerickI presume google's impl is pretty thight
00:14cemericktight*
00:15ninjuddwell, i do use DynamicMessage rather than their specific generated message classes
00:15ninjuddso there may be some room for improvement
00:16ninjuddi assume the reflection has some cost
00:16cemerickreflection is a killer for IO, yeah
00:17ninjuddwell, i'm not sure how much "Java Reflection" they use
00:17cemerickprobably none, but if you're using some....
00:18ninjuddi use instanceof
00:18ninjuddand i cache all costly actions like looking up fields by name
00:19ninjuddit is still really fast
00:19ninjuddthough this is pretty core to what we are doing, so any speed boosts we can get would be worth me spending more time on it
00:20cemerickI'd think the development process improvement would be a big enough win, even if the actual perf didn't change.
00:21ninjuddwell we aren't actively adding features to that code
00:22ninjuddit already supports all non-deprecated protobuf types
00:22ninjuddand we added extensions for sets and maps
00:23ninjuddi wouldn't ming doing it to learn about deftype though
00:23ninjudd*mind
00:24ninjuddmaybe i'll chat with chouser about it
00:25cemerickyeah, that's a good plan
00:25cemerickhe's always pretty excited about protobufs anyway :-)
00:27ninjuddyeah, protobufs are seriously awesome
00:29cemerickso they're generally useful for serialization?
00:29cemericki.e. not just for network comm?
00:29ninjuddyeah, that's all we are using them for
00:29ninjuddwe use json for network comm
00:30ninjuddwe use them as the data serialization format for our graph db
00:30cemerickI wrote my own serialization mechanism for clojure objects a while back that worked out to be pretty darn fast. It'd be nice to not have to maintain that.
00:31ninjuddopen source?
00:31cemerickshould be, never got around to it
00:32ninjuddhave you looked at clj-serializer?
00:32cemerickit's part of an in-process database I wrote...a thick layer on top of jdbm
00:33ninjuddnice
00:33ninjuddthat's what we're using protobufs for
00:33cemerickyup, very similar to that, though no java component
00:34cemerickhrm, and we do support more object types
00:34ninjuddthan protobuf?
00:35cemerickthan clj-serializer
00:35ninjuddah
00:35cemerick...and we support using Java Serialization for arbitrary java objects, and arbitrarily-deep nesting of composite objects
00:35cemerickso, same concept, we went a little farther
00:36cemerickthere's nothing special about it though, of course
00:36ninjuddyou should open source it
00:36cemerickYeah, it's on the list
00:36cemerickI've got about 6 projects that I keep meaning to get on github.
00:37ninjuddpart of the reason i like protobufs so much is that they do a really good job of keeping the serialization size small
00:37cemerickwe'd probably have a helluva time packing arbitrary java objects in them, though?
00:38ninjuddwell
00:38ninjuddyou could store them as binary
00:39ninjuddi should support that automatically actually
00:39cemerickright, but could we configure the protobuf library to transparently serialize them, or would we have to walk our object graphs, serialize to byte[], and then pass to protobufs?
00:39ninjuddif you have a protobuf field of type bytes, i could use java serialization to dump the object
00:41ninjuddif there is an easy way to dump an object and all objects it contains, then i could do it automatically
00:41ninjuddnot sure if java-serialization does that
00:42cemerickyeah, it serializes full object graphs
00:42ninjuddso clojure protobuf could automatically serialize a java object if you assign it to a field of type bytes
00:42ninjuddwouldn't be too hard
00:43cemerickwe'll have to see how motivated I get in that direction :-)
00:43cemerickI wouldn't look forward to converting the existing databases. :-P
00:43ninjuddyeah
00:44ninjuddmay be a good exercise though
00:46ninjuddbut it would only be useful if you use those java objects inside of clojure objects really
00:50MadWombatHello
00:56sids,(:arglists ^str)
00:56clojurebotnil
00:56sids,(:arglists ^(var str))
00:56clojurebot([] [x] [x & ys])
00:56sidsI really don't understand the difference between the above two
00:59ninjuddfrom what i understand, one is the metadata on the fn referenced by str, the other is the metadata on the var str itself (the reader metadata)
01:00cemerickyup, that's right
01:00cemerickthere's some sugar for the latter
01:00cemerick,#'str
01:00clojurebot#'clojure.core/str
01:00cemerickand
01:01cemerick,(meta #'var)
01:01clojurebotjava.lang.Exception: Unable to resolve var: var in this context
01:01cemerick,(meta #'str)
01:01clojurebot{:ns #<Namespace clojure.core>, :name str, :file "clojure/core.clj", :line 356, :arglists ([] [x] [x & ys]), :tag java.lang.String, :doc "With no args, returns the empty string. With one arg x, returns\n x.toString(). (str nil) returns the empty string. With more than\n one arg, returns the concatenation of the str values of the args."}
01:07sidsninjudd, cemerick: thanks, I think I understand
01:08sidsso defn associates the metadata with the var, not the function? but why so?
01:10nathanmarzsids: http://www.assembla.com/spaces/clojure/tickets/94-GC--Issue-90---%09-Support-metadata-on-fns
01:10sexpbot"#94 - GC Issue 90: Support metadata on fns (Fixed) | Clojure | Assembla"
01:12replacahiredman: great, glad to see it's working again
01:12replaca,(doc pprint)
01:12clojurebot"clojure.contrib.pprint/pprint;[[object] [object writer]]; Pretty print object to the optional output writer. If the writer is not provided, print the object to the currently bound value of *out*."
01:13sidsnathanmarz: oh, nice. thanks
01:15MadWombatis there any way to disconnect from slime/clojure-swank without losing an ability to reconnect?
01:19sidsMadWombat: when at the repl, type , (comma) followed by 'quit'
01:20MadWombatsids: lemme try
01:21MadWombatsids: I get "open-network-stream: make client process failed: connection refused, :name, SLIME Lisp, :buffer, nil, :host, 127.0.0.1, :service, 4005"
01:21MadWombatsids: when I try to reconnect
01:22MadWombatsids: I am using lein swank plugin to start swank
01:22sidsMadWombat: this will quit swank itself
01:23sidsMadWombat: you'll have to restart swank again (using lein swank)
01:23MadWombatsids: yes, my question was, how do I reconnect to swank without restarting it
01:24sidsMadWombat: if you don't want to have to do that, use M-X slime-disconnect instead
01:25MadWombatI get the same error on slime-disconnect
01:28sidsMadWombat: may I ask, what is the purpose of disconnecting?
01:32MadWombatsids: changing code on a remote system, restarting emacs or logging out
01:44sidsMadWombat: I can't figure it out; if you do please let me know!
01:45MadWombatsids: sure
02:59gerryxiaohello
02:59gerryxiaowhere is add-watcher?
03:00hamzaAFAIK its removed.
03:01gerryxiaomy old code use it, how to change to add-watch?
03:02gerryxiaowhat does the key arg of addwatch do?
03:03hoeckgerryxiao: just for referencing the watch
03:03hoeckthrough remove-watch
03:04gerryxiaomy old code: (add-watcher a :send-off b f) how to change to add-watch?
03:05hoeckto use watches should be sth like : (add-watch <ref> :key (fn [k the-ref old new] (send-off <your-watcher-agent> <your-action-fn> old new)))
03:12gerryxiaoi'm abit confused about change add-watcher to add-watch
03:14cemerick~max
03:14clojurebotmax people is 283
03:15cemerickgerryxiao: add-watch is more general-purpose than add-watcher was. You can generally just ignore the key value in the fn you pass to add-watch, although there are ways you can use it to simplify certain patterns.
03:19gerryxiaook,thx
03:34gerryxiao(add-watch a :key (fn [k r old new] (send-off b action-fn new)))
03:37gerryxiaoit seems working
03:47gerryxiaowhat's the difference between send and send-off?
03:48hoeckgerryxiao: send-off spawns a new thread
03:49hoeckso that it doesn't block existing threads in the agents thread pool
03:49gerryxiaohoeck: which is suit for sync?
03:49hoeckits used of you do blocking stuff in your agent
03:49hoecklike (send-off *state* read-from-socket)
03:50hoeckand read-from-socket may wait until there is something readable in the socket
03:50gerryxiaohoeck: ok
03:50hoecksend is for non-blocking stuff, like (send *state* update-in [:counter] inc)
03:51gerryxiaohoeck: so send is suit for sync
03:51hoeckwhat do you mean by "sync" ?
03:52gerryxiaoi mean "at the same time" both agent action and main action
03:52_atogerryxiao: send is also in a seperate thread, but it doesn't spawn a new thread for each call, instead it uses a thread pool
03:53_ato,(doc send)
03:53clojurebot"([a f & args]); Dispatch an action to an agent. Returns the agent immediately. Subsequently, in a thread from a thread pool, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)"
03:55gerryxiaoi have a agent watching chesses on board , when chess is dead, agent will remove the chess from board, which one is better?
03:56_atosend
03:56gerryxiaook,thx
03:57_atouse send-off for actions that block (like reading from a socket, or waiting for user input)
04:16gerryxiaowhen will 1.2 be out
04:17Licensergood morning
04:19somniumsalut
04:22gerryxiaoafternoon
04:48Licensergerryxiao: nobody knows
05:08gerryxiaowhy?
05:08clojurebotwhy not?
05:08gerryxiao,*clojure-version*
05:08clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
05:12bsteuberwhy do people always use *clojure-version* although the corresponding function is much more readable?
05:12bsteuber,(clojure-version)
05:12clojurebot"1.1.0-master-SNAPSHOT"
05:30gerryxiao,(doc seq-contains?)
05:30clojurebotTitim gan éirí ort.
05:32gerryxiaois defrecord faster than defstruct when using :field as accessor?
05:32gerryxiaoand defrecord support all defstruct ops ?
05:32hamza~def sorted-set
05:33carkhgerryxiao: as far as i know yes and yes
05:33carkhtho it will only be faster for "declared" fields
05:35gerryxiaook,great
05:38Chousukedefstruct is pretty much obsoleted by defrecord
05:46hamzawhat does sorted-map uses to sort if i give vector of numbers as keys?
05:49Chousukeno idea. you probably want sorted-map-by
05:52hamzano I meant which pred is used to keep it sorted I am not trying to resort the map, cause (> [1 2] [3 4]) kind of thing does not work for vectors.
05:53Chousukeit probably compares the hashcodes
05:53Chousukeso essentially, it's a random order
05:55Chousukethough I suppose you need to check the code to be sure.
05:55hamzakk thanks will check..
05:55hamza,(sorted-map [3 4] :b [1 2] :a)
05:55clojurebot{[1 2] :a, [3 4] :b}
05:55hamzathis is the behaviour i am after, but i can't decide if I should count on it or not
05:59_ato,(compare [1 2] [2 3])
05:59clojurebot-1
05:59_ato,(compare [5 2] [2 3])
05:59clojurebot1
06:00_atovector comparison is well defined
06:01_atohttp://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/APersistentVector.java#L392
06:02_ato< <= >= and friends are only defined on numbers
06:02_atouse 'compare for other objects
06:02hamza_ato: ok great, so i can safely count on it for vectors of the same size.
06:02_atoyep
06:02hamzathanks.
06:03mmarczykwould it be (easily) possible in Clojure to create a sequence type which, when asked for "rest", wouldn't calculate "first"?
06:04mmarczyksomething which would make it possible to do (take-nth 4 (map (partial print " ")) input-seq) and have only the elements picked by take-nth printed out
06:10_atommarczyk: yeah, with proxy or reify on clojure.lang.ISeq
06:12mmarczyk_ato: right, I'm trying to write a deftype for this, but apparently I'm doing something completely wrong :-(
06:13mmarczykgetting AbstractMethodErrors
06:13mmarczykooooh, I haven't implemented Seqable
06:14mmarczyk...oh bother, now I have and still no go
06:15Chousukemmarczyk: you can only make such a sequence if the rests in no way depend on what was before them.
06:15mmarczykthey don't
06:15mmarczykhttp://gist.github.com/386218
06:17Chousukeyou probably need to implement cons too. but I'm not sure about that :P
06:19mmarczykChousuke: not really, cons just calls clojure.lang.RT/cons, which only cares about ISeq / Seqable
06:20mmarczykhuh!???
06:20mmarczykwait
06:20mmarczykit works now
06:20mmarczykoh come on
06:20mmarczykwhat a macro failure
06:21mmarczykcorrected now :-)
06:24mmarczykand now map doesn't work :-(
08:41hoeckgerryxiao: setting *dynamic-vars* works only on the repl, cause the repl runs in a context where *warn-on-reflection* is bound, like (binding [*warn-on-reflection* false] (clojure-repl))
08:41hoeckgerryxiao: try using (alter-var-root #'warn-on-reflection (constantly true))
08:41hoeckbut you don't have to set it during compilation or in compiled production code
08:42hoeckits really only used to find reflection usages while developing an application
08:42Licensergood day my friends
08:43hoeckhi Licenser!
08:43gerryxiaohoeck,thx, and lein clojure 1.2.0-snapshot don't know flatten func
08:45hoeckisn't flatten in clojure.contrib.seq? maybe it has been moved to clojure.core
08:45Licensergerryxiao: I thinik it is in the c.c.seq namespace
08:45Licenseryea it's in clojure core
08:45Licenserhoeck is right again :P
08:46gerryxiaoException in thread "main" java.lang.Exception: Unable to resolve symbol: flatten in this context
08:46Licensergerryxiao: are you running lein repl?
08:47gerryxiaoLicenser: no, repl compile
08:47gerryxiaos/repl/lein
08:47Licenserah I see
08:47Licenserhm hmm I kind of don't trust lein with the 1.2 branch, at least in the repl it still lods the olds stuff
08:48Licenserbut I think it's different with the compile
08:48gerryxiaoin my namespace, i have :use c.c.seq
08:48Licensergeramuk: in 1.2 you should not need
08:49gerryxiaohow to make lein use clojure.jar and contrib.jar located in my box?
08:50Licenserfor compiling I'm not sure but in theory copy them in your lib directory
08:53gerryxiaobut the jar in lib have timestamp in the file name
08:55gerryxiao clojure-1.2.0-master-20100501.080553-61.jar clojure-contrib-1.2.0-20100501.080834-94.jar
08:56gerryxiaowhynot know flattern?
08:56RaynesIt's supposed to.
08:56RaynesBecause they are snapshots.
08:56RaynesAnd flatten is in core now.
08:57gerryxiaoRaynes: so it should be in clojure-1.2.0-master.xxx.jar
08:58Raynesflatten? Yes, if you have the latest snapshot, and if you did lein deps recently, you should, flatten will be there.
08:58gerryxiaoRaynes: i just do lein deps now
09:01gerryxiaohow to update lein itself?
09:01Licenserlein upgrade
09:01gerryxiaook
09:03gerryxiaolein upgrade
09:03gerryxiaoException in thread "main" java.io.FileNotFoundException: Could not locate leiningen/upgrade__init.class or leiningen/upgrade.clj on classpath:
09:05patrkrisgerryxiao: download the new lein script from github.com/technomancy/
09:06gerryxiaook,thx
09:07patrkrisgerryxiao: (and run lein self-install afterwards)
09:10Licenserhmm were did re-split go to?
09:15gerryxiaoafter update lein, still not work for flatten
09:19gerryxiaoException in thread "main" org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted.
09:19gerryxiaowhat's it?
09:19Licenserwow gerryxiao you have some seriouse oddities there
09:19Licensercan you explain your setup?
09:20gerryxiaoproject.clj?
09:20Licensertype lein version
09:20Licenserstart with that
09:21gerryxiaoLeiningen 1.1.0 on Java 1.6.0_20 Java HotSpot(TM) 64-Bit Server VM
09:21Chousukeyou're not starting java with a security policy defined, are you?
09:21gerryxiaoyes
09:22gerryxiaoChousuke: i just do lein clean, and got that error msg
09:22Chousukehmmh :/
09:23gerryxiaobefore do lein clean, i got not find flatten symbol error msg :)
09:23Licenseroh you had multiple clojure jars in your lib then
09:23Licenserlein does not remove old jars when you do lein deps, a evil thing kind of but adly that is how it works
09:24Rayneslein clean && lein deps should work. :<
09:24Licenserand when did you got that exception?
09:24gerryxiaolein compile
09:25Licenserdo you happen to have an exit or something like that in your code?
09:26LicenserI hate compiler errors, they so much don#t tell you what goes on ...
09:28gerryxiaono
09:29Licenserhmm hmmm
09:29Licenservery odd
09:29gerryxiaoLicenser: i have one line call (-main)
09:29Licenseryou don't need that call
09:30Licenseryou need to define -main but don't call it
09:30gerryxiaoafter comment it, it seems working, weird
09:30Licenserthe line was the problem
09:30gerryxiaobut works on repl
09:30Licenserwhen compiling all top level code gets executed
09:31Licenserso when you have (-main) in there it tries to start the program while compiling
09:31Licenserthink you'd do that in C or something, of cause that gives you odd errors )
09:31Licenserwhen you start it with the jvm it will call main for you
09:31gerryxiaooic,thx
11:05Licenserhmm is there a easy way to find the index of a certain element in a seq?
11:06Chousukecontrib has an "indexed" function. that's probably the easiest
11:07hamzapositions in c.c.seq-utils
11:07Licenser*nods* thanks :)
11:15Licenserhmm can I monitor changes to a ref?
11:18Chousukeadd-watch
11:18Licenserah thank you!
11:28Licenseranother silly question how do I remove soething from a set
11:28LicenserI know remove works but it makes a seq from the set
11:28rhudsondisj
11:29Licenserway too easy, thank you rhudson
12:35rshif I wanted to include a custom java file with some static methods to import into a clojure file, how can I do this using leiningen? compiling it and adding it to /classes doesn't seem to work nor does adding it to a jar and putting it in /lib
12:37stilkov rsh: you could put the source into src/main/java, do a lein pom and then let maven handle it
12:38stilkovalternatively, you could build your Java stuff using a separate mvn project and then require it as a depencency from your project.clj
12:47rshin the first case, what do you mean exactly by let maven handle it? sorry, never used maven before
12:47Raynescompanion_cube: Were you asking about the sexpbot/clojurebot source code a while back?
12:53maravillasrsh: there's a lein-javac plugin you can use to do that
12:53maravillashttp://github.com/antoniogarrote/lein-javac
13:11Licenserhmm curiose fact: get does not work on lists
13:13rhudsonLicenser: you need to use nth for lists
13:14Licenserthanks rhudson :)
13:14Licenserand oh my I actually used contains on a seq now o.O
13:15Licensernext question for the smart people, can I extend a proxy with more methods?
13:15Licensersituation is I've an interface X which is statisfied by a proxy pX and an interface Y which also statisfies X so if I write pY I would like to 'reuse' the stuff of pX
13:17replacaLicenser: nope, because proxies are anonymous
13:17Licenserokay
13:18Licenserthen it's time for more macro majo
13:18vu3rddgiven a key like :foo, how can I get the name "foo"?
13:18replaca,(name :foo)
13:18clojurebot"foo"
13:18hamza,(name :key)
13:18clojurebot"key"
13:18vu3rddah.. ok.
13:18vu3rddthanks
13:18replacathe answer was in the question :-)
13:19remleduffWhat does the coding standard mean by "prefer updating over setting?"
13:19vu3rddyes. :) Only that my memory is too small to hold the names of all these functions
13:21rhudsonremleduff: for e.g. a ref, prefer alter to ref-set
13:23hamzawhen you ref-set it implies you don't care about refs prev state.
13:25remleduffGotcha, I thought it was still talking about collections at that point, but it's kind of just a big bag o' tips :)
13:26Licenserhmm more dumb questions, to add an element in a sequience at a certaion position is there already some code?
13:27defnposition in what context?
13:27defnlike after the 5th element add "foo" to the vector?
13:27hamzaAFAIK no, if its a vector use subvec to split it then rebuild for sequences concat.
13:27Licenserdefn: yap
13:27Licenserwell I don't know the type sadly
13:28Licensermight be any kind of sequence, so I guess I roll my own code
13:29remleduff,(assoc (vec (seq [1 2 3 4 5])) 0 99)
13:29clojurebot[99 2 3 4 5]
13:29defnhmmm
13:29remleduffOh, you want to insert?
13:29hamza(concat (take some sequence) [thing_to_insert] (drop some sequence))
13:29Licenseryea insert
13:29hamzareplace some with a number and sequence with your sequence
13:29Licenserhamza: that is nice!
13:31hamza,(concat (take 2 [1 2 3 4]) [99] (drop 3 [1 2 3 4]))
13:31clojurebot(1 2 99 4)
13:31Licenseractually drop 2?
13:31LicenserI want to insert not to add
13:32defn,(rotations [1 2 3])
13:32clojurebotjava.lang.Exception: Unable to resolve symbol: rotations in this context
13:32defn,(use 'clojure.contrib.seq)
13:32clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/seq__init.class or clojure/contrib/seq.clj on classpath:
13:32hamzayeap drop two
13:32defn,(use 'clojure.contrib.seq-utils)
13:32clojurebotnil
13:32defn,(rotations [1 2 3])
13:32clojurebot((1 2 3) (2 3 1) (3 1 2))
13:33Raynes$(rotations [1 2 3])
13:33sexpbotUnable to resolve symbol: rotations in this context
13:33defnmanning still hasn't emailed me with the updated JoC
13:33defn$(use 'clojure.contrib.seq)
13:33sexpbotclojure.contrib.seq
13:33defn$(rotations [1 2 3])
13:33sexpbotUnable to resolve symbol: rotations in this context
13:33RaynesLicenser: ^ is that a bug.
13:33defn$(clojure.contrib.seq/rotations [1 2 3])
13:33sexpbotclojure.contrib.seq
13:34RaynesI think that is a bug.
13:34Raynes;o
13:34defnlooks that way :)
13:34RaynesHe is also printing stuff wrong...
13:34Raynes$(+ 3 3)
13:34sexpbotresult: 6
13:34RaynesIt should always put result: behind it, except in the event of an error.
13:34Licenserhmm odd
13:35Licenserdid you allow use?
13:35RaynesBut that probably isn't clj-sandboxes fault.
13:35RaynesLicenser: You whitelisted c.c.seq, right?
13:35LicenserRaynes: do you really think I know all the whitelisted ns's?
13:35RaynesLicenser: Yes. :p
13:36RaynesNo.
13:36Licenserheh
13:36RaynesYou only whitelisted seq-utils.
13:36RaynesBut it doesn't exist.
13:36RaynesIn 1.2
13:36Licenserah see
13:36Licenserwell just whitelist seq too :P
13:36Licenserno harm in whitelisting non existing stuff
13:36RaynesActually never mind.
13:36RaynesLicenser: You do have it whitelisted.
13:36RaynesSo, bugtime.
13:37Licenserheh
13:37LicenserI finish my seq-ref-combobox-model you find a bug
13:37DavideAngelocolathere is a way to automatically execute code at slime-repl startup?
13:39remleduffDavideAngelocola: If you have a user.clj in your classpath, it gets executed
13:40DavideAngelocolacool, thanks :)
13:41remleduffI kind of wonder how that isn't a security problem, sometimes
13:42remleduffI guess stuff you put in your classpath can do anything it wants in static initializers, etc, so it's not like you're safe just downloading random jars
13:46DavideAngelocolawhat about hardcoding some code in my .emacs? at least to load repl-utils and setting print limit
13:46remleduffDid user.clj not work for that?
13:47DavideAngelocolano, it worked :)
13:58LicenserRaynes: look at this: http://github.com/Licenser/clj-swing/blob/master/src/clj_swing/example.clj#L28
13:59RaynesAwesome.
13:59Licenservery slim definition of the gui and the combo box content backed by a seq that sits in a ref, all changes are auomatically populated to the gui
14:00Licenserso I guess soon you'll write a swing gui for sexpbot :P
14:03rhickey(=? 42) for #(= 42 %) ?
14:03Licenserhmm nice ida
14:04Licenser(some (=? 42) (range 100))
14:04Licenserlooks good to me
14:04Chousukehm, how would you read that?
14:04cemerickrhickey: thanks for the clarification on the field access
14:05rhickeycemerick: you're welcome. I might make that work under reflection, but more work than what is there
14:05LicenserRaynes: big question, list is - obviousely taken, so how do I call the macro for jlist?
14:05rhickeyno path to flow the keyword-ness to where it's needed
14:05cemerickrhickey: surely a good idea before it becomes a supported feature.
14:06rhickeycemerick: if ever
14:06ChousukeLicenser: namespaces are good. just call it list? :P
14:06cemerickrhickey: people suss these things out :-)
14:06LicenserChousuke: I wasn't sure if that'd be bad tase
14:06rhickeycemerick: any opinion on =?
14:06cemerickrhickey: I haven't been following -- in the logs?
14:06rhickeycemerick: (=? 42) for #(= 42 %
14:06rhickey)
14:07rhickeyequality predicate maker
14:08ChousukeI'm not sure I like the name. it breaks the ? convention for predicates and I don't know how it's meant to be pronounced :P
14:08cemerickI'll have to think about =?
14:08Licenserrhickey: the suggestion of got? isntead of contains? was quite good :P
14:09cemerickrhickey: in favor of?
14:09rhickeyChousuke: agreed, but I don't know of better
14:09rhickeycemerick: (some (=? 42) (range 100))
14:09cemerickah
14:09Chousukerhickey: =fn or something? too weird?
14:09rhickey=? would work everywhere predicates do
14:09LauJensenGood evening
14:09Licenserthat reads quite nice I think
14:09Licenserhi lau
14:10rhickeyLicenser: no it wasn't imo
14:11Licenserso rhickey there is one upside to this whole discussion, at least I got used to reading contains? in palces I'd not expect it :P
14:11cemerickThe thing about =? that his me right away is the surprise that it's returning a fn.
14:12rhickeycemerick: yes, but what else could it do?
14:12cemerickSeeing = as the first char in fn position makes me think it's a cousin of =, which it's not. I wonder if that's muscle memory or something that'd be a constant source of friction.
14:12rhickeycemerick: I agree it's the naming convention for preds, OTOH, I don't think it implies anything itself
14:13rhickeythere are of course more verbose and descriptive ways to do this, but will lose to #(= x %) for brevity
14:14Licenserbut #(= x %) is quite short too so while =? is kind of neat there is no urgent need for it
14:14rhickeysome shorthand for partial would work pretty well too
14:14cemerickrhickey: you and chouser were riffing on simpler/cleaner syntaxes for simple anon fns a while back. Is there anything leftover from that that applies here, or was that only for hosty things?
14:14Licenserif you'd had to write (partial =) or (fn [e] (= x e)) every time then yes
14:14remleduffWhat's wrong with equal?
14:14remleduff(equal? 1 1 1 1 1) -> true
14:15rhickeycemerick: only hosty, I can;t think of anything simpler or smaller than #() and it's worked out extremely well
14:15Licenserremleduff: nothing wring, just disucssing to make a shortcut for #(= x %)
14:15technomancyas well as =?
14:15cemerickrhickey: there's a whole tradition of sigils for partial and comp
14:15rhickeytechnomancy: got one?
14:15Licenserthe shorthand of partial would be cool
14:15cemerickMore line-noise-esque stuff though.
14:15technomancythough the former may make the latter unnecessary
14:15Licenserp?
14:15clojurebotI'm sorry, Licenser. I'm afraid I can't do that.
14:15Chousukemaybe make #{x} return a set that's optimised for checking for that one element instead? :P
14:15Licenser(p =)
14:15rhickeycemerick: dot for comp conflicts with host syntax
14:15Licenserthat'd be prtty nice :P
14:16Licenser(doc p)
14:16clojurebotHuh?
14:16cemerickrhickey: right; devlinsf has a convention he uses....
14:16Licenserp seems not taken too
14:16rhickey(app = 42) == app is partial apply
14:16cemericklol
14:16Licenser(doc app)
14:16clojurebotIt's greek to me.
14:16arohnerrhickey: I like (=? 42)
14:16cemerickfn names as humor
14:17technomancydon't have any suggestions, no
14:17rhickeyapp for partial wasn't a joke
14:17cemericksomeone find a haskeller
14:17cemerickrhickey: oh, I know
14:17cemerickI like it quite a bit right off
14:17cemerickIt's just also a pun.
14:17sidsrhickey: why not make some test for equality if the first arg isn't a predicate?
14:17rhickey(some (app = 42) (range 100)) is only one character more
14:17cemerickwhich is a plus, IMO
14:18Chousukewhy not shorten it to just ap?
14:18ChousukeI think that's haskell apply though :P
14:18cemerickwe're all going to be writing in APL shortly. :-P
14:18remleduffCan you do something like just have = return itself instead of true?
14:19Chousuke,(= 1)
14:19clojurebottrue
14:19rhickeyChousuke: Haskell has currying and doesn't really need partial
14:19remleduffYeah, but if = returned itself, you could continue to call it until it returned false
14:19remleduff((= 1) 1)
14:19Chousukeremleduff: but that would break applying =
14:19Chousukeremleduff: since you'd have to special case single-element collections
14:20Licenserwould it?
14:20remleduffWhy? The fn = is still a true value
14:20rhickeynot changing =
14:21cemerickI'll say +1 on app == partial apply
14:21rhickeysids: Clojure doesn't do that sort of thing in general
14:22cemerickapp is nicer than ap IMO FWIW
14:22rhickeycemerick: yes, ap is awkward looking
14:22cemerickThere's some kind of slight phonetic connection that's stronger between apply and the former than the latter
14:23remleduffCould also call it curry?
14:24rhickeystill, even given app, (=? 42) seems clearer than (app = 42)
14:24rhickeyremleduff: that's not currying
14:24cemerickrhickey: Not sure about that -- and app is generally useful.
14:25cemerick=? still screams "returns boolean" to me
14:25rhickeycemerick: yes, app is general, and might win out over use of #(foo arg %)
14:26remleduffapp is kind of likely to already be a used name somewhere
14:26cemerickremleduff: for top-level fns?
14:26rhickeycemerick: but in context? (some (=? 42) ...) , (filter (=? 42) ...)
14:26remleduffTop level def, I think it's the name of my web-app's top level var
14:27cemerickrhickey: yeah, better in context. Still uncomfortable tho.
14:28remleduffBy the time you've found the "some" function, you already should know the #{42} idiom though, it's right there in the docstring?
14:29cemerickIn any case, I want app. :-)
14:29rhickeycemerick: name conflict issue for app are real
14:29rhickey(some (=to 42) (range 100))
14:29rhickey?
14:30mmarczyk99% of the time, #{foo} is good enough for me -- and (remove identity ...) for removing falsey values
14:30rhickeycemerick: yes, and :as-of etc
14:30remleduffpapp instead of app?
14:30cemerickbbl
14:31LauJensenComing in a little late, what was the purpose of app/=? other than currying?
14:32rhickeyLauJensen: it's not currying, app == partial
14:33rhudson(=_ 42) maybe?
14:34sidshow about (=% 42)?
14:35mmarczykhow about, say, %foo (&foo? $foo?) in operator position expanding to partial foo
14:35mmarczykor maybe %* for partial, %. for comp (%:, %% ?)
14:35LauJensenrhickey: Ah - Would be great if that could be implemented in a similar way to #()
14:35LicenserI think we're getting too perly here
14:36LauJensenWould make sense though #() for anonymous !() for anonymous partial for instance
14:36LicenserI'd rather write (partial foo 42) then (&foo? 42)
14:37Licenserat least everyone knows what I mean, and seriousely partial isn't that long
14:37LauJensenYes, but what about !(f 42) ?
14:37mmarczykor #!() or sth
14:37Licenser#!() = (not #())?
14:37rhickeyLauJensen: that's not going to happen, #() is sufficient magic
14:37LauJensenshot down :)
14:38rhickeyshorter name for partial is all that's in play, and app is really good
14:38remleduffI kind of like papply, app is fine too, I can :exclude, you're right. Not sure what the point of =? is, doesn't seem to buy much.
14:38LauJensencgrand will have to rename his app then, in moustache
14:38Licenserapp sounds lind of like application to me
14:39rhickeyLicenser: it is partial application
14:39Licenserahh sneaky then application even makes sense :)
14:40Licenserto toss in something else, pa?
14:40LauJensenapp is good though, think it will sit well with most people quite fast
14:41remleduffWhy can't apply just be partial if too few args are supplied?
14:42mmarczykremleduff: how'd you tell if too few args were supplied?
14:42Licenserbut yes app is fine
14:43remleduffmmarczy: should probably have thought more before I asked, but was thinking you could use reflection or something
14:44remleduffmmarczyk: I mean
14:44LauJensenremleduff: Doesnt hurt to throw it out there, you never know what comes back
14:47patrkris"app" is partially the word "apply" - so it makes sense :) But maybe that was the whole reason for the suggestion :)
14:47mmarczykremleduff: that *would* be nice, but can't be sure in general
14:47Licenserhmm I can't call a namespace list it seems meh :P
14:47rhickeypatrkris: yes
14:48ChousukeLicenser: hm, you can't?
14:48LicenserI called it clj-swing.list and it tells me
14:48LicenserName conflict, can't def list because namespace: clj-swing.list refers to:#'clojure.core/list
14:48Licenserah wait no I can't cal the function list o.O?
14:48Chousukehuh
14:49remleduffappl is also partially apply, and it sounds tasty ;)
14:49ChousukeLicenser: ah, right, you need to rename clojure.core/list or (def your.namespace/list ...)
14:49Licensernope def my.namespace/list does not work
14:49Licenserand rename core/list sounds evil o.O
14:50ChousukeLicenser: though using this name means people using your namespace will not be able to :use it
14:50Chousukebut in my opinion that's just a positive thing :)
14:50LicenserChousuke: but it does not let me def my.namespace/list :P
14:50Licenserand I can't write around in clojure.core just to rename a function so I can get the name
14:50Chousukewell I guess you can add a :refer-clojure to your ns declaration :P
14:50Licensera
14:50Licensernd
14:50LicenserI
14:50Licenser'
14:50rhudsonLicenser: might be better to stick with jlist for this one
14:50Licenseroops sorry
14:51Licenserbut then all components should be j*
14:53rhudsonLicenser: that wouldn't be so bad. But I think folks would understand why jlist is a special case
14:53Licenserhmm true
14:53Licenseror I convince rhickey to rename list to clist :P
14:53Chousuke:P
15:08Licenserhmm is there a reason contains does not work on lists?
15:09Licenserand no I don't want to start an argument again
15:10remleduff,(get '(a b c d) 2)
15:10clojurebotnil
15:10remleduffThe explanation on the group is that contains works with get, if get will return a value, then contains returns true
15:11mmarczykget and contains? both return nil when they have no better idea
15:11mmarczykin the case of lists, they do in fact have no better idea
15:11Licenser,(contains [1 2 3] 2)
15:11clojurebotjava.lang.Exception: Unable to resolve symbol: contains in this context
15:11Licenser,(contains? [1 2 3] 2)
15:11clojurebottrue
15:12Licenser,(gat [1 2 3] 2)
15:12clojurebotjava.lang.Exception: Unable to resolve symbol: gat in this context
15:12Licenser,(get [1 2 3] 2)
15:12clojurebot3
15:12Licenserah I see
15:12opqdonutmmarczyk: why?
15:12opqdonut(get (seq '(1 2 3 4)) 2)
15:12opqdonutgah
15:12opqdonut,(get (seq '(1 2 3 4)) 2)
15:12clojurebotnil
15:13opqdonut,(get (seq [1 2 3]) 2)
15:13clojurebotnil
15:13opqdonuthmm
15:13mmarczykopqdonut: well I certainly see why get wouldn't work with sequences; it's what nth is for
15:14opqdonut,(nth 3 [1 2 3])
15:14clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
15:14opqdonut,(nth [1 2 3] 2)
15:14clojurebot3
15:14opqdonutthat
15:14opqdonut's not a reason :)
15:14remleduffIt would almost be better for get and contains to throw assertions if they were used on the wrong structures
15:14mmarczykget is supposed to query 'mappings', so it works for sets/maps and also vectors/strings when given a number as key
15:14Licenser(nth '(1 2 3) 2)
15:14Licenser,(nth '(1 2 3) 2)
15:14clojurebot3
15:15mmarczykremleduff: I feel that perhaps it would be better to remove the word 'almost' from your last sentence :-)
15:15Licenser(inc remleduff)
15:18remleduffremledufg
15:18rhudson:)
15:19Licenserhah first logical problem with the swing stuff, panels :(
15:19defnanyone else having issues with enlive-html and null point exceptions when using deftemplate?
15:20remleduffdefn: You get those if your path to the html file is wrong
15:20remleduffAlso maybe for other reasons, but always been that for me ;)
15:22defnremleduff: yeah ive tried a few paths, not sure why it's not shoing up on the CP
15:22rhudsonWhat's the panel problem?
15:22remleduffdefn: It's boiling down to calling (html-resource "thePathYouGive") if you want to experiment
15:23remleduffdefn: I had problems at one time because I had my templates in a "resources" directory but the swank version I was using didn't add "resources" to the classpath
15:23LauJensenremleduff: Had the same problem, describe-function swank-clojure-project, added the line, C-c C-c, done :)
15:25defnremleduff: im using lein swank
15:25defnso it shouldn't be a problem
15:26defnis it possible to turn a string "(foo (bar (baz)))" into '(foo (bar (baz)))?
15:26patrkrisLauJensen: what is your secret to get Clojure jobs in Denmark? :)
15:27LauJensenpatrkris: Well if I told you it wouldnt be a secret - But as everything else its hard work and putting in the hours
15:28rhudson,(read-string "(foo (bar (baz)))")
15:28clojurebot(foo (bar (baz)))
15:28patrkrisLauJensen: :) Everyone that offers me anything wants .NET programming. Which I'm capable of. But it's not fun in the same way. :)
15:29LauJensenpatrkris: Then the trick might be to start saying no :)
15:29patrkrisLauJensen: well... you know... the money :)
15:30remleduffpatrkris: ClojureCLR? ;)
15:30wlangstrothpatrkris: tried F#?
15:30patrkrisremleduff: yeah - what's the current state of that?
15:31patrkriswlangstroth: nope, I haven't
15:31LauJensenF# is the greatest thing to hit IT since burnt toast
15:31patrkriswlangstroth: the ML-stuff never appealed to me - but maybe I should give it a try
15:31LauJensenoops, value judgement :)
15:31patrkrisLauJensen: haha, I guess you're not a fan
15:32wlangstrothaw, F# is okay. If someone just has to have .NET, F# is more fun than C#
15:32LauJensenpatrkris: I did a blogpost a while back, which ran through some news groups counting words. I had 2 separate guys email. first saying "I solved this in F#, but unfortunately it dies halfway through, dunno why", the other guy "I solved this in f#, for some reason it crashes when I try to run it" - So that kinda tainted my image a little bit
15:34wlangstroth... but then, I haven't tried out ClojureCLR yet
15:34patrkrisLauJensen: hmm... that *does* leave a bad impression
15:35patrkriswlangstroth: ClojureJVM is really easy to get working, and last time I looked at ClojureCLR it looked still half-baked.
15:35patrkrisbut that's a while ago
15:35LauJensenpatrkris: I think CLR has come to a grinding halt, because once clojure is implemented in clojure, they basically have to start over in a different way as I understood it
15:36patrkrisLauJensen: right, didn't think of that
15:36patrkrisbesides, i really like running a *nix OS
15:36defn(with-out-str (pprint (java.io.PushbackReader. (java.io.StringReader. "(foo (bar (baz)))"))))
15:37defnis that correct? it's not giving me the pprint version
15:38patrkrisLauJensen: know of any companies employing clojure in Denmark?
15:38patrkrisLauJensen: besides yours ;)
15:39LauJensenpatrkris: Well, first you have to check out http://conj-labs.eu to get your black-belt, then we'll talk :)
15:39sexpbot"conjLabs - Now accepting registrations!"
15:41chessguycan someone remind me, what's the expect way within a clojure project to include other files in the project?
15:41mmarczykhttp://www.paullegato.com/blog/dtd-validation-malformed-xml-clojure/
15:41sexpbot"XML DTD Validation in Clojure: Turning It Off, Parsing Malformed XML | Paul Legato"
15:41mmarczykthis has to be one of the very best rants I've ever read :-)
15:42mmarczyk(I'm totally on the side of the author, by the way, lest the word 'rant' implies otherwise)
15:44chessguyi'm confused about use, require, and refer
15:44mmarczykuse = require + refer
15:45chessguyand what's the difference betwen require and refer?
15:45mmarczyk,(doc refer)
15:45clojurebot"([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current name
15:46mmarczykso that's what refer does, while require goes out and searches for a namespace with the given name on the classpath
15:46chessguyyeah, i read that, but i don't understand the difference
15:47mmarczykwell refer does not go out and search for the ns on the classpath
15:47chessguyso it's just for within your project?
15:47mmarczykno, it's just for namespaces which already exist when it's called
15:47remleduffrefer won't actually cause anything to get loaded, it just takes another name and brings it into the current namespace
15:47mmarczykand require does not do what refer does, i.e. add any mapping to the current namespace
15:48mmarczykwell actually it might add an alias
15:48mmarczykthat's properly the job of alias, but require can call that when used with :as
15:48chessguyso....if i want to use something from another namespace, i need to require it
15:48mmarczykor use it, though don't forget :only in that case
15:49chessguyso that readers of the code can tell what you're pulling in?
15:49mmarczykyes, and so that you can avoid name clashes which might be introduced by updates to libs that you're using
15:50chessguyso when would i 'use' instead of just 'require'
15:51mmarczykif you need just a couple of names from a namespace and want to reference those directly
15:51mmarczykI tend to use clojure.contrib.monads, as I can't see publics from there clashing with anything else
15:51chessguyok, cool. thanks
15:51mmarczykexcept another impl of monads maybe :-)
15:51remleduffI consider use fine within your own codebase when you're pulling in another file that you control. It's also fine with :only if you want to say (symbol) rather than (alias/symbol)
16:03rhudsonmmarczyk: Re the Paul Legato rant -- I couldn't help but notice that his workaround is a lot of .setFeature calls that, ah, use URLs as identifiers.
16:06remleduffAnyone know where to find leiningen-1.1.0.jar ?
16:07remleduffNevermind, right there on github
16:10mmarczykrhudson: I got the impression that he wasn't particularly happy with that feature of the API
16:10mmarczyknor any other for that matter
16:10mmarczykI'm entirely in agreement :-)
16:12rhudsonYeah, I spent some painful hours this very week lost in the bowels of javax.xml
16:13Raynesrhudson: Was it hot down there? I hear it's hot down there.
16:13rhudsonI got pretty hot around the collar.
16:13rhudsonAnd it's very dark
16:15mmarczykisn't that the inspiration for "A dungeon horrible, on all sides round, / As one great furnace flamed, yet from those flames / No light, but rather darkness visible / Served only to discover sights of woe" ?
16:16LicenserRaynes: if you want check out the new clj-swing stuff :) nicer now! Soon you can start making your swing apps :P
16:17rhudsonParadise Lost? With XML I'm not sure we ever had it
16:18mmarczyktrue
16:19mmarczykand yet every moment spent with XML makes one pine for it more
16:20rhudsonWhat gets me (to bring it back to Clojure) is that a lot of folks perturbed by "all those parentheses" seem fine with XML in ant, maven, Spring, ...
16:23mmarczykyes
16:23mmarczykthat is so... unfathomable
16:24mmarczykuncanny even
16:24wlangstroth"abandon hope all ye who enter here"
16:24mmarczykthe work of XML demons
16:24remleduff<invoke><function>inc</function><arg>rhudson</arg></invoke>
16:26rhudson<emoticon>:)</emoticon>
16:28mmarczykyou mean <emoticon sentiment='positive' nose='false' />
16:29rhudsonDo you have an XSLT for that?
16:29mmarczykyeah, I'm sure it is there somewhere... oh, where is it now...
16:31remleduffIs there any way to "validate" a sexp though? There are some advantages to schemas at least.
16:32mmarczykremleduff: what's an invalid sexp? :-)
16:33rhudsonWell, the repl tells me when I have the wrong number of arguments...
16:33mmarczyk{:schema "my funky schema" :data {:foo "bar" :quux "baz"}}
16:34mmarczykthen "my funky schema" can decide which keys :data should / may contain etc.
16:35mmarczykbut anyway, what can be done with XML that can't be with a protobuf and/or json (possibly with the constraint that it is worth doing)
16:36chousera protobuf *require* a schema (actually the happily named Descriptors$Descriptor) before you can interpret it.
16:36remleduffxsd is defined in a standard enough way that I can take your xsd and tell you where you use an xml element with the wrong number or type of args. In IntelliJ if I open an xml file with a schema, IntelliJ can offer context-sensitive completions automatically.
16:36chouserxml is nicely namespaced in a way the json is not.
16:37chouserxml is awkward and verbose in many cases where json and protobufs are not.
16:38rhudsonIt's not XML per se that bothers me so much as inappropriate uses of it. It's inappropriate syntax for a DSL for instance -- anything humans would write.
16:39rhudsonXML is machine-readable; let machines write it.
16:39chouserclojure s-exprs are namespacable, provide a nice variety of collection types, are compact, do not require a schema (though there's a handy language for validating/manipulating them)
16:40mmarczykchouser: I mentioned protobufs *because* they use schemas
16:40mmarczykas an example of a nicer technology which can be used in place of XML where schemas are useful
16:40rhudsonXSD is a case in point -- to my mind it's inferior to Relax NG, which has a non-XML Compact Syntax that's very readable.
16:40chouserbut not everyone is comfortable consuming/producing clojure s-exprs (yet) so still often not the best choice. :-)
16:41mmarczykagreed on "let machines write it"
16:41mmarczykas soon as I won't have to deal with build scripts written with XML
16:42mmarczykand the like
16:42rsynnottthough it is worth noting that they're not suitable for communication with an untrusted client/server, as currently implemented
16:42mmarczykI'll only dislike and not hate XML :-P
16:42rsynnottif the client says that, say, a string is 4GB, current implementations will happily allocate that
16:43rsynnottAMAZINGLY faster than XML, though, of course :)
16:44bmasonwhat happened to the compojure documentation?
16:44bmasonwasn't there a reference page for the request/response maps?
16:45remleduffGoogle has more than 12,000 .proto files!
16:56bmasonnevermind, compojure's Request is in the RING documentation
17:04defnhow do you turn "(foo (bar (baz 42)))" into (foo (bar (baz 42)))?
17:05Chousukeread-string
17:05defnChousuke: thanks
17:39remleduffAnyone know if compojure has some helper for making "links" with method="delete"?
17:41defn [null] Caused by: java.lang.Exception: Unreadable form
17:41clojurebothttp://clojure.org/java_interop#toc46
17:50chessguyok, i have this declaration:
17:50chessguy(ns generic_operators.complex-numbers-operations
17:50chessguy (:require [generic_operators.real-imaginary-complex :as complex]))
17:50chessguyand it gives this error:
17:50chessguyCould not locate generic_operators/real_imaginary_complex__init.class or generic_operators/real_imaginary_complex.clj on classpath: (complex-numbers-operations.clj:1)
17:51chessguywhat gives?
17:53arbschtchessguy: what's generic_operators and is it in your classpath?
17:53chessguyit's just part of the namespace
17:54chessguy(i'm new at clojure projects)
17:54remleduffAnyone know how to do the equivalent of Rail's link_to function in compojure or enlive?
17:56arbschtremleduff: hiccup.page-helpers/link-to
17:56quizmehi, does anybody here use Counterclockwise in Eclipse?
17:57arbschtremleduff: that's if you're using hiccup with compojure; compojure itself doesn't do it
17:57chessguyarbscht, can i not have something like that as part of my namespace?
17:57quizmeI am trying to get a lein-generated clojure project to be viewable in Eclipse.
17:57remleduffarbscht: That can't seem to do method="delete" though :\
17:58licoresseisn't there an issue with using _ and - in namespace-names?
17:58arbschtchessguy: you can, you've probably structured your file tree inappropriately. can you pastebin a view of it?
17:58chessguyoh, it's dependent on the diretories?
17:59licoressechessguy: sure is
17:59chessguybummer
17:59stilkovchessguy: Java platform shining through
17:59clojurebothmm… sounds like your out of heap space
17:59arbschtremleduff: right, I think you'll have to roll your own for a perfect equivalent
18:01chessguywhat does this channel prefer for a pastebin?
18:01arbschtpaste.lisp.org or gist.github.com
18:04chessguyok, so here's the directory structure and what i'm trying to do (it's changed since what i pasted in the channel earlier)
18:04chessguyhttp://paste.lisp.org/display/98651
18:08chessguythe error i'm getting now is: Could not locate real_imaginary_complex__init.class or real_imaginary_complex.clj on classpath: (complex-numbers-operations.clj:1)
18:10chessguyugh, i got booted
18:11stilkovchessguy: how do you run your code? from the command line?
18:11raekyou should use the full namespace names
18:11stilkovand what's in your classpath?
18:11chessguystilkov, i launch a REPL and load it there
18:11raek(ns generic_operators.complex-numbers-operations (:require [generic_operators.real-imaginary-complex :as complex]))
18:12raekchessguy: from what directory?
18:12stilkovand you launch the REPL how?
18:12chessguyraek, that's what i had originally
18:12chessguyi right-click on one of the files and select 'launch repl'
18:12raekI'm not familiar with how that script works
18:13chessguyi'm in eclipse
18:14raekanyway, you have to decide what directory is the source root
18:14raekmaybe eclipse has it's own opinion about that
18:15stilkovthe directory your code is in needs to be a source path in you build path settings
18:15stilkov*sigh* I guess the Eclipse way is hard to explain in an IRC chat
18:15raekyou can look at the classpath with (map println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
18:16chessguythat gives:
18:16chessguy(#<URL file:/C:/eclipse/workspaces/generic_operators/bin/>
18:16chessguy#<URL file:/C:/eclipse/workspaces/generic_operators/>
18:16chessguynil #<URL file:/C:/eclipse/workspaces/generic_operators/clojure.jar>
18:16chessguynil #<URL file:/C:/eclipse/workspaces/generic_operators/clojure-contrib.jar>
18:16chessguynil #<URL file:/C:/eclipse/workspaces/generic_operators/classes/>
18:16chessguynil nil)
18:16raekah, ok
18:16chessguyso i guess that's right
18:17raekthen "generic_operators" should not be a component of your namespace names
18:17raekah, now I see it...
18:17chessguyit shouldn't be in the namespace name, or in the :require
18:17chessguyor both
18:18raekhyphens in namespace names should be underscores in file names
18:18raekboth.
18:18chessguyoh, ugh
18:18raekthe namespace name reflecs the path to the source file, relative the classpath
18:18raekso segments in the classpath should not be in namespace names
18:19chessguyah, fixing the filenames seems to have fixed it
18:19raek"Could not locate (...) real_imaginary_complex.clj on classpath"
18:20raekI've been hit by this some times myself
18:20licoresseas I said
18:21chessguythanks raek, i got it now
18:35remleduffAnother 1.2 feature I might request, deprecate underscores in namespaces :)
18:36remleduffI mean hyphens
18:36remleduff1.2 is going to be great already though :)
18:43Raynes$mail LauJensen Eric implemented the s/this/that/ behavior you wanted.
18:43sexpbotMessage saved.
18:53licoresseClojure on LLVM? Why not?
18:55remleduffLack of inifinite Rich Hickey's ;)
18:58tomojremleduff: you want no hyphens allowed in namespaces?
18:59remleduffWould be one less thing for newbies to trip on
19:02remleduffMost of the time, when you use a hyphen in a namespace, could just as easily add another segment to the package
19:03joshua-choiI have an integer "n" and a lazy sequence "s" that may be infinite. What is the best way to determine if (> (count s) n)?
19:03joshua-choiI'm using drop right now, but I'm wondering if there's a better way
19:06joshua-choiNamely, is there a better way than (seq (drop n s))?
19:08remleduffjoshua-choi: You could do (when (instance? Counted s) (count s))
19:08hiredman,(doc counted?)
19:08clojurebot"([coll]); Returns true if coll implements count in constant time"
19:09joshua-choiThat seems a little fragile. Will it always work?
19:10remleduffActually, count will work on its own if you look at the implementation
19:10hiredmanremleduff: no, count will try and force the infinite lazy-seq
19:11remleduffOh right, forgot where I was starting from
19:12remleduff,(count (increment inc 0))
19:12clojurebotjava.lang.Exception: Unable to resolve symbol: increment in this context
19:12remleduff,(count (repeatedly inc 0))
19:12clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$repeatedly
19:13rhudsonremleduff: I think you want 'iterate
19:14remleduff,(count (iterate inc 0))
19:14clojurebotExecution Timed Out
19:14joshua-choiOh good, I was afraid it would blow up
19:14rhudsonsmart bot
19:14remleduffNo, did it here instead of my repl because I knew it would timeout and not break my own repl :)
19:15rhudsonsmart remleduff
19:15chouserrepl-utils has set-break-thread! so you can manually timeout such things
19:16joshua-choiremleduff, (when (counted? s) (count s)) doesn't do the same thing as (seq (drop n s)). I want to know if n is within the seq's bounds.
19:16remleduffWell, you still have to do the drop if is isn't Counted
19:17joshua-choiEven if it's not Counted, it may be lazy, right? (Or are all lazy sequences non-Counted?)
19:18joshua-choiOh, right, of course they aren't.
19:18remleduffWas just suggesting a way to optimize the non-lazy case
19:19joshua-choiI see; you mean then (if (counted? s) (< n (count s)) (seq (drop n s))).
19:19remleduffYep
19:20rhudsonBut I would think if s is counted, then drop's pretty efficient
19:21joshua-choiHmm
19:21drhodes(def $/ "foo") is there a way to escape the / so that it becomes a valid name ?
19:22rhudsonIt's already a valid name
19:22drhodes,(def $/ "foo")
19:22clojurebotInvalid token: $/
19:22joshua-choiNo, there is not.
19:23joshua-choihttp://www.clojure.org/reader
19:23drhodesokay, thanks joshua-choi
19:23remleduffIf you (map f <something-counted>) is the result counted?
19:23chouserno
19:23chousermap returns a lazy seq, which is not counted
19:23hiredmanyou can map over an infinite sequence
19:24remleduffYeah, it could easily return a lazy seq that is counted too though
19:24hiredmannope
19:24rhudson,(count? [])
19:24clojurebotjava.lang.Exception: Unable to resolve symbol: count? in this context
19:24rhudson,(counted? [])
19:24clojurebottrue
19:24rhudson,(counted? (seq []))
19:24clojurebotfalse
19:26remleduffThe seq of something counted also be counted though
19:26remleduffProbably be way easier with protocols
19:27rhudson,(counted? (seq [1]))
19:27clojurebotfalse
19:27remleduffI see you're saying that it currently isn't, but I don't see why it couldn't be
19:28rhudsonI see what you're saying
19:34chouser,(counted? (seq (into-array [1 2 3])))
19:34clojurebottrue
19:35rhudsonha
19:35remleduffI think seq of arrays makes an ArraySeq
19:35remleduff,(class (seq (into-array [1 2 3])))
19:35clojurebotclojure.lang.ArraySeq
19:46remleduffAny emacs users no how to deal with a C-x C-f that takes something like 3 seconds every time before it starts showing files?
19:46remleduffman, my spelling is horrible. s/no/know/
20:13remleduffIf I do something like (defn page [id] ({:home "/home", :user "/user"} id)) is the map evaluated every time I call the function?
20:16qbgSo Rich removed seq-contains?
20:37chessguyfor a multi-method, are you guaranteed the methods you define will be tried in order?
20:39qbgWhat do you mean by tried in order?
20:42chessguye.g., if i do (defmulti action dispatch) (defmethod action v1 [] ...) (defmethod action v2 []), if v1 and v2 can both potentially match the value return from dispatch, v1 will always be used
20:43chessguyit seems like that's the case, given the idiomatic way of using :default
20:45chessguyoh, i guess the only matching done is equality and isa
20:46chessguyi mis-understood that
20:53defnevery time i use (with-out-str (pprint (read-string "(letfn [(without [s n] (concat (take n s) (drop (inc n) s)))] (without (range 10) 4))"))) in my repl it works as expected, adding newlines where needed
20:53defnonce I put that into my application I get "unreadable form" java exceptions
20:54zkimhey all, anybody here using lein 1.2.0/master
20:59chessguyit does seem like multimethods could be more powerful
21:02mmarczykdefn: works for me, both from the REPL and the file
21:02mmarczykdefn: are you absolutely sure you're using the same string both places?
21:02chessguye.g., if http://www.brool.com/index.php/pattern-matching-in-clojure got pulled into multi-methods, that would be cool
21:03sexpbot"brool » Pattern Matching In Clojure"
21:03mmarczykchessguy: with multimethods, the more derived type is preferred
21:03defnmmarczyk: tough to say, might be the syntaxhighliter screwing everything up
21:03mmarczyksee derive / underive functions
21:03mmarczykdefn: well in Emacs you could use C-M-k at the REPL to kill the string
21:03chessguymmarczyk, yeah, still seems pretty simplistic though
21:03mmarczykthen yank it back inside your app
21:04mmarczykchessguy: it never occurred to me to think of this as simplistic :-)
21:04mmarczykchessguy: what useful extra complexity would you like to add?
21:05mmarczykzkim: why?
21:05chessguymmarczyk, dispatch based on more than equality/hierarchy
21:05mmarczykchessguy: well you can dispatch on whatever you want
21:05mmarczykchessguy: that's the point of the dispatch function
21:05chessguymmarczyk, err, sorry, i'm talking about matching the result of the dispatch function
21:06chessguynot the dispatch itself
21:06mmarczykchessguy: well, to be honest, I see no point
21:07mmarczykthat would be like building an infinite tower of polymorphic dispatches
21:07chessguye.g. (defmethod foo {:Shape :Rect :wd 2} ...)
21:07mmarczykwe've just dispatched on our args, so let's take the "dispatch key" and process it further
21:07mmarczykthen why not take the result of that and dispatch again etc.
21:08chessguywhy not indeed
21:08Associat0rwlangstroth: I do F#
21:08mmarczykthe answer to 'why not' is that it's hard to see the answer to 'why' ;-)
21:09mmarczykand you don't want to have multimethods be slower without great reason
21:10chessguyhm. fair enough
21:10mmarczykif you care for pattern matching in your dispatch, then use it in your dispatch function, returning some keyword codes
21:10mmarczykpresumably you'll only have finitely many methods
21:10chessguyyuck
21:10chessguythat's kind of ugly
21:11chessguyand what if i want to add more methods later?
21:11mmarczykif you want "open pattern matching"
21:12mmarczykthen maybe return the most general pattern you're able to match
21:12mmarczykum, sorry, I mean the most *specific* pattern
21:13mmarczykor actually, return whatever makes sense for your multimethod, coming to think of it, it's not obvious which would be correct :-)
21:13mmarczyklanguages with built-in support for pattern matching, afaik, all use a closed model
21:14chessguyyeah, exactly :)
21:14mmarczykso now you have a problem of how to open it up
21:14mmarczykallow appending patterns to the list or sth?
21:14mmarczykmaybe implement an alternative flexible dispatch scheme, say with
21:15chessguyok, so imagine a wumpus world
21:15mmarczyk(let [patterns (atom [])] (def ^{:add-pattern (fn [...] ...)} foo [...] ...))
21:15chessguyi may really want to dispatch on a lot of things
21:15mmarczykum, what's a wumpus?
21:15mmarczyk:-)
21:16chessguylol
21:16chessguyclassic AI problem
21:16chessguyumm, ok, tic-tac-toe
21:16chessguythere are a lot of patterns, even in that simple game
21:16mmarczykok, looked it up :-)
21:16zkimmmarczyk: sorry, stepped out for a sec, trying to get lein HEAD to work, but I'm getting a stack overflow when running ./bin/lein. Was wondering if anybody else has gotten it to work
21:17chessguywhat i want to do is dispatch based on a destructuring of the board
21:17mmarczykzkim: works for me, never saw it overflow stack
21:17mmarczykzkim: are you sure you've got updated deps etc.
21:18zkimyeah, maybe I'll nuke my .m2 and try again
21:18mmarczykmaybe try rm -rf deps
21:18mmarczyk& lein-stable deps
21:18mmarczykfirst
21:18mmarczyk:-)
21:18zkimah good idea
21:19gerryxiaohello
21:20mmarczykchessguy: without wanting to go into what would work for any particular problem, if you really feel that pattern matching could help you, you can maintain an atom of pattern / function pairs (a vector of vectors, most likely)
21:20mmarczykchessguy: have the function which would be your "pattern-based multimethod" close over that atom
21:20gerryxiaohow to make lein uberjar includes images or sound resource files
21:21mmarczykchessguy: with functions to manipulate the list of pattern hidden a way in the metadata on the Var, maybe?
21:21gerryxiaowhich is not in src dir
21:21mmarczykchessguy: see if it works better for you than a multimethod-based approach
21:22mmarczykchessguy: not saying that it would, but who knows, and if you miss your pattern matching...
21:22mmarczykgerryxiao: I believe stuff in resources/ should be included in the uberjar
21:22mmarczykgerryxiao: it's certainly included on the classpath with lein swank
21:24mmarczykchessguy: multimethods certainly can't do the same thing, but they're meant to be a flexible polymorphism solution, not an open cond
21:24chessguymmarczyk, fair enough
21:26mmarczykchessguy: but going back to the wumpuses, is the challenge to code up a wumpus or a wumpus hunter? :-)
21:26mmarczyk(or both?)
21:27chessguymmarczyk, typically, it's phrased so that the problem is to code the wumpus hunter
21:27gerryxiaommarczyk: i have to move stuff to resources dir?
21:27mmarczykgerryxiao: that's the place lein expects to find resources
21:28mmarczykgerryxiao: there's probably a project.clj switch to change that location, but I can't say I remember the name
21:28mmarczykgerryxiao: anyway, I'd expect uberjar to pull in stuff from there, so maybe give it a shot
21:29mmarczykchessguy: and the wumpuses don't move, do they? cool puzzle :-)
21:30gerryxiaook,i'll try that
21:30chessguymmarczyk, there are different formulations of the game
21:38mmarczykI see... now I want to go wumpus hunting :-)
21:39chessguyhehe
21:43rfgHow does one set Java options when using lein?
21:49joshua-choiI am having difficulty with Leiningen after self-installing; is there another room I can ask Leiningen help in?
21:50chessguymmarczyk, i'm kind of thinking about re-implementing ruby-warrior in clojure for similar fun
21:50hiredman2009:Mar:17:14:25:44 hiredman : http://github.com/ryanb/ruby-warrior/tree/master <-- this is way cute, it needs porting to clojure
21:51hiredmanchessguy: do it!
21:51chessguyhiredman, what, you mean you saw that it needs to be done, and didn't do it??
21:51chessguyfor shame!
21:52hiredman~hiredman
21:52clojurebothiredman <3 XeLaTeX
21:52hiredman~hiredman
21:52clojurebothiredman is an evil genius.
21:52hiredmanhmmm
21:53mmarczykthis... is... amazing 8-O
21:53remleduffrfg: I think it's JAVA_OPTS
21:53mmarczykruby-warrior, I mean
21:53mmarczykdefinitely needs porting :-)
21:54rfgremleduff: Yeah, I've just found that, cheers.
21:55gerryxiaohmm,where is seq-contains? i have just changed includes? to seq-contains?
21:55mmarczykactually I might go through it first, I was going to learn some Ruby to see where all the Ruby people in the Clojure community come from :-)
21:55joshua-choigerryxiao: In the clojure.core.
21:55mmarczykgerryxiao: got axed yesterday
21:55joshua-choiAh!
21:55joshua-choiReally? Was it renamed?
21:55zkimmmarczyk: hey, just thought you'd like to know, turns out the stack overflow only happens when you run lein w/o arguments
21:56gerryxiaommarczyk: now use what for seq-contains?
21:56mmarczykzkim: right, I don't think lein makes any effort to be useful without an explicit arg
21:56mmarczykgerryxiao: whatever you used before, I guess
21:56remleduff,(some #{42} (seq [3 63 42]))
21:56clojurebot42
21:56mmarczyk(some #{false true} [1 2 false 3])
21:56mmarczyk,(some #{false true} [1 2 false 3])
21:56clojurebotnil
21:57mmarczykouch, I mean
21:57mmarczyk,(some {false true} [1 2 false 3])
21:57clojurebottrue
21:57mmarczyk,(some #(= % 3) [1 2 3])
21:57clojurebottrue
21:57gerryxiaommarczyk: i used includes? before
21:57remleduffOh, hah, so it'll have to go back to contrib I guess
21:58mmarczykgerryxiao: never used that one, so wouldn't know if it's still in contrib
21:58remleduffBetter off learning the some idiom though :)
21:58chessguy(#(= % 3) 3)
21:58chessguy,(#(= % 3) 3)
21:58clojurebottrue
21:58chessguy,(#(= % 2) 3)
21:58clojurebotfalse
22:01technomancyjoshua-choi: what's the issue with lein?
22:01gerryxiao,(some #("hello") [1 3 "hello"])
22:01clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--13672$fn
22:01technomancyman, CL sure had some lousy function names
22:01chessguy,(some #(= % "hello") [1 3 "hello"])
22:01clojurebottrue
22:01joshua-choitechnomancy: It actually disappeared for some reason.
22:01joshua-choiI do have an Autodoc question: I included [autodoc "0.7.0"] in :dev-dependencies in my project.clj, but I can't do "lein autodoc". Do I have to do something else?
22:02technomancyjoshua-choi: you did lein deps after adding it to dev-dependencies?
22:02remleduff,(some #{"hello"} [1 3 "hello"])
22:02clojurebot"hello"
22:02gerryxiao,(some #(= % "hello") '(1 2 "hello"))
22:02clojurebottrue
22:03chessguy,(some #{"hello"} [1 3])
22:03clojurebotnil
22:03chessguyhm
22:03chessguyis the #{foo} construct the same as #(= % foo) ?
22:04chessguyerr, no, clearly, it's not
22:04joshua-choitechnomancy: Yes, I did. Actually, I'm running into a different problem now when I type "lein autodoc".
22:04rhudsonIt's a set with one element
22:04remleduffNo, #{foo} is a set containing foo, when used as a function it returns the value or nil
22:04joshua-choitechnomancy: I get, "[null] #<CompilerException java.lang.ExceptionInInitializerError (autodoc.clj:1)>
22:04joshua-choi [null] Make sure autodoc is added as a dev-dependency in your project.clj."
22:04joshua-choi(I'm using [autodoc "0.7.0"].)
22:04rhudsonAs a function, it says whether the arg is in the set
22:05chessguy,({"hello"} "hello")
22:05clojurebotjava.lang.ArrayIndexOutOfBoundsException: 1
22:05chessguy,(#{"hello"} "hello)
22:05clojurebotEOF while reading string
22:05chessguy,(#{"hello"} "hello")
22:05clojurebot"hello"
22:05remleduffPesky characters
22:05chessguy,(#{"hello"} "bye")
22:05clojurebotnil
22:05chessguygotcha
22:06mmarczyk,(#{false} false)
22:06clojurebotfalse
22:06mmarczyk:-)
22:06chessguy,(#{nil} nil)
22:06clojurebotnil
22:07chessguy,(= nil nil)
22:07clojurebottrue
22:08chessguy,so, what is this syntax called? #(= % foo)
22:08clojurebotjava.lang.Exception: Unable to resolve symbol: so in this context
22:08chessguy oops
22:08mmarczykchessguy: 'anonymous function literal', I guess :-)
22:09chessguymm, it's more tnan that, with the parameter naming
22:09mmarczykhm?
22:10chessguyoh, i see, never mind
22:10mmarczyk:-)
22:11chessguykind of a silly name, but ok
22:12rhudsonI suppose it's an "anonymous function reader macro", or "reader macro anonymous function"
22:13remleduffIt's basically shorthand for lambda
22:16remleduffDoes anyone have an example of a sizable project using enlive?
22:28chessguythis ruby-warrior codebase is actually really nice
22:31sethschessguy: hola! what's the context of the ruby-warrior codebase?
22:31chessguycontext?
22:31clojurebotcontext is the essence of humor
22:31chessguyha. thanks clojurebot
22:32sethschessguy: I just joined the channel, so just curious what I missed
22:32chessguyseths, ah, we were just saying that someone should port it to clojure
23:05technomancyjoshua-choi: replaca would be your guy for that
23:07joshua-choiThanks
23:07joshua-choireplaca: May I ask a question on Autodoc?
23:29gerryxiaohello
23:30gerryxiaowhy remove seq-contains?
23:32_atogerryxiao: probably because rich is sick of the discussion it triggered
23:32_atosee the google group
23:33gerryxiaook
23:41gerryxiaook, i have to define it by myself
23:43_ato,(some #{2} [1 2 3 4])
23:43clojurebot2
23:43_atogerryxiao: ^ or you can do it like that
23:43_ato(as long as you're not looking for false or nil)
23:47gerryxiao_ato: i'm using filter with it, but #() not support nested
23:47mmarczyk,(some {false true} [1 2 false :foo])
23:47clojurebottrue
23:47_atogood one
23:48mmarczykcgrand's :-)
23:48gerryxiao,(some #{"hell"} ["hell" 2])
23:48clojurebot"hell"
23:48gerryxiao,(some {"hell"} ["hello" 2])
23:48clojurebot1
23:49_ato,(filter #(some #{"hell"} %) [["summer" "autumn"] ["winter" "hell" "spring"]])
23:49clojurebot(["winter" "hell" "spring"])
23:49mmarczyk_ato: out of curiosity, do you have a preference w.r.t. the naming issue? unless you're sick and tired of it yourself
23:50mmarczyk,(let [=? (fn [& args] (fn [x] ((zipmap args (repeat true)) x)))] (some (=? 1 2 3) (range 10)))
23:50clojurebottrue
23:50mmarczyk,(let [=? (fn [& args] (fn [x] ((zipmap args (repeat true)) x)))] (some (=? 1 2 3) (range 0 10 4)))
23:50clojurebotnil
23:51mmarczykmaybe call that oneof?
23:53_atommarczyk: I think contains? was a bad choice (even if it is supposed to parallel get), seq-contains? just confuses things even more so. contains-key? and contains-val? are at least clearer. I don't tend to use either contains? or includes? in my own code
23:54_atousually use (get) with a default instead
23:54_atoand some
23:56rhudsonI like contains-key? and contains-val?
23:57mmarczyk_ato: same by me
23:58rhudsonmmarczyk: the advantage of your (=? x y z) over {x y z} is that it works where say x is nil or false?
23:58mmarczykI actually think contains? totally makes sense as a name for the current clojure.core/contains?, mind you
23:58mmarczykrhudson: right
23:58mmarczykit also totally makes sense as a name for what seq-contains? was to be
23:59mmarczykand that is precisely the reason why I'd maybe prefer not to have such a name in the core at all