#clojure logs

2009-07-17

00:55skalnikhow do I check if a sequence is empty?
00:55grrrtempty?
00:55grrrt,(doc empty?)
00:55clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
00:56skalnikthanks :)
00:56grrrtI find this website quite useful at times: http://java.ociweb.com/mark/clojure/ClojureCategorized.html
00:56grrrtit has all (most?) clojure functions by category
00:57skalniknice
00:57grrrtuseful if you're looking for something without knowing the exact name
01:01skalnikyay, coded euler problem 3 :)
01:04grrrtmetadata still has me confused. I wish I could do this:
01:04grrrt,(def t (ref 0))
01:04clojurebotDENIED
01:04grrrtoh allright
01:05hiredmanerm
01:05grrrtI wish I could do this: (def t (ref 0)) (with-meta t {:foo "bar"})
01:05durka42(let [t (ref 0)] (with-meta t {:foo "bar"}))
01:05durka42,(let [t (ref 0)] (with-meta t {:foo "bar"}))
01:05clojurebotjava.lang.ClassCastException: clojure.lang.Ref cannot be cast to clojure.lang.IObj
01:05grrrtexactly
01:05grrrtclearly I'm missing something
01:06hiredman,(let [t (ref 0)] (alter-meta t assoc :foo "bar"))
01:06clojurebotjava.lang.Exception: Unable to resolve symbol: alter-meta in this context
01:06hiredman,(let [t (ref 0)] (alter-meta! t assoc :foo "bar"))
01:06clojurebot{:foo "bar"}
01:06hiredman,(let [t (ref 0)] ^(alter-meta! t assoc :foo "bar"))
01:06clojurebotnil
01:06hiredmanbah
01:06grrrtheh
01:06hiredman,(let [t (ref 0)] (alter-meta! t assoc :foo "bar") ^t)
01:06clojurebot{:foo "bar"}
01:06durka42,(let [t (ref 0)] (alter-meta! t assoc :foo "bar") t)
01:06clojurebot#<Ref@bdc53e: 0>
01:06grrrtright. So why does with-meta not work then?
01:07hiredmanthere are several meta data related interfaces
01:07durka42that seems like a huge bug
01:07hiredmanwith-meta effectively returns a new object with the given metadata
01:07hiredmanwhich is not what you want in this case
01:07grrrthmm, I can see that being problematic for refs
01:07grrrtyeah
01:07grrrtpoint taken
01:08grrrtthx hiredman ! #clojure rocks.
01:20skalnikhm, how do I turn a character list into a string?
01:20grrrt,(str \a \b)
01:20clojurebot"ab"
01:21grrrt,(apply str [\a \b])
01:21clojurebot"ab"
01:21skalnikhmm
01:21skalnikthanks
01:21skalnikyeah, apply str worked
01:21skalnikmakes sense.
01:51grrrtweird... back in my java days I would work on a project, writing code, code and more code. Eventually I would sit back and look at the large amount of code I had written and I'd feel pretty impressed with myself.
01:51grrrtWith clojure, I write code and more code, but then when I sit back I think "hey is that all?"
01:51grrrtClojure is just *so* much more expressive...
01:51mariorzits all the lisp
01:53mariorzi think you work at ibm you get bonuses by kloc's though
01:53grrrtIn my last java job we had the rule "no methods with more than 15 lines"... In clojure I don't even have to *try* to stay under 15 :)
01:53mariorzif you*
01:53mariorz:P
04:49gko,1
04:49clojurebot1
04:49cp2,42
04:49clojurebot42
04:49jdz_strange, ain't it?
05:02cp2very
05:19gkoAny user of clojure-dev (for Eclipse?)
05:19gkoAny user of clojure-dev (for Eclipse) ?
05:45Fossihi. is there a pattern/helper for catching exceptions in lazy seqs?
06:17carkFossi : you may (doall your-sequence) and souround this with a try form
06:56Fossicark: that's what i figured. now i just need to find out why it's still not being catched. :)
06:57Fossiit's still a little arkward if your data is not a simple sequence, but a nested structure
06:57carkmaybe your sequence contains other lazy saquences ?
06:57Fossithat's what i suspect
06:57Fossiso a structure-walking helper would be helpful
06:58carkis this only for debugging ? or do you want this for production as well ?
06:58Fossii try to make compojure not throw exceptions to the frontend
06:58carka quick way to make your sequence concrete is to pprint it
06:59Fossiwell, that is a code walker :)
06:59Fossior data walker in that case
06:59carkright =)
07:00Fossishould be a pretty common use-case with web applications. maybe something i can give back upstream later
07:00carkwell usually with compojure you'll build vectors instead of sequences, and these are not lazy
07:01Fossihmmm
07:01Fossimaybe somethings wrong then on some other end
07:01carkalso it's no big deal if your exceptions fires later, you may change the error page i think
07:02Fossii searched a while in the docs and also code, but i could point anything like that
07:02Fossi*couldn't
07:03carkmhh
07:03carkthere must be !
07:03cark=P
07:03Fossiin fact i greped for "try" and there wasn't any in the code
07:03carkmy guess is that the web server library has the try
07:04Fossimight be, but since we run it on different once, that's not helping so much
07:04Fossi*ones
07:04Fossino english skills today ;)
07:05Fossithe error-pages look different on tomcat/jetty etc, so it looks like the exception just falls through to the container
07:06carkwell then talk directly to jetty
07:06Fossias said: because we run on different containers, that's not really a nice solution.
07:06Fossii'll decorating my app with some exception handling somehow
07:07Fossibut first i need to somehow catch any exception
07:07carkthen you'r bound to walk the data structures
07:07Fossiyeah, i guess so
07:07carkthough you know, it's a feature in composure to be able to work with lazy sequences
07:08Fossiyeah, especially for streaming a doall you be real bad (tm)
07:08carki remember reading a post on the google group about using this feature to update a page
07:08carkahwell you can't have the cake and eat it too =)
07:09Fossii'll put the issue aside for a while and fix the cause of the exceptions first. should be easy to provoke later on.
08:41Fossiwhat's the right way to 'un-keyword' something? so make :http "http"?
08:42Fossiprolly (key (map-with-known-values)), but if i don't know them? str?
08:42cark,(name :hello)
08:42clojurebot"hello"
08:43Fossiah, cool
08:46Fossiand the lisp-1 thing bites me again...
08:49carkhow so ?
08:50Fossihaving a variable called name in just that function
08:51carkahwell you'll get used to it, i came from common lisp and got used to it
08:52carki'm pretty sure that variable ought to be named customer-name anyways !
08:52Fossimore like server-name, but yeah
08:52cark=)
08:53Chouserheh
08:53Fossiit's a little weird when you don't know there's a function of that name around somewhere and rename, but miss one occurence
08:53rhickey"name" is actually the only name that gives me Lisp-1 problems
08:54Fossistill compiles, but then you get a mystical "can't cast IFn to String" or something
08:55ChouserI see people stumbling over others, but "name" is probably the most common.
08:57djpowellis print-method officially usable?
08:57djpowelli assume that print-method is just for creating arbitrary human-readable (?) print representations
08:58Fossii've had val key and map as well
08:59djpowelli've got a vector with 'type' metadata, and if I override print-method for that type, then it works, but I notice that it also overrides the behaviour of print-dup - which isn't what I want, cause my print-method output isn't readable
09:02cemerickI believe print-dup falls back on print-method impls...
09:16AWizzArdYes, cemerick is right. And one can add or overwrite those at runtime to get new printing behaviour.
09:22djpowellIs print-method output expected to be 'read'able? no?
09:23djpowellI was just worried that by providing my own, un-'read'able print-method for a meta-data 'type'd vector, it causes print-dup to use it, rather than to use the more suitable print-dup for vector.
09:25rhickeydjpowell: readability will only matter to a reader. The only time Clojure will print-dup/read it is when the type is a constant in code
09:33skalnikso I have a list of 20 booleans, how do I make sure they're all true?
09:34skalniknevermind :)
10:11fsodomkaChouser: please, don't forget about http://clojure-log.n01se.net/ -- logs are still not showing
10:11Chouserfsodomka: yes, thanks.
10:13fsodomkarhickey: I saw that in the chunks Clojure branch, you changed tests for 'range'
10:13fsodomkawhat is the correct behavior for range with fractions?
10:16rhickeyfsodomka: it will be that it returns values as long as < n
10:17fsodomkaso (range 2.5) is (0 1 2)
10:17rhickeyright
10:18rhickeyin the future
10:18fsodomkafuture feature :-)
10:18drewrclojure knows the future?
10:18drewrexcellent
10:18rhickeydrewr: clojure is the future
10:18drewreven better
10:19rhickeyor merely, clojure is its own future
10:19drewrself-referential future == single reality
10:24fsodomkarhickey: would it be ok, if I write Clojure tests separately in my own branch? using patches is really hard-to-work-with solution (at least for me)
10:24fsodomkacommits are transparent, so other people who write tests won't do the same thing/area
10:25fsodomkahttp://github.com/fsodomka/clojure/commits/testclojure
10:26fsodomkaonce in a while, we can just merge branches to get tests in
10:26Chouserthat merge can be done via a patch
10:28fsodomkayeah, that would work too
10:29rhickeyfsodomka: we're still working on a pull mechanism for contributions, but I'm not opposed for bigger things as they are pulled into clojure, like the test lib itself. I don't want it to be harder for people once their stuff gets included. OTOH, as Chouser says, if once in a while you run git format-patch it should reconcile when you resync
10:38fsodomkarhickey: the most important thing for me, was to be able to do check-ins. Now since I know that every check-in doesn't have to be a patch, I can work with it. I will contribute a bigger patch once in a while :-)
10:41Chousukefsodomka: there's no need to squash every commit into one if you use format-patch, though.
10:42Chousukefsodomka: a good way to do it is to clean up the history and commit messages, but keep every logical change as a separate commit, then dump them with git-format
10:43Chousukeer, format-patch :P
10:45stuartsierraHas anyone made progress on Clojure + OSGi?
10:46fsodomkaChousuke: how or what tools do you use to do this clean up? (I am new to git) Or what git functions do this clean up?
10:47Chousukewell, assuming you have all your commits in a separate branch, you can do an interactive rebase for example
10:47Chousukeit allows you to delete, reorder and squash together commits.
10:47Chousukeyou can think of each git commit as a single patch. it's pretty much how it works.
10:48Chousukefor example, if you are on master, do git checkout -b my-changes; then do a few commits, and try git rebase --interactive master
10:49Chousukethough, as rebase rewrites history, you should not use it on branches that you have shared with others.
10:50Chousukeit's a good way to get rid of all those "oops" and "typo" commits that happen during development, though :)
10:50ChouserI wouldn't personally worry too much about cleaning up the history, esp. in test directories.
10:51rhickeystuartsierra: I've made a bunch of changes that should help things there, but still need someone to define what exactly that means and what the expectations are
10:51ChousukeWell, I have perfectionist tendencies :P
10:52Chousukeif all your mistakes are local, there's no harm in cleaning up before sending a patch out
10:52ChouserBut don't squash commits together too aggressively. If you submit a big patch with lots of commits in it, and all the commits are good but there's questions on one of them, it's relatively easy to create a new patch with that one commit left out.
10:52drewrChouser: +1
10:53drewrsmall commits, isolated concerns
10:53Chouserthat way most of a batch of changes could get merged in without being held up by a queation about one of them.
10:53ChousukeI'm not advocating big commits. I'm against big commits. :P
10:53stuartsierrarhickey: thanks. I'm just thinking about modularity & dependency management in general, and OSGi seems to be the Java standard.
10:53ChousukeI just don't like seeing "oops" in the logs. :)
10:53Chousukeit makes bisecting less effective, too :/
10:53ChouserChousuke: yeah, didn't mean to suggest otherwise. Just pointing out the one part of "clean history" that I think is most important.
10:54Chousukesmall commits are also easier to revert. :)
10:55rhickeystuartsierra: there are 2 or 3 aspects I think - one is whether or not independently loaded Clojure code with imports of classes know only in their 'module' can work, That should be much better. The other is can modules have largely independent Clojure namespaces etc. This will require getting rid of the central ns repository. Third is exposing Clojure itself as some sort of modular 'service'
10:56rhickeydependency part a whole other can of worms, at least as far as incorporating Clojure ns deps
10:57rhickeystill have yet to have anyone describe adequately what it means to 'get Clojure running under OSGi'
10:59fsodomkathanks for the help with git - I will read up on it and play with it a little :-)
10:59stuartsierraI think, ideally, one would want to be able to distribute Clojure libraries as OSGi bundles, with declared dependencies.
11:00Chousukefsodomka: http://www-cs-students.stanford.edu/~blynn/gitmagic/ is a nice tutorial
11:03stuartsierraWhat I want is CPAN-style discovery with OSGi-style dependency management.
11:05cemerickosgi is a big, hairy pill to swallow just to get dependency mgmt (IMO of course)
11:05stuartsierracemerick: agreed, but what else is there for Java libs?
11:06cemerickmaven, ivy, jigsaw (forthcoming)
11:06cemerickthere's other less well-known ones *shrug*
11:07stuartsierraBut don't maven/ivy/etc handle only half the problem, finding & downloading dependencies?
11:07stuartsierraThey don't do nested ClassLoaders.
11:08cemerickright, no, they don't do that
11:08cemerickjigsaw does, but it's vaporware at the moment
11:08stuartsierraah, ok
11:09cemerickcourse, when JDK 7 hits, we'll have to see if it's going to play java.util.logging to osgi's log4j
11:10stuartsierraHmm, yes.
11:11cemerickI'm infinitely distrustful of anything that claims to do anything like CPAN. There's lots of them, but none of them work half as well as the original (partially due to code-rot, partially due to other platforms not being like perl, partially due to bad impls).
11:12stuartsierraYes, Rubygems, Python eggs, and Maven are all inferior to CPAN.
11:12stuartsierraI'm trying to figure out why.
11:13cemerickdo let me know when you've got it :-)
11:13cemerickI generally just throw my hands up in frustration and go do something else productive. I can't stand to deal with stuff like that.
11:13stuartsierraWell, I'm supposed to talk about it for Philly Lambda on Tuesday. :)
11:13cemerickah-ha. good motivation!
11:13stuartsierrayep
11:14cemerickCase in point, I've got a pylons app that I'd like to migrate to a different server. Unfortunately, all of its dependencies came out of the cheese shop (via easy_install/paste/et al), and it's apparently old enough that various versions of libs it requires are now gone from the cheese shop.
11:15cemerickold enough == 2 years :-/
11:15stuartsierraYes, I've had the same problem with Ruby.
11:16cemerickon the other hand, a colleague of mine had a 5-year-old perl script that used some CPAN modules, and he got the thing running in about 4 minutes.
11:17cemerickI wonder if it's just a matter of stack complexity. A perl script is a far cry from a pylons/django/rails app, never mind a J2EE or Swing contraption.
11:17cemerick...and I don't see a lot of big, frameworky perl apps floating around
11:18Fossiif you come up with something useful, the world's gonna kiss your butt
11:18stuartsierraPerl certainly leans more toward small, independent modules rather than large frameworks.
11:18Fossipackage management systems tend to be a bigger pita than the problem they are trying to solve
11:19cemerickstuartsierra: I wonder if there's any visualizations of the dependency networks of CPAN vs. the ruby/cheese shop/maven equivalents
11:19Fossiactually, the osgi stuff in eclipse is pretty nifty
11:20cemerickFossi: yeah, and the netbeans module system does well, too (I forget its name). Focus certainly seems to help.
11:20drewrsolves a direct problem in an ant-friendly way
11:20Fossiwell, ant itself is a pita :)
11:20Fossibut i guess nothing that a little lancet wouldn't fix
11:20cemerickWe used ivy for about 18 months, specifically because of its ant friendliness. Using it to track internally-produced dependencies ended up being too onerous, though.
11:20Fossididn't get around to actually try it out
11:21Fossibut ifs in xml make me sick
11:21drewrcemerick: really? I just have my own repository and structure things the way it makes sense
11:22drewrreally simple and without the complexity of maven
11:22stuartsierraSome info on CPAN dependencies: http://ali.as/top100/
11:22cemerickyeah, I totally agree. But for tracking dependencies between internal projects, it's way overkill
11:22cemerickvs. git submodules, say
11:23drewrcemerick: perhaps, but for the "please find and download these jars and put them in lib/" it's *awesome*
11:23cemerickyes, definitely
11:23drewri have an allergic reaction to putting jars in VCS though :-)
11:24cemerickwe've found that git submodule do the same job for us in a more straightforward way.
11:24Fossithen again, it would help if people released their jars with proper meta-data :D
11:24cemerickI did too, but we just create functionally-related dependency repos that hold *only* jars, etc.
11:24drewri suppose if I had a jar-only repo submodules would work ok
11:24drewrah, yes ;-)
11:24cemericke.g. a UI dependency repo, a jdbc one, a couchdb one, etc
11:24drewri do that for things like internal db auth info etc.
11:29Fossiis there a good style for (cond (some-test? some-param) some-param (some-other-test? some-other-param) some-other-param)?
11:30drewrFossi: condp could probably help there
11:31drewrit gives you more of a switch-style cond
11:32drewre.g. http://paste.lisp.org/display/80007,1/raw
11:33Fossii don't even understand what the api wants to tell me :)
11:33drewryou give it the test you want to perform on the var, then the var, then the possible result->action combinations
11:34drewr,(condp class 10 String :string Integer :integer :else :foo)
11:34clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$class
11:34Fossiyeah, but if i get it right the test must be the same then
11:35drewr,(condp class 10 String :string Integer :integer :foo)
11:35clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$class
11:35stuartsierradrewr: you want "instance?"
11:35drewr,(condp instance? 10 String :string Integer :integer :foo)
11:35clojurebot:integer
11:35drewrstuartsierra: thanks :-)
11:35drewrforgot it was a comparison not a predicate
11:37Fossiso at least if test is the same, that'll work
11:38Fossia kind of cond-let would be nice though
11:38Fossiah, seems like contrib has one
11:39drewrif the tests are unique then cond probably makes most sense, or a map with dispatch fns
11:47hiredmanor multimethods
11:47hiredmanclojurebot: multimethods?
11:47clojurebotmultimethods is what separates the boys from the men.
11:47hiredmanclojurebot: multimethods is also <reply>multimethods are awesome!
11:47clojurebot'Sea, mhuise.
11:48Chouseralso awesome: promises
11:50Fossihmmm. i wonder how a multimethod could work out
11:50hiredmanactually most likely pretty badly if you want cond-let
11:51Fossiproblem is i have a string and want to check whether i know a tag that's similar
11:52drewrFossi: paste an example of what you have and we'll try and clean it up
11:52drewrlisppaste8: url
11:52lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
11:52hiredmanwhat is a tag? a keyword?
11:53lisppaste8FossiFoo pasted "untitled" at http://paste.lisp.org/display/83752
11:53Fossinice pastebin
11:53hiredmanif you turn your string into a keyword you can construct a hierarchy which multimethods can use for dispath
11:54hiredmanoh
11:54drewrwhat does group-articles-by-tags return? articles?
11:54Fossithe tag is some other string i have stored previously
11:55Fossiwell, the group-article-by-tags isn't really relevant, as i just want the tags. just didn't refactor yet
11:55hiredmanseems fine
11:56Fossiif the (.toLowerCase tag-guess) is more expensive, i'd like to let it somehow
11:58hiredmanI doubt it's very expensive
11:59hiredmanjust some subtraction
11:59hiredman,(int \A)
11:59clojurebot65
11:59hiredmanaddition
11:59hiredman*cough*
11:59Fossino, it's not, but if i place another more expensive operation there
11:59Fossilike a fuzzy word-search or such
11:59hiredman,(char (+ 30 (int \A)))
11:59clojurebot\_
11:59hiredman:/
12:00Fossii guess map and dispatch functions would be best
12:16technomancywould love to get feedback: http://github.com/technomancy/swank-clojure/tree/master
12:18JomyootIS there magick with Emacs to make Clojure coding faster?
12:19Chouseryes, but you have to feed it your soul first
12:19technomancyfaster than what? =)
12:19replacaJomyoot: clojure-mode, of course, slime, and paredit are my magic pieces
12:19technomancyyes, paredit is indispensable
12:20replacaparedit converts parens from enemies to friends :-)
12:21JomyootHow about Textmate?
12:21JomyootAnytihng special for clojure?
12:22technomancythere's support, but last I heard it's fairly primitive
12:23danlarkinJomyoot: it's nowhere near emacs for editing clojure code
12:23Jomyoothow about la clojure?
12:25replacaJomyoot: don't know anything about la clojure
12:25Jomyootgotta see demo for paredit
12:26technomancyslowly
12:29replacaJomyoot: good thing to do is load it up, grab the cheat sheet and just play in an empty buffer. Then just start using it while writing code. At first it will be a little awkward, but pretty soon you'll get it in your muscle memory and not know how you did lisp without it.
12:29cemerickJomyoot: enclojure provides maybe 60% of what you'd get in emacs w.r.t. editing s-expressions, with the additional upside that you won't go stark raving mad over time, and you'll spend time doing work instead of tweaking emacs. :-P
12:29technomancyre: paredit: http://p.hagelb.org/paredit-outline.html
12:32RaynesLooks like the AjClojure guy is looking for a new name. He said so on Twitter. Twitter don't lie.
12:32Chouserheh
12:32Chouserwell, it's a good sign anyway
12:32Jomyootawesome
12:33cemerickactually, a couple of clojure wrappers around NetBeans APIs would make it possible to put together every emacs-y things within that environment.....
12:33technomancyfeedback welcome on that outline btw; I'm going to turn it into a screencast soon
12:35Raynes"AjClojure is a reimplementation of Clojure ideas using C# I should change the project name, AjSharpure?"
12:37cemerickugh, that's so tortured.
12:41hiredmanclojurebot: rhickey is also <reply>"The guy is totally awesome." -- Daniel Weinreb
12:41clojurebotIn Ordnung
12:41cemerickhiredman: where'd that quote come from?
12:42hiredmanhttp://stuartsierra.com/2009/02/22/its-about-the-libraries#comment-42489'
12:42hiredmaner
12:42hiredmanextra ' on the end there
12:42technomancyhe's an author of the CL spec, right?
12:42hiredmanone of them
12:43hiredman"Clojure is the future of Lisp" in there as well
12:43drewrhe wrote LOOP for crying out loud!
12:43cemerickwow, that's a helluva endorsement.
12:44hiredmanhe did sort of qualify it with "in a production environment"
12:44hiredmanbut that ain't much of a qualifier
12:44technomancyhiredman: especially coming from someone who likes CL over scheme
12:49technomancyclojurebot: multiple inheritance is http://www.piratejesus.com/nerdcore/nerdcore017.gif
12:49clojurebotAlles klar
12:50stuartsierraHe might have been referring to Scheme's use as an academic, teaching language.
12:53cemerickyeah, scheme still has an upper hand in that department, IMO.
12:53Chouserbut it's so mutable!
12:54cemerickthat's just an implementation detail
12:54cemerickI think PLT cons cells are immutable now
12:54Chousermaybe we need a teaching-clojure that keeps all the immutable goodness, but ditches all the JVM libraries in favor of cleanliness.
12:56cemerickhrm. Sounds like scheme. :-P
12:56Chouserhm
12:57Chouserscheme doesn't do mutable locals?
12:57technomancyChouser: just don't teach people how to use any construct involving a dot, and you'll be in good shape
12:57Chousersetf or whatever its called?
12:57technomancyno need to change the language. =)
12:57Chousertechnomancy: could be. I'm likely to have a chance to teach a kid programming and am trying to decide if clojure's a good fit or not.
12:58technomancycool!
13:00hiredmanI think a cool intro to programing class would be something like "learn lua by writing a lisp interpreter"
13:01hiredmanwhere lua is lua, python, ruby, javascript, or something else
13:02drewrheh
13:03hiredmanso you have a very directed course, and learn about the internals of a programing language
13:04hiredmanyou'd start by writing everything up in the host language, and has you get towards the end of the course you start replace bits and pieces in the implemented language
13:09hiredmanhomework "now that we have macros, replace special forms x y and z with macros
13:09danlarkinhard class if you're not used to FP!
13:09hiredmanI don't think so
13:10hiredmanI think it would be a great freshmen cs class
13:11Chousermany freshmen cs students at my school were still struggling a bit with simple loops half-way through the semester. a macro might be a lot to ask.
13:12cemerickwe've all had our heads screwed up by typical CS stuff, when FP really isn't that hard
13:12cemerick...says the guy who has a particularly screwed-up head
13:13cemerickloops are hard -- or, really, mutability is hard.
13:13hiredmanChouser: someone somewhere will always stuggle, best to set the bar high so everyone can struggle together :P
13:13ChousukeThere certainly exist people who really seem to be unable to learn programming.
13:14ChousukeI don't know if it
13:14Chousukeit's because of the imperativity or not, but hm
13:15danlarkinI don't remember where I heard this, but supposedly programming 101 professors fully expect 50% of their students to not grasp the material
13:15replacaafter reading through the source of enlive, Christophe has me using -> all over the place. Dunno if it's a good idea or not.
13:15technomancydanlarkin: that was probably a lot worse back when programming was seen as a way to get rich
13:15Chousukereplaca: heh
13:16ChousukeI like ->, but it's certainly easy to abuse.
13:16replacayeah, I haven't really figured out "best practice" yet. I'll keep using it til I decide where the limit is :-)
13:17ataggartMy intro CS course used a pseudocode language the whole semester. I got a D. The second semester was in java; I got an A. Not sure what to make of that.
13:17replacait does have a nice "pipeline-y" feel
13:17hiredmaneww
13:17hiredmanpseudocode
13:17danlarkintechnomancy: heh, probably. From my experience pretty true, too. Lots of confusion about where to put semicolons versus squiggly brackets. C++ isn't the greatest intro language, granted, but still
13:18technomancyunless you count languages that are bad on purpose
13:18danlarkinbrainf**k :)
13:18replacaataggart: that's like trying to teach kids numerical analysis before 2 + 2 = 4. Noble, but flawed
13:18hiredmanmacros are actually pretty simple from the perspective of the implementing language
13:18Chousuketechnomancy: is Visual Basic bad on purpose? :P
13:18ataggartlol
13:19hiredmanthats why I am saying you start with something like lua
13:19technomancyChousuke: teaching VB to beginners might be better than C++ because they'll realize how horrible it is sooner.
13:19hiredmanfunction some-name (args) do-stuff-here end
13:19technomancywith C++ they'll just keep banging their heads against the wall thinking, "maybe I'm just not *smart enough* yet!"
13:19hiredmandirt simple readable syntax
13:20Chousukehiredman: macros are very simple in principle. just a function of data structures to another data structure. I guess it's the details of effectively producing data structures that are also code that trip people up.
13:20hiredmanChousuke: it's not liked they'd have to write complicated macros, just replace a few previously (and careful selected for this purpose) "builtins" with macros
13:21danlarkinI think it's the runtime vs readtime that is tough
13:21Chousukehiredman: like the common misconception that ` is somehow a special macro thing.
13:21Chousukehiredman: or the hygiene issues when generating code. (which are actually completely separate from macros, as a concept)
13:22hiredmanChousuke: all of which would be skipped over
13:22hiredmanwhich will make a horrible lisp interpreter, but this is a freshmen cs class
13:22Chousukebut then you would not be able to write very useful macros :/
13:24hiredmanphp.lisp is about 390 lines of php
13:26hiredmandoesn't seem unreasonable for a quarter's worth of work
13:27ChousukeI saw a C lisp implementation somewhere once that was a single file and about a couple hundred lines of code.
13:28Chousukeit didn't have garbage collection though :)
13:28hiredman:|
13:28hiredmanyou could always throw in boehm
13:28Chousukeheh.
13:28technomancymine's 754 LOC
13:28technomancy(of Ruby though, major cheating)
13:30hiredmanphp.lisp uses php arrays as lists, which is sort of cheating I guess
13:30Chousuke(loop [] (print (eval (read))) (recur)); Cheating? Never.
13:30Chousukenot very useful though :(
13:31technomancyhiredman: I tried that in mine; it took me weeks to back myself out of that mistake
13:31hiredmanthe cool thing about implementing a programing language as the class goal, is there are all sorts of doodads you can fiddle and adjust and add in and take out
13:32Chousukeas a final assignment you could require them to write some simple program using their interpreter :P
13:32hiredmanif, god forbid, the class is burning through the material, just throw in type-checking
13:33hiredmanChousuke: yeah, have them solve euler problems using it :P
13:59rhickey_http://clojure-log.n01se.net/ down since 7/11?
14:00rhickey_er, not down, but not logging?
14:01cemerickyeah, hopefully there's data somewhere. I was unceremoniously lost my connection yesterday in the middle of the binding discussion.
14:02rhickey_cemerick: yes, we lost you - you were saying?
14:02cemerickoh, I don't remember what my next step was
14:03rhickey_well you should now have everything you need for a neat with-binding solution
14:03cemerickyeah, that'll certainly work.
14:03rhickey_I got the batch-editibility fully going in the persistent vector last night and this morning - the perf is within 20% of ArrayList
14:04ChouserI've got the logs, but they're in the wrong format. I hope to get the site up this weekend.
14:04cemerickI thought about it for most of the night, and it seems like the general solution (short of copying bindings on the propagation of every value) is to add some functional demarcation to my cells impl. Right now, it's very open-ended, in that a particular "dataflow" can be added to at any time. Very flexible, but can lead to *really* large transactions (with-binding or not).
14:07rhickey_I'm still on the fence about read access to the mutable colls, e.g. there's nth! but not seq
14:07cemericke.g. over *here* (/me waves his hands to the left) you've got a nest of cells that are UI-related, and over *there* you've got N other nests, each related to particular functional domains. When a value needs to be propagated from one nest to another, that should probably be a send to a "gateway" agent, which allows for some reasonable decoupling.
14:07rhickey_cemerick: sounds like a good idea
14:09rhickey_what's with all the "Whoa! I was listening to Sunn O))) and Rich Hickey started talking in the background and the music became creepier than before!" tweets?
14:10cemerickrhickey_: looks like they're all spammer accounts.
14:10cemerickpretty odd confluence, certainly
14:10cemerickodd bot behaviour
14:13cemerickrhickey: with-binding will solve direct future, pmap calls, etc., but it won't help with delays, etc., right? That'd require two calls -- one to capture the current bindings, and another inside the delay to apply them...I think.
14:14cemerickach
14:15cemerickheh, my proggit submission re: Weinreb's comment got buried, not surprisingly
14:29tashafahello.clj
14:29Raynes(println "What's up?")
14:30tashafahelp... can some please explain how preduce works
14:31Hun,(doc preduce)
14:31clojurebot"clojure.contrib.datalog.util/preduce;[[f data]]; Similar to merge-with, but the contents of each key are merged in parallel using f. f - a function of 2 arguments. data - a collection of hashes."
14:31tashafaespecially the (f base an-element-from the collection)
14:32hiredman~def preduce
14:36tashafaah... it was the fact that it uses a reduce without an inital value in the source of preduce that was tripping me up
14:46sh10151if: Clojure installation step failed: git clone git://github.com/kevinoneill/clojure.git
14:46sh10151is this a temporary situation or is my code out of date?
14:46sh10151from clojure-install in clojure-mode
14:47sh10151the git error is "no matching repositories found"
14:48hiredmanuh
14:48hiredmanclojure moved to git, so there is an official github repo
14:48hiredmanclojurebot: clojure?
14:48clojurebotclojure is far closer to perfection then python
14:49hiredmanclojurebot: github
14:49clojurebothttp://github.com/richhickey/clojure/tree/master
14:52Chousukethen :P
14:53Chouserhehe
14:57hiredman:/
14:57hiredmanclojurebot: literal [?] clojure
14:57clojurebot11
14:57hiredmanclojurebot: literal [1] clojure
14:57clojurebotcheating
14:58hiredmanclojurebot: literal [7] forget
14:58clojurebotnothing defined
15:01sh10151hiredman: so clojure-mode needs an update?
15:01hiredmansh10151: dunno
15:01sh10151huh
15:02sh10151this was easy three months ago :-D
15:02hiredmanwhere are you getting clojure-mode from?
15:02sh10151git://github.com/jochu/clojure-mode.git
15:02hiredmanhttp://github.com/technomancy/clojure-mode/ seems to be the place
15:03sh10151i'm out of it for a while
15:03sh10151and everyone gets delusions of grandeur
15:03Chousukejochu's is the original but techno's is more up to date.
15:04sh10151what do you use?
15:04sh10151i understand emacs is an acquired taste
15:04hiredmanvim
15:04sh10151ah
15:04sh10151I think that's not popular at work either
15:04Chousukevim is an acquired taste as well :P
15:04cschreinerbbbut I use emacs, and I love it
15:04hiredmanI am not opposed to emacs per-se
15:04sh10151IDEA and Eclipse seem to be the systems of choice
15:04hiredmanI just cannot be bothered
15:05rsynnottsh10151: for clojure?
15:05ChousukeI like both so I use viper with emacs.
15:08sh10151I'm trying to get my notebook set up with Clojure for a little presentation I'm doing
15:08sh10151"Clojure as an Interactive Java Shell"
15:29ti381IDEA and Emacs make me chuckle for clojure work
15:31tashafa~def memoize
15:32tashafahow do you print the source of a fn from the repl again?
15:34Chouser(source memoize) -- that's clojure.contrib.repl-utils/source
15:35tashafaah
15:35tashafathanks Chouser
15:46sh10151this clojure-mode clojure-install is giving me all kinds of trouble
15:47sh10151i think i will just do it all manually
15:49ksclarkehmm, I have clojure-contrib in my classpath but when I try to use mmap I get: "Unable to resolve symbol: mmap in this context (NO_SOURCE_FILE:6)"
15:49ksclarkeI'm a complete newbie so I know I must be missing something obvious
15:49ksclarkethe require for mmap worked fine
15:50stuartsierra"require" only loads the library. If you want to access it without a namespace, load it with "use".
15:51ksclarkeah thanks!
16:05rzoomanyone have any advice on passing an array of java strings to a java method?
16:06rzoomhow would I construct a Java array of Java strings?
16:06rzoom(to-array ["abc" "def"])
16:06Chouser,(into-array ["abc" "def"])
16:06clojurebot#<String[] [Ljava.lang.String;@1673ef7>
16:06Chouserwhat are you starting with on the Clojure side? a seq of strings?
16:07hiredman,(.toArray ["a" "b"])
16:07clojurebot#<Object[] [Ljava.lang.Object;@11e356b>
16:07hiredman:(
16:07rzoomthanks!
16:08rzoomto-array wasn't quite working
16:08Chouserrzoom: right. to-array returns a Java array of Objects
16:09Chouserhm. I mean a Java array-of-Objects
16:09rzoomahh.
16:09rzoomwell, i just added create-ssl-server to contrib server-socket
16:10Chousernice!
16:10rzoomwill have to send it to the maintainer
16:10Chouseryep. You've seen http://clojure.org/patches ?
16:10rzoomi have now. reading ;)
16:25hiredman~works on my machine
16:25clojurebothttp://haacked.com/images/haacked_com/WindowsLiveWriter/IConfigMapPathIsInaccessibleDueToItsProt_1446B/works-on-my-machine-starburst.png
16:31rzoomok, showing my Java ignorance: is ant multithreaded?
16:32rzoomoh, i see that it can be.
16:40stuartsierratypically it isn't
16:41rzoomyeah, looks like the <parallel> tag is needed
17:41rhickeyok, if you want to play around with batch editing of vectors, the code is in the chunks branch: http://github.com/richhickey/clojure/commits/chunks
17:42rhickeylisppaste8: url
17:42lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:42lisppaste8rhickey pasted "batch editing of vectors" at http://paste.lisp.org/display/83767
17:47mebaran151is it possible to change the size of the agent thread pool?
17:47hiredmanthere are two agent threadpools
17:47rhickeymebaran151: the send-off pool grows as needed
17:52mebaran151alright thanks
17:58Chouserrhickey: looks pretty clean considuring the mutability
17:59rhickeyChouser: the idea is, write it the correct way, if it becomes your bottleneck, add mutable, !, !, !, immutable
18:00rhickeysome open questions are - right now I disallow normal nth/get etc on the mutable version, must use nth!/get! etc
18:00rhickeyalthough normal count works, hrm
18:01rhickeyI don't want these things to be very useful if 'leaked'
18:07Chouserright
18:08ChouserI think that's valuable property
18:08rhickeyI wonder how much pressure there will be for seq
18:08rhickeyI imagine these used mostly for building/creating, but people might hang on to them for an extended time
18:09hiredmanmight be useful to have scoped mutability
18:09rhickeyyou could in fact use one as the value of an agent, simply (immutable @agt) whenever you want to read, as send ensures serial access
18:10Chousergotta go. I'll try to work on irc log later
18:10rhickeyChouser: thanks
20:29Chouseroh, I just got what you were saying -- leave it mutable and each time you need to read use (immutable @agt)
20:31rhickeyright
20:31rhickeynot quite sure that will work, since there is not threading control at all
20:32rhickeyin fact, will not work
20:35Chouseroh, because a flying read might break while the agent it updating the value?
20:35rhickeyimmutable copy must be given by same thread as mutation
20:37Chousermust be same thread, or just serialized with mutation?
20:37rhickeyserialized, but not really a good story
20:37Chouseryeah
20:38Chouserthin plot, no character development.
20:38rhickeyunhappy ending
20:40Chouserand agents were the best shot at leaving mutables hanging out in public -- sharing them other ways just gets worse
20:41rhickeythere might be some variation of that idea though
20:42rhickeynot too important
20:42rhickeythe primary use is birth/batch
20:43Chouserare you worried about abuse? I'm not really, esp. if nth and seq fail.
20:44ChouserI'm sure you've thought of this, but it's easier to add capability than to take it away. So if seq and nth fail for now, and people have valid use cases for them, it'll be easy enough later to allow them to work.
23:36duck1123How do I specify code to be run as a destructor when using gen-class
23:36Chouserdoes java even support that?
23:37duck1123destructors? I thought they did...
23:37ChouserI seem to recall something called "finallize" but that it wasn't very reliable.
23:38duck1123hmm... it appears you're right
23:39duck1123I'm trying to open a connection to a xmpp server when my http server starts, and I want to make sure things are cleaned up when it shuts down
23:41duck1123unfortunately, compojure's defservice returns immediately. otherwise I would use the with-connection macro I wrote
23:42Chouserhm. maybe compojure has some kind of shut-down hook?