#clojure logs

2009-10-30

00:00gerry_ok,not use println
00:02gerry_not use println is 35 vs 44
00:02Knekksee?
00:03gerry_about 20% boost
00:03gerry_i thought it should be > 40% :)
00:04Knekkincrease to 500k iterations? Does your ratio hold?
00:05gerry_let's try
00:06gerry_206 vs 256
00:06gerry_still about 20%
00:06Knekkok
00:07Knekkdunno. you should ask someone who knows the internals about your missing improvement
00:07gerry_AwizzWard?
00:15gerry_chouser's patch still not used yet?
00:20RaynesApparently, the bleeding edge VimClojure works fine for me. It's a little inconvenient to have to have any file you edit on the classpath, but I'll manage.
00:20nrootHi I am new to clojure, but I have some experience in Erlang and Map reduce. The reason I am learning clojure is because it is said that it is build for concurrency from ground up.
00:20nrootMy question is what is it parallelism model, is it thread based ? Meaning it will only work on machine with large number of cores or is it map reduce like meaning it can work on large number of machines with each having 1 or 2 cores.
00:20tomojoh, damn
00:21tomojthe error I was having with c.c.http.agent was because I changed something in there to intentionally cause an error so I could see the backtrace, and forgot to change it back
00:21gerry_oh,that's 217 vs 304
00:22gerry_about 40% great
00:22tomojnroot: clojure's concurrency model is based on threads
00:22tomojit doesn't do anything at all to help you with distributed computing
00:23nroottomoj: so it can not exploit working on something like google app engine
00:23tomojin fact rhickey thinks it's outright impossible to do what clojure does for distributed computing
00:23tomojI dunno anything about google app engine
00:24gerry_minibenchmark result: deftype about 40% faster than defstuct
00:24tomojif you have a multi-threaded application clojure will help you deal with the problems that usually arise with multi-threaded applications and state
00:24nroottomoj: thanks
00:24technomancytomoj: "outright impossible" is strong wording... he's just said that it doesn't belong in the core language
00:25tomojno, he said it's "doomed"
00:25tomojI'm not talking about distributed help in general, just that he said trying to do what clojure does for multi-threaded state in a distributed way is doomed
00:25tomojcertainly we can build some clojure tools that help with distributed computing
00:26technomancyoh sure, but that's kind of tautological.
00:26technomancy"providing tools to help with shared mutable state is impossible when there's no shared state."
00:27tomojheh, yeah
00:27tomojbut I'm sure he didn't mean a tautology when he said it
00:27tomojI just am too noob to say it right
00:27tomojthe statements I'm talking about are in http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
00:27technomancyhehe
00:27chousernroot: There are several projects that are working to help make it easy to distribute Java work across multiple machines
00:28nrootchouser: like ?
00:28chouserClojure can take advantage of some of these already, and will do more in the long run
00:28chouserThe one that comes to mind is Hadoop, but there are others.
00:29chouserI think there's also one that may be pure Clojure. http://github.com/amitrathore/swarmiji
00:30leif-pI believe one company is already using clojure with Hadoop + Cascading for their data processing.
00:31chouserBut Clojure itself is more concentrated on the multicore/multithreaded model where you can read memory more cheaply than passing messages to another process, and don't have to worry about the same failure cases as distributed systems.
00:31woobynroot: clojure runs fine on app engine
00:32woobynroot: although the STM is busted because of the way google deploys stuff
00:33tomojmy neural networks where each node has a seq of references to other nodes: buggy
00:33woobynroot: http://elhumidor.blogspot.com/2009/04/clojure-on-google-appengine.html
00:33tomojmy neural networks where each network is a single immutable value: not buggy
00:33tomoj:D
00:33woobytomoj: what kind of network?
00:34tomojlike, sum the inputs and run them through a sigmoid
00:34technomancyterracotta, JMS, AMQP
00:34technomancyAMQP is language-agnostic
00:34technomancybut works great with Clojure
00:34technomancyyeah, that wraps AMQP actually
00:34technomancyanyone want to test out my swank-clojure 1.0 release candidate?
00:34technomancyshould be an even easier install than M-x clojure-install
00:34technomancygoogle disallows new threads, so STM is not that interesting without that
00:34woobyi was working on something like that the other day, from turing omnibus
00:36tomojmine are fully lazy (i.e. cache each node's activation in an edge before passing it on to the next node) to support abitrary topologies
00:36tomojworking on implementing ken stanley's NEAT
00:37woobytomoj: i would be very interested in seeing that, if you're willing to throw it up somewhere
00:37piccolin1technomancy, heck yes!
00:38tomojwooby: it will be thrown up soon once I iron out a couple problems
00:38woobyawesome
00:38tomojeventually want to do HyperNEAT
01:34Clipswww.socialchat.co.uk or irc.socialchat.co.uk
01:34ClipsJoin now :) Swearing allowed
02:02tomojis there a better way to write (fn [a b] [a b]) ?
02:03hiredmanvector
02:03tomojaha
02:03tomojthanks
02:03hiredman,(vector 'a 'b)
02:03clojurebot[a b]
02:03tomojI knew of vec, but not vector
02:04hiredman,((juxt (comp first list) (comp second list)) 'a 'b)
02:04clojurebot[a b]
02:04tomoj,(map vector [1 2 3] [4 5 6])
02:04clojurebot([1 4] [2 5] [3 6])
02:04tomojnifty
02:05tomojjuxt is cool too
02:32qedman it sucks that have this friend who who goes out of his way to refuse that clojure is worthwhile
02:32qedthat I have this*
02:33qedas usual, our drink turned into a discussion about programming, and i bring up how I think clojure is sort of the future programming language in that many of its features will be implemented into the mainstream at one point or another
02:34qedhe is of the mind that if you aren't writing C you're wasting time, so I bring up abstraction and how it's important, but he seems dead set on this notion that concurrency and all of the things that clojure brings with it are glitter, without substance
02:35qedcan anyone offer me anything in the way of perspective?
02:35qedam i being too bold when it comes to clojure?
02:37qedit just seems like the most elegant language ive ever used, how could anyone who hasn't used it have any idea?
02:37arbschtqed: if I were you, I'd have focused on enjoying the drink and not arguing about programming :)
02:37piccolinoYou'd be surprised what some people just can't be convinced of.
02:38qedarbscht: good advice, good advice, sigh, im not trying to convince so much as im just trying to gain some sort of recognition
02:39qedhe's so ill-informed, though, that when i try to explain certain concepts he just dismisses them because he doesn't know them
02:39arbschtqed: write some useful code, it is more satisfying than recognition of the merits of a system in the abstract
02:39piccolinoPunish him by letting him remain ignorant.
02:39qedpiccolino: haha, arbscht: no doubt
02:39tomojqed: has he written a multi-threaded C program?
02:40qedtomoj: he claims to know mutexes and thread locking, but i highly doubt he knows what lies in that clusterfuck
02:40tomojah
02:40tomojhave him try to write ants.clj in C
02:40qednow that is a gauntlet! :)
02:41tomojkeeping the idea that each ant runs on a separate thread
02:41qedhis main argument was this:
02:41tomojI guess maybe you could do it OK since ants.clj is not very complex
02:41qedthe difference between making your program concurrent and running it fast with C is negligible
02:41tomojI have never done much multi-threaded stuff
02:41tomojhahaha
02:42tomojdid you remind him about the end of moore's law?
02:42qedtomoj: lol, omg that would have destroyed him
02:42qedi wouldn't have a friend anymore if i reminded him of *that*
02:42qedhe would have been so butt hurt he probably would have stormed off with a curly bracket and a semicolon
02:43tomojif program B runs faster than program A by a constant factor, but B only runs on one core, and A runs on 64 cores...
02:44tomojI actually only have one core here :(
02:44tomojbut it pretends like it's two cores or something strange like that
02:45tomojanyway I guess pretty soon everyone will have 8+ cores?
02:45qedtomoj: i just sent that to him via im
02:45qedhis response is: "that's really a kernel thing, the kernel schedules the usage of all the processors"
02:46qed"if you create a thread it will be automatically scheduled and used on any available processors"
02:46qed"it's not like your code has to be any more complex"
02:47tomojI conclude he has never done any serious multi-theaded programmming
02:47tomojthough neither have I, so what do I know
02:48tomojbut the problem is, of course, these threads will want to access the same memory (in C)
02:49qedhis response: "yeah that's why you write thread-safe code"
02:49tomojexactly
02:50tomojthe question is HOW
02:50tomojin clojure it's easy
02:50tomojin C...?
02:50qedhe's clueless and stubborn
02:51tomojeh
02:51qedi know him very well, he really lashes out against anything he doesn't know already
02:51tomojguess it's like the Blub programmer
02:52tomojeverything I've ever done, I've been able to do with ruby/clojure/CL/java, so anything else is useless
02:54tomojor rather, not any MORE useful than what I've got
02:54qedhe just told me: "build me an operating system in clojure"
02:54hiredmanqed: I will
02:54hiredmanjust give me some time
02:55woobyclojurebot nearly is
02:55hiredmanhttp://research.sun.com/projects/dashboard.php?id=185
02:55woobyi saw that the other day, so awesome
02:55hiredmanhttp://research.sun.com/spotlight/2008/2008-08-13_maxine.html
02:55tomojhmm
02:56hiredmanreally, I want maxine, the guest os thing is just kind of cool
02:56tomojis the test of a programming language's usefulness whether or not one can build an OS using the language?
02:56hiredmanI know headius is looking at maxine for jruby
02:57qeddude, he just logged off: "but seriously, don't fucking tell me i have no perspective because i'm not balls deep in some obscure shit"
02:57qed"you're pissing me the fuck off"
02:57qed /quit
02:57tomojhehe
02:57qedlol, one less friend
02:57qedmore time to code
02:57tomojdevelopers can be quite defensive
02:58qedyeah, he's totally on that game, i welcome whatever i can find that's new and weird and obscure and challenging, etc.
02:58qedit's just my nature
02:58qedi truly don't understand the other end of that spectrum
02:58qed"what i have is good enough for anyone!"
02:58qedwtf?
02:58qedno. it's not.
02:59qedi think what pisses him off more than anything, is that he has a veryyyyy formal CS education, but he knows about the same as me
03:00qedso he feels like he has this platform to accept or reject ideas i propose when it comes to CS
03:01qedlike he is the high court of CS, and his decree will be the law of the land
03:03qedidk, just another typical CS student who believes they wont need to learn anymore after they finish college
03:05qeduniversities are filled with so much garbage these days
03:05qedsigh, im rambling
03:05qedsorry all
03:21sfuentesqed: that's a bit extreme there
03:22qedsfuentes: ?
03:22qedthe university bi?
03:22qedbit?
03:22qedI just meet a lot of undergrads these days who have no passion--
03:22sfuentespersonally, i think a lack of a software engineering curriculum is at work
03:22qedthat's certainly true
03:23qedit's like this weird hermaphrodite balance between djikstra and kay
03:23tomojall of the CS majors I know are shitty developers
03:23qed(curriculum-wise)
03:23qedtomoj: same here
03:23qedlike practically inept
03:24tomojI like the CS curriculum just fine, though
03:24tomojI enjoy abstract stuff that has no practical application :)
03:24qedthere is less than 20% of CS majors I've seen who could hack
03:24qedlike-- really... hack.
03:24arbschtirc channels are filled with garbage these days; I think a lack of coding is at work ;) (does clojure make programming useful things so trivial that you have time for this?)
03:25qedarbscht: bourbon, ginger beer, and bitters -- will do this to a man
03:25tomojsomeone just peed off the balcony above me
03:25qedtomoj: welcome to halloween'
03:25qedi live in madison, wi
03:25sfuentesi think there should be a "software school" (similar to law and medical school) after one gets their CS degree.
03:26qedsfuentes: that's a really good idea
03:26tomojnot sure you can really learn much without actually doing
03:26sfuentestomoj: but you *will* be doing
03:26tomojif it's a school, you won't
03:26qedour CS program emphasized group work to get the "software development" "real world" scenario
03:26qedbut it was BS
03:26tomojunless the school is really just an internship
03:27qedhalf the time your partner wouldn't do anything
03:27qedand you'd pull the team
03:28tomojI wonder how many clojure dev shops there are
03:28qedprobably not many
03:28qedid love to be a part of one
03:28sfuentestomoj: Residency training
03:29tomojyeah, isn't that what an internship is?
03:30sfuentesinternships are very general
03:30sfuentesnot very supervised
03:30sfuentesbut yes
03:31tomojthey can be useless I suppose
03:32tomojI work for the IT dept of my university and there's very little source control, absolutely no testing, and absolutely no pair programming
03:32qed:X
03:32qedi have to go to bed, it's late
03:32qedbut we will continue this tomorrow :)
03:33qedciao tomoj, sfuentes
03:33tomojco'o
03:34sfuentesnight qed
03:34sfuentestomoj: sad to hear
03:34sfuentesthen again its IT
03:35tomojI am now wondering whether the liquid that just fell from above onto my shoes is piss or a drink :(
03:56arbschttomoj: don't evaluate it, it might have side effects!
03:59tomojafterwards someone said "oh I didn't realize there was a drink next to you sorry" so I think I'm OK
04:58yasonIs Clojure good at optimizing out multiple funcalls and replacing them with the value returned from a single funcall?
04:59yason(let [x (compute-something)] (list x x)) versus (list (compute-something) (compute-something)) ?
05:03cgrandyason: no because clojure can't generally know if a function is pure
05:05yasoncgrand: No metadata for annotating pure functions? Ok, so (let ...) it is.
05:05yasonAvoiding let would've made a more beautiful look though, in this case :)
05:06cgrand(repeat 2 (compute-something))
06:18AWizzArdHow can I type hint a parameter to be a function object?
06:21AWizzArdah okay, it's #^clojure.lang.Fn
06:28AWizzArdmorning
06:31modulushey, some good doc to read on the deployment of clojure and ides and stuff?
07:06KjellskiGooood, morning!
07:24AWizzArdHi the Kjell.
07:43rhickeydeftype/defclass print is up - thanks to chouser!
08:01blackdog_hi, in slime/swank is there a way to add a directory of jars all at one time to the classpath, rather than enumerating each
08:05_atoblackdog_: (setq-swank-extra-classpaths '("~/somewhere/*"))
08:06blackdog_ah thanks :)
08:06_atoassuming you're using java 6, I don't think it works in earlier versions
08:06blackdog_yes
08:23eevar2with java 1.5 you'd do (setq swank-clojure-extra-classpaths (cons "/opt/clojure-contrib/clojure-contrib.jar" (directory-files "/opt/clojure-libs" t ".jar$")))
08:23eevar2damn old macbook.. :/
08:32AWizzArdchouser: cool, thanks for the printing
08:33AWizzArdrhickey: is the PAR branch (git) dependend on some external libs? Can it get merged with the NEW branch?
08:34rhickeyAWizzArd: it depends on jsr166y
08:35AWizzArdhttp://www.jcp.org/en/jsr/summary?id=166
08:35rhickeythe dep is here: http://github.com/richhickey/clojure/downloads
08:36rhickeyhttp://cloud.github.com/downloads/richhickey/clojure/jsr166y.jar
08:40AWizzArdDo you think the .class files from that .jar may get included in future versions of Clojure?
08:49rhickeyAWizzArd: jsr166y is not compatible with Java 5
08:51AWizzArdI see
08:53chouserbah
08:53rhickeychouser: good morning to you too :)
08:53chouserrhickey: sorry about the load order. I forgot to actually try building clojure before putting the patch up.
08:54chouserheh. good morning. :-)
08:54rhickeynp
08:54notallamajsr166y.jar seems to be missing things. namely, jsr166y.forkjoin.*
08:58rhickeynotallama: compared to what? there may have been some refactoring since I snapshotted, but that is all that par needs
08:58rhickeyforkjoin was moving target at the time
09:00rhickeyso, the new deftype/defclass theory is, if you want IPersistentMap support generated, just specify it in the interface list but don't implement it
09:00rhickeyby default only hash,equals, metadata and lookup are included
09:02notallamarhickey: compared to what parallel.clj is asking for. (import '(jsr166.forkjoin ...))
09:03rhickeynotallama: parallel.clj was written to a very old jsr166y, available here: http://clojure.googlegroups.com/web/jsr166y.jar
09:04rhickeythe old and new libraries are incompatible, that was the last version to work with Java 5
09:05rhickeyso par will replace parallel at some point
09:05hoeckrhickey: what about adding IObj/IMeta to the list of magically implemented interfaces?
09:05rhickeyhoeck: meaning no default generation?
09:05hoeckrhickey: or is this a must so that the type tag works?
09:06hoeckrhickey: yes, say for some extreme lightweigt types, like database-rows
09:06rhickeywho doesn't want metadata?
09:06notallamaoh, so parallel isn't par. that explains things
09:07rhickeyhoeck: seems like a premature optimization
09:07rhickeyas database rows flow through an app, you sure might want to remember what table they came from etc
09:07hoeckrhickey: okay, guess I will measure then :)
09:07rhickeyhoeck: certainly only a space issue
09:08hoeckrhickey: ok, point taken, but whats the reason to optionally implement IPersistentMap?
09:09rhickeybut there will at lest be a consistent construction story, regardless of which interfaces are implemented - fields you asked for + meta + extmap, the latter 2 defaulting to null
09:09AWizzArdBtw, what advantages does defclass offer over deftype?
09:10chouserAWizzArd: named class and (maybe) more speed
09:10rhickeyhoeck: IPersistentMap brings a ton of semantics - it essentially makes your type/class a collection - collection, Counted, Seqable, associative etc
09:10AWizzArdchouser: named class - so one can add type hints in functions that take defclassed objects?
09:10chouserI noticed defclass only made one ctor.
09:11chouserAWizzArd: well, so that Java can use it by name, find the class file by name, etc.
09:11rhickeychouser: yes,I need to fix that, copied from deftype
09:13chouserI couldn't see where the ctors were specified
09:13rhickeydefclass docs
09:14chouserI mean I didn't see where create-defclass* was told what ctors to create so I thought maybe it was all in Compiler ...and promptly stopped digging.
09:15rhickeychouser: yes, compiler does the ctor from fieldslist supplied to defclass*
09:15chouseryeah, ok. will deftype classes get 2 ctors also, or will there have to be another arg to defclass*?
09:17rhickeychouser: no, there's only one ctor, 2 factory functions - the docs are wrong because I copied factroy-ctor from deftype docs to defclass docs
09:18chouserahhhh. ok.
09:18rhickeyright now there isn't accessibility to the deftype ctor for code not inside deftype
09:18chouserright
09:18rhickeybecasue the actual classname doesn't escape
09:19rhickeyso, dissoc of base field --> ordinary map not of type?
09:19rhickeyI like that better than error, if e.g. get of non-present is going to return nil
09:21chouserdoesn't it seem a little scarey that all the behavior (besides IPersistentMap) could change on dissoc?
09:21rhickeychouser: it's a different object
09:21chouserhm -- regular map but keep the type :tag?
09:22rhickeychouser: it's not the same type anymore
09:22rhickeyif you are calling dissoc you are treating the class as a collection/data
09:22rhickeyi.e. more generically
09:23rhickeycode in set or relational libs might do that just as a matter of transformation
09:23rhickeythis thing without those fields merged into that thing
09:24rhickeyshouldn't blow up if this-thing is from a deftype
09:30AWizzArdIs it/will it be possible to define a hierarchy with deftype/defclass?
09:30rhickeyAWizzArd: a hierarchy of concrete types ? no
09:33hoeckrhickey: but a hierarchy of interfaces?
09:33AWizzArdMaybe one can use derive and isa??
09:34hoeckand how do I define Interfaces? with gen-interface?
09:35rhickeyhoeck: it's possible, and I've done it, but it's almost always better not to. You end up doing in in Java because you couldn't say foo(this-and-that-type x), maybe now with generics you can
09:36rhickeyhoeck: there will be a definterface that matches defclass/type, but same idea, and same AOT
09:36rhickeyAWizzArd: you should avoid hierarchy when you have other tools to model overlapping concerns - like protocols :)
09:40jdirksHi there anyone willing to answer my noob questiosn?
09:42jdirksHow do i make a set from a list? #{ (list 1 2 3 4) } makes a set that contains 1 list element.... not what I want.
09:42chouser,(hash-set (list 1 2 3 4))
09:42clojurebot#{(1 2 3 4)}
09:42chouserd'oh
09:42chouser,(set (list 1 2 3 4))
09:42clojurebot#{1 2 3 4}
09:44hoeckrhickey, so the clojure interface-hierarchy will be defined in terms of `protokolls', cool
09:45esjis there a reference out there explaining protocols in this sense ?
09:45AWizzArdrhickey: ok, I still don't have protocols on my radar yet.
09:46AWizzArdesj: http://www.assembla.com/wiki/show/clojure/Protocols
09:46esjAWizzArd: much obliged
09:50jdirksI notice set creates a PersistentHashSet and sorted-set creates a PersistentTreeSet. Is there a way to create a PersistentTreeSet with a function like set that can take a list?
09:50_ato,(apply sorted-set (list 1 2 3 4))
09:50clojurebot#{1 2 3 4}
09:51_ato,(type (apply sorted-set (list 1 2 3 4)))
09:51clojurebotclojure.lang.PersistentTreeSet
09:53jdirksAnyone know why 'set' can be called directly but union only works with 'clojure.set/union' ? It seems a bit inconsistent.
09:56chouserjdirks: you're asking why some set-related functions are in clojure.core and others are in clojure.set ?
09:57jdirksI know it is just a design issue but it seems that set and union really should go together.
09:58jdirksI was wondering if there was some real reason for the different name space
09:58jdirksespecially since it is not documented that way at http://clojure.org/api#union
09:59_atoit is, scroll up and you'll see it's under a clojure.set heading
10:00rhickeyjdirks: actually, that is in it's own section, per namespace, just not great graphically
10:00chouserthe basic functions you need to work with the set datatypes are all in core -- set, hash-set, sorted-set for creation; get, contains?, conj, seq for working with existing ones.
10:00rhickeyabove difference - clojure.set
10:01jdirksoops sorry
10:01rhickeychouser: thanks for deftype print - so much nicer to play with now!
10:01jdirksi guess if you only use search on that page you do not notice it is organized that way.
10:01chouserthe clojure.set namespace has "extra" stuff for working with set objects -- mostly relational things (join, select) and their support functions, but some others as well.
10:01gerry_hello
10:01chouserrhickey: heh, np.
10:02chouserrhickey: will you be wanting a reader?
10:02gerry_my os crashed, i have to reinstall it to check out clojure-new and try again
10:02rhickeyso, (deftype Foo [a b c d e] [IPersistentMap]) in order to get associative/expando?
10:03chouserrhickey: is that instead of any opt-out flags?
10:03rhickeychouser: at some point I guess at least print-dup/readable, but complications exist regarding the availability of the supporting code needed to create instances
10:03rhickeychouser: yes, instead of opt out or int
10:04rhickeyin
10:05chousercan we have clojure.lang.* imported by default? or maybe shortcut names for use in the deftype/defclass interfaces list?
10:06chouser(deftype Foo [a b c] [:map :stack :reversible java.util.Foo])
10:09KjellskiAnyone that saw a good comparison for Clojure ans Scala? Where the main differences are?
10:10gerry_hmm
10:10chouserKjellski: Clojure, when compared objectivly and rigerously to Scala, has more good and less bad
10:10_atohehe :)
10:11Kjellski*smile* write this in the #scala and get on with the flamewar right?
10:11rhickeychouser: I like the abstracting away of the interfaces in that, but it has to be clear what you get, and what will conflict if self-defined
10:11jdirksI would say Scala is Java++. Clojure is a functional language that runs on the JVM.
10:11magnetchouser, that's objective
10:12gerry_kjellski: search on stackoverflow.com
10:12chousermagnet: exactly. and rigorous
10:12Kjellskigerry_ : thanks, nice tip.
10:13magnetKjellski, my comparison is: Clojure is a Lisp. Scala is not. If you like Lisp, use Clojure. If you prefer ML use Scala.
10:14rhickeychouser: :keys in interface list might be useful as an extension point as well
10:14chouserKjellski: Clojure has: dynamic types, macros, smaller core, more emphesis on immutability, richer concurrency semantics, more broadly useful seq abstraction.
10:15Kjellskichouser : And what of that does Scala have not?
10:15chouserrhickey: yeah, the mapping of short key to interface name isn't terribly obvious. auto-importing clojure.lang would be less magical
10:16Kjellskichouser : Okay, macros I know... ^^
10:16chouserKjellski: those were as compared to Scala
10:16Kjellskichouser : you really think, that is all better in clojure?
10:17chouserWell, Scala is staticlly typed and has no macros, so that's easy.
10:17Kjellskik
10:17jdirksIs there any work being done on getting some sort of stack trace when you hit an exception? Especially since I am new I find that I need to test every little bit of logic separately because if there is a runtime exception I can not find where it happened exactly.
10:18jdirks(This was never a problem when using Python)
10:18_atojdirks: huh? you should be getting a stack trace, with the file and line number
10:18chouserThe Scala type system is quite complex, the compiler would have to be more complex, and I think the standard library is larger, so you can file all that under "larger core"
10:18Chousukeyou may need to use (.printStackTrace *e) after the exception
10:19Chousukeor, even better, use the contrib stacktrace pretty-printing thing to do that.
10:19jdirksok I may have missed something. Is there a long to how to do that?
10:19raekjdirks: if you are using emacs, I recommend slime over inferior-lisp
10:19chouserKjellski: Scala does support immutable locals and has some immutable collections, but it also has mutable locals and mutable collections. Clojure provides only immutables -- so "more emphesis on immutability"
10:19jdirksI currently use the Eclipse plugin
10:20Kjellskichouser : don´t stop, I´m reading ^^
10:20raekI'll guess it depends on the IDE you are using
10:20cemerickrhickey: perhaps you could relent on open imports just for clojure.lang. Maybe an :import-clojure form in ns?
10:20magnetchouser, the fact is in both Clojure and Scala you can fall back to Java and end up with mutable structures. Scala made the choice to provide some (Scalified) of its own, whereas Clojure put a barrier and said "here be dragons; we do not compromise" :)
10:20Chousukealso: scala syntax. :-(
10:21ambientwell, clojure has arrays for fast mutable access, which for my purposes are a bit clunky
10:21magnetChousuke, a lot of people would say; also: clojure syntax :-( ;)
10:21Chousukemagnet: but they would be mistaken!
10:21rhickeycemerick: I really don't want people to marry all of clojure.lang, or possibly any of it
10:21chouserKjellski: If you want to write multithreaded apps, Clojure allows you to choose for each taks between: agents (a bit like Scala's actors), atoms, refs (the main STM hook -- no such thing in Scala), vars (easy access to thread-local data) -- thus "richer concurrency semantics"
10:21jdirksThen again you can do OO in Scala.
10:21Chousukewell, except for a few things
10:21Chousuke#() can get ugly sometimes
10:22magnetchouser, I hear Scala developers are planning for a STM in 3.0
10:22cemerickOK. I was just reacting to chouser's ":map :stack :reversible" example.
10:22rhickeycemerick: but the interfaces could be auto-included with the java.lang bits
10:22magnetchouser, but I agree with you that chouser provides more support currently
10:22chousermagnet: yes, and I appreciate the pragmatism of both. But when speaking of the language itself I think it's still accurate to say Clojure puts "more emphesis on immutability"
10:22chouserright
10:23rhickeycemerick: one nice aspect of :map etc is that it doesn't dictate that the support will be provided via interfaces. Once those features are supported via protocols they could be provided wither way
10:23raekKjellski: macros are one of my favorite things in lisps. if the code is starting to look complex, simplify it with macros
10:23Chousukeit's not even possible to use most of the concurrency stuff if you're not using immutable data structures :/
10:23markgunnelsadf
10:23raek(a (b (c (d (e))))) => (-> e d c b a)
10:23magnetraek, macros are also a thing a lot of people tend to get wrong in Lisp
10:24magnet"with a great power comes great responsibilities ;p"
10:24raekhehe
10:24raekthat's true...
10:24chouserKjellski: that leaves the seq abstration. Scala does have lazy Streams, but they're their own thing with a few methods. Clojure's seq library is pervasive and shouldn't be underestimated in it's power.
10:25magnetchouser, actually that changed in 2.8 with the new scala collections
10:25rhickeycemerick: so, you are ok with (deftype Foo [a b c d e] [IPersistentMap]) in order to get associative/expando?
10:25Chousukebut macros are one tool that you want to have.
10:25cemerickrhickey: oh, that's just fine :-)
10:26esjthe only trouble with Clojure, is that for beginners, such as myself, learning Clojure, requires learning three languages (clojure, java, lisp) more or less concurrently, which is a mild challenge
10:26chouserKjellski: every collection type knows how to be viewed as a seq, the set of functions that work on seqs are powerful and succinct, and all the persistent collections can be built from seqs. It's really a beautiful thing for expressing data transformations, and you get to use it just about anywhere.
10:26Kjellskichouser : Thanks a lot for this nice wrappup! I´ll definitely save this log. That´s what I was looking for.
10:26raekis there any way to read, say words or other tokens, from a java InputStream using a seq?
10:26Chousukesure.
10:27chousermagnet: oh, which changed? I've been away from Scala a while.
10:27magnetchouser, pretty much everything in collections. Odersky remade them more or less from scratch
10:27chouserKjellski: oh, and a final killer feature for me that Scala just can't touch: commit access. ;-)
10:27Chousukefirst you read a seq of characters, then send that through a filter which tokenizes the seq, and then you have a seq of tokens :P
10:27rhickeycemerick: and dissoc of base key yielding non-type map?
10:28cemerickrhickey: yes, definitely. It's probably an opinionated choice w.r.t. type theory, but I think it's the right one, anyway.
10:29Kjellskichouser : Sure, that´s pretty nice... but there is no way to get involved in Scala?
10:29magnetKjellski, define "get involved"?
10:29magnetah
10:29Kjellskigot it?
10:29magnetwell sure, there are some external committers for scala too :)
10:29raekChousuke: how do I get a seq from a stream?
10:29rhickeyhmm... 30+ interfaces in clojure.lang
10:29magnetKjellski, didn't see chouser's line :)
10:29chouserKjellski: oh I'm sure there is, but I'm "in" here already. :-)
10:29raekis there anything like that in the core api?
10:29Kjellskimagnet : okay.
10:30Chousukeraek: well, for example, (repeatedly #(.read stream))
10:30raekah, ok. that was pretty simple
10:30Kjellskichouser: And, please stay here =)
10:30Chousukethat produces ints though
10:30magnetKjellski, a huge argument in favor of Scala is that, I believe it's easier to get Java/C++ programmers to move to Scala than to Clojure, at least currently.
10:30magnetbut that's only my personal experience
10:31Chousukemagnet: I don't think that's a real pro, though :/
10:31Kjellskimagnet : I think so too, but the hard time I have now, will be forgotten when I´m used to write Lisp code... I just need the "paranthesis from my father" ^^
10:31magnetChousuke, well it's a pro when you get your boss to agree to use Scala on a project because "even if I'm gone, people can maintain it, it's easy to read, look" :)
10:31chouserKjellski: heh, no worries. I've tended to bail on languages pretty quickly in the past, but rhickey got his hooks into me.
10:32cemerickmagnet: that only matters if you need to go hire lots and lots of programmers. Warm bodies in abundance isn't necessarily an objective.
10:32magnetKjellski, a more elegant weapon for a more civilized age?
10:32magnetfrom*
10:32_atommm.. and if you hire good programmers they should be able to pick up anything pretty easily
10:32Kjellskimagnet : Oh please, got the link? I´ve searched for this but couldn´t find it again...
10:32ChousukeIt's funny how people always focus on the parentheses with lisp syntax.
10:33Chousukethey just move around a bit. why does that matter so much? :(
10:33chouserChousuke: since you asked
10:33chouser...I'll tell you why it matters.
10:33KjellskiChousuke : That´s just an "insider" from xkcd... ^^ nevermind
10:33magnetcemerick, depends on the shop you work at. Here it's Java only, and earlier a colleague came into my office asking for "the Scala guy" .. I have hope for a move to Scala, but I wouldn't dare dream to Clojure (even if I'd enjoy it)
10:34magnetKjellski, the xkcd link?
10:34Kjellskimagnet : yap
10:34chouserin C-like languages, foo(...) always means "call foo" or possibly use a builtin syntax thing called foo
10:34raekhttp://xkcd.com/297/
10:34Kjellskiraek: thanks!
10:34jdirksAlso for os clojure/lisp noobs it would be nice if the API page would contain (or a link to) a minimal example for every function with its intended use.
10:35chouserin C-like languages, the only other way parens are used are for grouping and syntactially it's clear they're not calling anything.
10:35Kjellskijdirks: : That´s definitively signed from me.
10:35cemerickmagnet: right, that was mostly my point -- it's very, very hard to determine what's "best" w.r.t. language choice, because circumstances and premises vary so much.
10:35Chousukechouser: hmm, I guess that makes sense. in Lisp you have parens everywhere so I suppose it looks messy to the uninitiated.
10:36raekyou can see that strip on several office doors at the Institution of Computer Science here at Linköping University
10:36Chousukechouser: I think Clojure suffers a lot less from that problem than CL or Scheme do, though. :)
10:36chouserIn lisps (foo) could mean just about anything. I could be invoking a function or special form, or it could be deep in a nested form and just be a symbol in a list, or (in non-Clojure) it could be declaring a local named foo or be a special arg to a macro or ... who knows what!
10:37chouserChousuke: yes, less. But it can still mean a fn or method def (in fn, letfn, proxy and now defclass and deftype) or a friggin' group of test cases in 'case'
10:38ChousukeI must say I like the scheme syntax for function definition, even though it has this "confusing" use of parens... (define (foo x y) ...) just makes sense.
10:38cemerickchouser: you don't like the parens in case, eh? :-)
10:39chousercemerick: how'd you guess?
10:39_atoI don't have much of a lisp background (came from c, python, ruby etc) and I found Clojure a bit easier to read than other lisps because of the vector-syntax like (defn foo [a b c] whatever), makes things stand out more.
10:39chouser_ato: exactly. me too.
10:39Chousukechouser: with fn, proxy, defclass/deftype I can forgive it because they all use it in a similar way (method/function definition)
10:40KjellskiI love the example from Stuarts book, where he showed the (.. ) macro just producing less parens than native java itself... that´s where I lost my fears about them I think...
10:40chouserKjellski: ah, that's good to hear.
10:42Chousukeso Rich decided on lists for case syntax?
10:42Kjellskichouser: The problem for me was, the combination of different semantics for parens and exactly same looking data structure in "old" lisps... just like _ato said.
10:43Chousukewith Scheme you can actually use [] and {} interchangeably with ()
10:43Chousukewaste of good characters :P
10:43chouserChousuke: that's what's in branch 'new' but perhaps it's not in stone yet.
10:43cemerickthat *always* screws me up now
10:43cemerickchouser: keep hope alive!
10:44raekwhich lisp has "superparens"?
10:44raeklike: ( ( ( ( ]
10:44Kjellskiraek, that sounds pretty confusing...
10:44Chousukebut in elisp [...] actually is (vector ...)
10:47djorkPLT Scheme uses [] interchangeably with ()
10:47djorkbut I've never heard of superparens
10:47djorksounds nice though
10:47raekI guess superparens were invented before highlight matching paren functionality of editors ;)
10:47chouserFranz Lisp used ] to close off all open parens
10:47djorkheh heh
10:47djorkyeah
10:48steigerhm
10:48steigersuper parens seems to be fun
10:50KjellskiI don´t get it, that makes only sense if they´re not used in a better way, like representing another data structure?
10:50chouserKjellski: right
10:52Kjellskichouser: "Righty thenn..."
10:53jdirksNoob Question: I have a vector and for each element in it i need to call a function like (myfn index value) how should I do that?
10:53AWizzArdmap
10:53raekdoes anyone know how to change coding system in slime?
10:53AWizzArd,(map inc [10 20 30])
10:53clojurebot(11 21 31)
10:53jdirksI need to know the index in when calling the function
10:54raekon startup, slime says: (swank.swank/start-serve "/tmp/slime.24462" :encoding "iso-latin-1-unix")
10:54AWizzArd,(use 'clojure.contrib.seq-utils)
10:54clojurebotjava.lang.IllegalStateException: shuffle already refers to: #'sandbox/shuffle in namespace: sandbox
10:54AWizzArd,indexed
10:54clojurebot#<seq_utils$indexed__697 clojure.contrib.seq_utils$indexed__697@ec0f07>
10:54raekI most definitely don't want to use latin1...
10:55_atoI think languages like Python are always going to have a small readability advantage over lisps as they read more like english, but lisps have huge benefits for writability -- besides the obvious macros, editor support (like eval hotkeys) works much better. Curly brace languages are neither really much more readable, nor writable, it's just everyone is used to them. :-P
10:55AWizzArd,(map #(vector :index (first %) (inc (second %))) (indexed [10 20 30]))
10:55clojurebot([:index 0 11] [:index 1 21] [:index 2 31])
10:55rhickeyso, on the parens in case thing. If you want parens to always be 'calls', then how do you match lists? (case '(:a :b) (:a :b) "found" ...). parens still are list data designators, and the first of each clause is unevaluated data by definition (i.e. not a call)
10:56_atoA friend had previously tried to convert me (as a Python/Ruby user) to common lisp. I wrote a few programs and liked macros and the editor support, but I found the syntax difficult, but the clojure vector thing improved it enough to convert me.
10:57chouserrhickey: literal sets were mentioned as an option
10:57jdz_ato: which vector thing?
10:58rhickeyso the desire to 'save parens for calls' eliminates their use here and elsewhere for data matching. The fact that vectors usually work for both has made that less of an issue, but it's a big deal to lose one of the 3 matching delimiter pairs
10:58_atojdz: (let [x 1]) instead of (let ((x 1))) and (defn foo [a b] ...) instead of (define (foo a b) ...)
10:58rhickeychouser: that's still a possibility
10:58Chousuke_ato: and for lisps there's paredit :P
10:59jdz_ato: what's the difference?
10:59rhickeyone problem is that almost everywhere else syntax calls for a logical set, a vector is used instead
10:59rhickeyusing sets in case will beg the question as to why they aren't used in similar situations elsewhere
11:00chouseryes, it's a big deal to lose parens for other meanings, and futile to try to remove them completely -- you can always have deeply nested quoted structures or user macros that use literal lists as non-calls.
11:00_atojdz: it makes it more obvious that [x 1] is not a function call, it's an assignment when you're reading the code
11:00jdzi personally have very mixed feelings about the property-list kind of specifying things (keys not being anything special)
11:00Chousuke_ato: Instead of manipulating lines of code, you manipulate *expressions*. It's simple, but... Once you learn it, there's no going back :P
11:00jdz_ato: not really. [x 1] might as vell be a vector acces.
11:01jdzand by property-list kind i mean undelimited pairs of things
11:01chouserAnd honestly it probably won't matter much to me personally anymore -- I'm in deep enough with the lispy syntax now to not be terribly confused by usages like for case. I can even read scheme somewhat more easily now.
11:01jdzso i prefer CL's style for both LET and COND
11:01_atoChousuke: yeah, I'm a big paredit fan
11:02ChousukeI sometimes still open vim for quick edits of lisp code and it always feels silly to type the closing parentheses
11:02chouserBut I do think it actually made a significant difference between the amount of effort it took to try to use CL vs. Clojure
11:03rhickeyI will say that case was definitely a problem for me when I was learning CL, the whole unevaluated position thing, how symbols were used literally to match symbols, not referents. Of course, they don't even support composites as keys there
11:03_atojdz: that's true. As a previous non-lisper though, it's just easier to adapt to for some reason. I'm used to assignments and method definitions being visually distinct. I never confused it with literal vector syntax for some reason
11:03rhickeychouser: don't get me wrong, Clojure definitely tries to use [] for non-calls as much as possible, and gets rid of lots of grouping
11:04Chousukeand there's always going to be a closing paren anyway, so the editor should just take care of it :P
11:04jdz_ato: yes, that's subjective.
11:04chouserrhickey: right. it's clear that was a goal and has been sufficient so far.
11:04chouserrhickey: 'proxy' and even multiple fn bodies are used rarely enough that beginners can look at a lot of code before having to deal with them.
11:05rhickeyif [] and () were both supported as keys, would people expect case to differentiate by type?
11:05rhickeybecause that would ruin case perf
11:05Chousukechouser: and really, ([foo bar] stuff) is probably not going to look like a function call to a newbie anyway. they'll just go "what's that vector doing there?"
11:06chouserChousuke: right
11:06_atojdz: yeah, indeed, I'm sure it depends completely on what you're used to, but it gives Clojure a better chance at converting non-lispers, which is a good thing.
11:07jdz_ato: that's for sure -- non-lispers are used to syntax sugar :)
11:07rhickeywell, the most important thing is that people kick the tires with deftype case etc. Please try 'new' branch everyone!
11:07jdzi'd say even addicted :)
11:07Chousuke[] and {} are not syntactic *sugar* though
11:08Chousukenor is #{} (I always forget sets)
11:08tomojhow not?
11:08jdzChousuke: depending on usage. in case of let and bindings they are.
11:08jdz*other bindings
11:08jdzbut then, CL has vectors, too: #(1 2 3)
11:08Chousukejdz: not really. for example, destructuring would be slower if lists were used instead of vectors
11:09jdzChousuke: nah, implementation details.
11:09Chousukethey're *real* vectors, as syntax. not shortcuts for (vector foo bar)
11:09Chousukethat means that in your macro you can use nth on the vector and it's constant time.
11:09jdz#(1 2 3) is also a real vector, and not a shortcut.
11:10jdzbut it is offtopic anyway
11:11Chousukeso you will be able to manipulate a vector if you do (somemacro #(foo bar))? and somemacro takes a single parameter :)
11:11jdzChousuke: but of course
11:12jdzChousuke: if foo and bar are bound, that is
11:12Chousukewhy do they need to be bound? :/
11:12jdzChousuke: same reason as in Clojure, they would be treated as variables
11:13jdzChousuke: oh wait a second.
11:13_atohehe so Clojure is like a nicotine patch for syntax sugar... weaning you off overcomplicated, sugared syntax but still with enough variety to prevent withdrawl symptoms. :-P
11:13Chousukeif #() were just a reader expansion to (vector foo bar) you'd get a list for manipulation in your somemacro
11:13jdzChousuke: it's a macro, so yes, you'd get a vector of 2 elements
11:14jdzChousuke: symbol FOO and symbol BAR
11:14Chousukeright.
11:14Chousukeprobably no-one uses vectors for macro syntax in CL though.
11:14Chousuke#() looks a bit ugly. :P
11:15jdzChousuke: well, yes it does. that's why i don't like it in Clojure :P
11:15jdzbut in CL it is used very rarely
11:15rhickeyClojure: (let [a 1 b 2 c 3] [a b c]) CL: (let ((a 1) (b 2) (c 3)) `#(,a ,b ,c))
11:16cemerickChousuke: really? I quite like it. What would a good alternative be, in a parallel universe?
11:16Chousukecemerick: I don't think there's anything better
11:16_atoin a parallel universe keyboards would have a lambda character instead of # :p
11:16ChousukeI think #() fits quick lambdas better than vectors, anyway
11:16jdzrhickey: not really. (let ((a 1) (b 2) (c 3)) #(a b c))
11:17djorkI appreciate the fact that I can use evenly-counted vectors instead of (() () ())
11:17chouserjdz: nope
11:17rhickeyjdx, no #(a b c) is a vector of 3 symbols, unevaluated
11:17Chousukethe # kind of says "make the next expression a function"
11:17jdzrhickey: ye, sorry. my CL is still swapping in ;)
11:17steiger_ato: in PLT Scheme, you can type the lambda character with CTRL+Z on their IDE
11:17steigerit works as syntactic sugar to the keyword lambda
11:18steigeri think
11:18Chousukeheh
11:18tomojmy emacs does that when I type lambda
11:18Chousukeyeah, mine too :P
11:18tomojbut no "lambda" in clojure anyway, and "fn" is short enough
11:18rhickeyjdz: that example highlights the difference - vectors have interpretation as syntax during evaluation in Clojure, in CL they are just a reader thing, embeds a vector in your code
11:18steigerfn is fine ;)
11:19jdzrhickey: yes, differences are ok, as long as there are reasons behind them. keep up the wonderful job you're doing :)
11:20jdzi did not want to drag CL in here, so, back to the scheduled regular Clojure discussions.
11:21ChousukeI wonder what it would take for Clojure to support continuations :/
11:22steigeris github down or something? what happened to richhickey/clojure ?
11:22Chousuke:o
11:23_atoyeah github's offline for maintainance
11:23ChousukeI wonder if they're finally going to make it faster.
11:23steigeroh yeah, i read it on the main page
11:23_ato"We are experiencing some heavy load on the frontends caused by a vast number of processes waiting for responses from the backend. On it."
11:24Chousukefortunately github is not central to development :D
11:25_atosteiger: you can still clone with: (defn readline-seq [rdr] (lazy-seq (cons (.readLine rdr) (readline-seq rdr))))
11:25_atogah
11:25_atowrong paste
11:25_atoI meant: git clone git://github.com/richhickey/clojure.git
11:25steiger_ato: i was wondering how the hell that would clone a git repo ;P
11:26_atowell... I guess if you redefine defn in a really strange way... :p
11:34chouser,(macroexpand '`[1 2 3])
11:34clojurebot(clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list 1) (clojure.core/list 2) (clojure.core/list 3))))
11:36Chousukewhy does it include the seq call? :/
11:36_atowow.. that's weird
11:37_ato,(macroexpand ``[1 2 3])
11:37clojurebot(clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list 1) (clojure.core/list 2) (clojure.core/list 3))))
11:37_ato,(macroexpand `'[1 2 3])
11:37clojurebot(quote [1 2 3])
11:38Chousukesyntax-quote is completely read-time so the macroexpansion is weird :)
11:38djorkinteresting
11:38chouserI look forward to that changing.
11:38Chousukebut that's what it has to expand to, because it has to build the structure at runtime.
11:39Chousukeso even a macro implementation will eventually produce something like that.
11:39Chousukechouser: my macro sq already works but it probably has some corner cases. :/
11:39chouserChousuke: hm, good point.
11:39_atoah right
11:39_atoit's because of splicing
11:39chouserthe concat is to leave room for splicing
11:39chouserright
11:40Chousukewhat I don't get is why there's teh seq after the concat
11:42_atoret = RT.list(APPLY, VECTOR, RT.list(SEQ, RT.cons(CONCAT, sqExpandList(((IPersistentVector) form).seq()))));
11:42_atohmm
11:43Chousukeheh.
11:43chouserIt's a java macro!
11:43Chousukea clojure reader macro written in Java :P
11:44chouserall the clojure reader macros are written in java
11:44Chousukewell, yeah.
11:44Chousukehmm
11:44ChousukeI think I'll try running the contrib test suite with my sq-macro-clojrue
11:44Chousukeclojure
11:45_atoalthough you think the reader could just expand it to (backquote whatever) and then you could define it in clojure
11:45chouserso concat always returns a seq anyway. so (seq (concat ...)) can only be to get nil on empty, right?
11:45chouser_ato: yes, that's the plan
11:45_atoyeah but (apply vector '()) and (apply vector nil) behave the same
11:46_atomaybe it's from pre new lazy
11:46_atoor sometime even earlier when things behaved differently
11:52avitalHi. To whom do I report broken links on http://richhickey.github.com/clojure-contrib/monads-api.html#monads/writer-m?
11:53chouseravital: I think github is just having problems at the moment.
11:55avitalOk cool. And for another question, can anyone point me to an example of using the update-state function from the clojure-contrib monads library? I feel like if I only see one working example it may all fall into place.
12:06AWizzArdavital: look at fnparse
12:06avitalAWizzArd: Thanks, GitHub is broken now, I'll take a look later.
12:06AWizzArdat github, http://github.com/joshua-choi but also down right now
12:07avitalAnd do we all agree that monads are probably the craziest and most amazing thing in the world or something?
12:07chouserare they amazing?
12:08chouserI need something to sell me monads the way "on lisp" sold macros.
12:09_atoyeah, to me they just seem to overcomplicate things without any major benefits
12:09avitalchouser: I'm going to try to make this thing that transforms all code into monad comprehension that allows you to attach arbitrary monad transformations thus allowing logging, profiling, exception handling and millions of other things just by adding one keyword each.
12:10rhickeyI'm thinking about requiring . before method names in reify/defclass/deftype
12:10avitalNo really. Monads are probably the most important thing or something.
12:10chouserrhickey: in the syntax for defining the method?
12:11rhickeybecause right now (deftype/reify .... (seq [] (seq "foo"))) the second seq is core/seq
12:11rhickeychouser: yes: (.seq [] (seq "foo"))
12:11sraderI've done a bit of micro-benchmarking with deftype/defclass. (time (dotimes [_ 10000000] (:age p))), where p is either deftype-obj, defclass-obj, PersistentStructMap, or PersistentArrayMap. I get PersistentStructMap slower (2x) than deftype-obj, which is slower (1.5x) than PersistentArrayMap, which is slower (4x) than defclass-obj.
12:11sraderdefclass is very fast!
12:11chouserrhickey: I think that sounds nice.
12:12hiredmanavital: http://tinyurl.com/ylk8lys
12:12_atorhickey: regarding " *
12:12avitalhiredman: AMAZING
12:12_atoUniversal field identifiers" ie the RDF namespacing of methods
12:13_atocan't you just namespace qualify them?
12:13_atoor is the idea to try to prevent tying them to any one package so you could have multiple implementations?
12:15rhickey_ato: right, namespaces would tie them to a lib, but you usually just want tiny field name + more universal name that might cross libs/apps
12:17rhickeyrhickey: reify/deftypes do not really have full class scope, only the fields have environment bindings, so this might clarify
12:17rhickeyer, chouser
12:17rhickey^^
12:19qedhello ladies and germs -- Anyone know of a good way to do syntax hilighting on clojure code for a website?
12:19qedI'm using rails right now -- didn't know if there was anything already out there...
12:20chouserrhickey: oh, can you refer to fields as if they were locals in method bodies?
12:21AWizzArdfunny :)
12:26_atoaah right.. it's too late at night.. it's universal *field* identifiers. I read that as *method* for some reason.
12:27AWizzArdtoo late in the night? East Russia?
12:27leafwqed: I am only aware of lisp javascript syntax highlighters.
12:28_atoAWizzArd: Australia, it's 3:30 am
12:28tomojgithub can highlight clojure right?
12:29tomojso I guess that means pygments can do it?
12:29tomojand pygments has a ruby wrapper
12:29tomojqed: ^
12:30tomojyes, clojure is on pygments' language list
12:31kefka,(class (hash-map))
12:31clojurebotclojure.lang.PersistentArrayMap
12:32_atokefka: array maps are used as an optimisation for small hash maps
12:32kefkaI know, but there's a problem.
12:33kefkaI'm working with transient collections.
12:33kefkaIf you're using assoc!, TransientArrayMap is worthless (at least according to spec)
12:34kefkabecause when there are more than 8 keys, the TransientArrayMap is full; assoc! returns the TransientHashMap, but the old array-map sticks around.
12:34kefka,(class (hash-map :a 1))
12:34clojurebotclojure.lang.PersistentHashMap
12:34chouseronce you've used 'assoc!' you shouldn't be touching the old collection anyway
12:35kefkachouser: you should be using the one returned, I assume?
12:35chouserkefka: right. Otherwise you're guilty of "bashing in place" and lots of things will break.
12:36chouser(doseq [...] (assoc! ...)) is bad, for example.
12:36kefkaSame rule for conj?
12:36chousereven with transients you should structure your code as if they were immutable, using the new collections, throwing away the old ones.
12:36_atowhen doing transients the simple rule is you should be able to remove (transient) (persistent!) and replace assoc! with assoc and the code should still work exactly the same
12:36_atoyeah
12:37kefkaSo the purpose of transients is just a performance optimization, then?
12:37chouseryes, that's it.
12:37_atoyes
12:37clojurebothttp://clojure.org/transients
12:37chouserif you want mutable collections ...which you don't! :-)... Java provides several.
12:38Chousukehmmh
12:39Chousuke,`(let [foo# 5] `(test ~'foo#))
12:39clojurebot(clojure.core/let [foo__5499__auto__ 5] (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/test)) (clojure.core/list (quote foo__5499__auto__)))))
12:40Chousukemy sq-macro doesn't handle that properly :(
12:40kefkachouser, _ato: Thanks
12:40Chousuke,`(let [foo# 5] `(test ~foo#))
12:40clojurebot(clojure.core/let [foo__5503__auto__ 5] (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/test)) (clojure.core/list foo__5503__auto__))))
12:40kefka,(doc assoc!)
12:40clojurebot"([coll key val] [coll key val & kvs]); When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vector, sets the val at index. Note - index must be <= (count vector). Returns coll."
12:41Chousukehm
12:41Chousuke,`(x# `[x#] `[x#])
12:41clojurebot(x__5521__auto__ (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/x__5519__auto__))))) (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/x__5520__auto__))))))
12:42Chousukehm :/
12:43ChousukeI'm not sure how to implement this
12:43AWizzArdwhat do you want to do?
12:44Chousukemake my syntax-quote macro work :P
12:45Chousukeit doesn't handle nested syntax-quotes with unquoting quite right.
12:47Chousuke,`(x# `[~x#] `[x#])
12:47clojurebot(x__5526__auto__ (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list x__5526__auto__)))) (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/x__5525__auto__))))))
12:48chouseronly a problem when autogensym is used?
12:48Chousuke,`(x# `[~x# `~x#])
12:48clojurebot(x__5531__auto__ (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list x__5531__auto__) (clojure.core/list (quote sandbox/x__5530__auto__))))))
12:49Chousukeas far as I can tell.
12:49Chousukebut that's just evil now.
12:50Chousuke,`(x# `[~x# y# `~y#])
12:50clojurebot(x__5536__auto__ (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list x__5536__auto__) (clojure.core/list (quote sandbox/y__5535__auto__)) (clojure.core/list (quote sandbox/y__5535__auto__))))))
12:51Chousukehmmh.
12:52Chousuke,`(x# `[~x# x# `~x#])
12:52clojurebot(x__5541__auto__ (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list x__5541__auto__) (clojure.core/list (quote sandbox/x__5540__auto__)) (clojure.core/list (quote sandbox/x__5540__auto__))))))
12:56notallamai was looking at comp, juxt, and partial. why do they have several different arities, rather than just the general "& rest" ones? is it more efficient that way?
12:57Chousukemaybe easier.
12:57Chousukebecause you don't have to manually extract the parameters.
13:01ChousukeI think Clojure's syntax-quote is taking advantage of the fact that it's read-time :(
13:01hiredmanclojurebot: syntax-quote is very hairy
13:01clojurebotIk begrijp
13:05Chousukeyeah... the syntax-quotes are actually expanded inside-out, which is why it works.
13:08Chousukehm.
13:09_atoChousuke: I've got no idea how you're implementing it, but can't you make your macro do the same? Perhaps by explicitly macro-expanding everyting inside or something?
13:09Chousukeright. that's what my "hm." above was.
13:09_atohehe :)
13:10rhickeychouser: yes, fields are in the local environment
13:22Chousukeoh wow. it actually works.
13:24Chousukeand it succesfully compiled contrib
13:24rhickeyreify is alive! .methodnames, more docs : http://github.com/richhickey/clojure/commit/9c3e97a85c042d2c3f276f0c1e0d270db35553aa
13:33dakroneis there a refactormycode-type site that supports Clojure?
13:38chouserquite a week for branch 'new'!
13:38clojurebotfor is not a loop
13:38djorkdakrone: that seems like just another pastebin
13:38djorkI just use gist usually
13:39drewrlimit on number of case clauses? http://gist.github.com/222567
13:40dakronedjork: well, I meant something like "this is my clojure code, please tell me how I can make it better/less java-ish"
13:40djorkthat's what this room is for :)
13:40djorkI think you'll find most of the programmers online who are able to help you with that right here.
13:41dakronealright then, I'll post it here :)
13:41chouseror on the google group
13:41dakronehow does this look? http://pastie.org/677017
13:42dakronejust kinda looking for feedback as in "don't do this" or "do this instead"
13:42mikehincheyrhickey: I like the .methodname change
13:42mikehincheyrhickey: I have iterator-seq working with proxy (no java), I'm trying with reify
13:43chouserdakrone: if BLIP_SUBMITTED is a field, you don't need parens around it
13:43chouseruse (inc x) instead of (+ 1 x)
13:43djorkah the geek favorite... die rolling
13:44dakronechouser: okay, will do, thanks
13:44chouserno need for re-pattern around #""
13:44chouseryou might consider using destructuring in calculate-rolls
13:46dakronechouser: so something like (let [[text dice sides] txt] ...) ?
13:47chouserinstead of (if-not (= (re-find ...) nil) foo) you can say (when (re-find ...) foo)
13:48chouserdakrone: or just (defn cr [[text dice sides]] ...) not sure if you'll like the results since you'd still have to process dice and sides.
13:48dakronechouser: is it similar to Ruby where anything other than 'false' or 'nil' is true?
13:48chouserdakrone: exactly
13:48dakroneokay, that helps
13:49chouserdakrone: looks good! nice clean code, good use of high-order functions, no state
13:50dakronechouser: thanks! I appreciate the feedback very much
13:51chouserdakrone: you have it actually working on wave?
13:52dakronechouser: yep, works great
13:52chouservery cool. I just haven't taken the time yet to do anything with wave.
13:52dakronechouser: so far building robots is the best part of Wave :)
14:00djorkand in clojure, no less
14:03drewrwhere's a current example of deftype?
14:03drewrthe Datatypes wiki seems out of date
14:04chouserdrewr: yeah -- by at least 2 or 3 days.
14:04chouseryou're probably best of looking at the wiki for concepts and the deftype docstring for syntax.
14:04GenericUser0Hello
14:04rhickeydrewr: docstring has gotten a lot better - feedback welcome
14:05rhickeynow that reify is in, I'll doc all three (reify/deftype/defclass) on the wiki soon
14:05GenericUser0What is the idiomatic way of performing a zip of several collections in clojure? I can't seem to find a zip function in the API.
14:06chouserGenericUser0: 'map' takes multiple collection args
14:06rhickeyso you can just map vector
14:07GenericUser0Ah, ok. Thanks.
14:08rhickey,(map vector [1 2 3] [:a :b :c] [:d :e :f])
14:08clojurebot([1 :a :d] [2 :b :e] [3 :c :f])
14:11froogwhat is reify?
14:12rhickeyfroog: like proxy but: faster, limited to interfaces
14:13rhickey(seq (reify [clojure.lang.Seqable] (.seq [] (list 1 2 3)))) -> (1 2 3)
14:15rhickeythe method bodies are true method bodies, yet close over local scope, calls have no lookup and no indirection to fns, much faster construction
14:16froogrhickey: great, thanks, I see now
14:20djorkcan I just gush for a second and say how freaking brilliant the lazy-seq facilities of clojure are?
14:20djorkthe fact that take is lazy just blows my mind
14:20djork(take 1 (take 10 x)) for example
14:22djorknot that I'd do that, I just have a function that returns (take n ...) and I just wanted the first one, so I took one and it was faster!
14:23djorkok, </fanboyMode>
14:27Chousukearr, recursively macroexpanding syntax-quote breaks :(
14:28ChousukeI wonder if I could just cheat and limit the depth... and then hope no-one has `[x# `````[~x#]]
14:28drewrso is my case clauses benchmark retarded?
14:28Chousuke,`[x# `````[~x#]]
14:28clojurebotjava.lang.ClassFormatError: Invalid method Code length 66815 in class file sandbox$eval__5550
14:28Chousuke:D
14:29Chousukeokay, looks like I should be fine.
14:29drewrsince the dispatch is supposed to be constant-time I thought I'd see for myself
14:29Chousuke,`[x# ```[~x#]]
14:29clojurebot[x__5554__auto__ (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/seq)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/concat)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/list)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote quote)) (clojure.core/list (qu
14:34twbray,(re-seq #".*" "foo\nbar\n")
14:34clojurebot("foo" "" "bar" "" "")
14:35chouser. doesn't match newline
14:35twbrayRight, but would've expected ("foo" "bar" "")
14:35twbray,(re-seq #".*" "foo\nbar")
14:35clojurebot("foo" "" "bar" "")
14:37chouser* is zero or more
14:37chouser,(re-seq #".+" "foo\nbar")
14:37clojurebot("foo" "bar")
14:38twbrayYeah, but if I'm trying to break "foo\nbar\n" into line fragments, I want 3 fragments, one empty. So .* is really what I want not .+
14:39chouserperl does the same
14:40twbraySigh. OK.
14:40chouserperl -e'$x="foo\nbar\n"; $x=~s/.*/[$&]/g; print "$x\n"' ==> [foo][]\n[bar][]\n
14:42chouser,(re-seq #"(?m)^.*$" "foo\nbar\n\n")
14:42clojurebot("foo" "bar" "")
14:42twbrayWow, thanks
14:42technomancy,(doc line-seq)
14:42clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
14:43twbray(re-seq #"(?m)^.*$" "foo\nbar\n")
14:43hiredmanso arrayseqs are apparently mutable...
14:43twbray,(re-seq #"(?m)^.*$" "foo\nbar\n\n")
14:43clojurebot("foo" "bar" "")
14:43twbray,(re-seq #"(?m)^.*$" "foo\nbar\n")
14:43clojurebot("foo" "bar")
14:43chouserhiredman: yeah, if you still have access to the array
14:44hiredmanchouser: :(
14:44chousertwbray: that's the normal meaning of \n -- as a line terminator not a line separator
14:44chousertwbray: at least I assume that's why ^ doesn't match after the last \n
14:45twbrayYeah, got a java.nio.CharBuffer I want to split into \n-separated chunks and it really matters if there's a trailing \n because that means an empty chunk
14:46notallamayou can put flags on patterns in java to change the behavior of /n and such.
14:46chouserthis is rather surprising:
14:46chouser,(seq (.split #"\n" "foo\nbar\n\n\n\n"))
14:46clojurebot("foo" "bar")
14:46twbrayAh, flags, good idea
14:48GenericUser0Why does something like (apply (partial < 5) 6) fail?
14:48hiredmanapply expects the last arg to be a seq
14:48chouserapply require its last arg to be a collection
14:48GenericUser0(sorry if I get disconnected, my anti-virus is being annoying today, and seems to want to kill anything associated with IRC...)
14:48hiredman,(apply (partial < 5) 6 nil)
14:48clojurebottrue
14:48hiredman,(apply (partial < 5) 6 '())
14:48clojurebottrue
14:49hiredman,(apply (partial < 5) 6 [])
14:49clojurebottrue
14:49hiredmanetc
14:49twbrayWhere do regex flags like /s and so on in #"" regexes?
14:50notallamatwbray: you might have to dip into java to do it, and use the horrible java regex syntax.
14:50twbraynotallama: Yeah, that may be it
14:50chouser,(take-nth 2 (re-seq #".*" "foo\nbar\n"))
14:50clojurebot("foo" "bar" "")
14:51hiredmanjava regex flags are generally something like (?i) at the fron of the regex
14:51chouserI used the m flag earlier: #"(?m)..."
14:51hiredman,(re-find #"(?i)foo" "FOO")
14:51clojurebot"FOO"
14:51chousertwbray: but anyway, there's your solution take-nth + re-seq
14:51twbrayThanks
15:00krumholthi anyone knows a good book about functional software architecture? i want something similar to the hundreds of books about object-oriented analysis and design. just for functional programming
15:00duncanmdum de dum
15:01duncanmi have this little bit of Java code, I can't quite think of a way to write it in idiomatic clojure - http://gist.github.com/222629
15:01chouserI wonder if the various functional languages are similar enough for a general text to be useful.
15:02duncanmhey chouser
15:02duncanmwhile ((count = input.read (data, 0, SIZE)) != -1) { output.write (data, 0, count); }
15:03duncanmloops like that, i don't know what to do, should I go back to using set!, should i use refs?
15:03duncanmoh, maybe loop/recur?
15:04krumholtchouser, i mean like a book of fundamentals for application development with functional programing languages
15:04chouserloop/recur would work, but it always does.
15:04chouserduncanm: but repeatedly would probably work here too
15:07chouserduncanm: untested: (let [data (make-array Byte/TYPE data-block-size)] (doseq [c (repeatedly #(.read input data 0 data-block-size)) :while (> c -1)] (.write output data 0 c)))
15:07chouserloop/recur might be every bit as good
15:17yacinagreed
15:17yacinwhoops
15:17yacinwrong chan
15:30falkorI was looking at clojure.contrib.graph and noticed that it is mainly directed graphs only, right? Things like undirected graphs, edges with weights.... not there... Or am I failing to see something?
15:31tomojwell you could always just have two edges between each node
15:31tomojI dunno about edge weights.. I'm doing stuff with edge weights on directed graphs now and decided to just start from scratch
15:32falkortomoj: that would be a cycle :( Plus, how to do weigths?
15:32falkorI am mainly working with weigthed trees... BTW, I suppose you know of JGraphT and JGraph... you might find it helpful....
15:37tomojfalkor: yeah been lookin at JGraph but I don't have my network library workin quite well enough yet to use it
15:38chouserrhickey: so if I want the speed of direct field access but don't want AOT or a named class, that still points me to reify?
15:38falkortomoj: suggestion, also check JGraphT, in case you have not done it. You might find it interesting
15:40tomojfalkor: thanks
15:40tomojnot interested in mutable graphs, though
15:40tomoj;)
16:06rhickeychouser: no, reify and deftype have the same perf - both give you direct field access *within* methods, reify gives you no access outside, and deftype gives you :field access outside. Both compile method bodies to true methods etc. It's all the exact same code for reify/deftype/defclass, it's just with defclass you end up with a named class which lets you access the fields direct *outside* of methods
16:07chouserah... right right.
16:08rhickeyone thing that is not there is any notion of private helper methods
16:09chouserwith immutable objects the dangers of visible helper functions are pretty low. I guess can be confusing for users to see them.
16:12rhickeyright, but external helpers can't have same perf as helper methods, at least for deftypes
16:13rhickeythe problem with helper methods is making them visible to the compiler's host interop infrastructure, the stub class hack would need more work
16:17GenericUser0Is there a program that will let me expand the stages of a function call so I can see where it's failing?
16:18GenericUser0I have a lot of somewhat complicated functions that are returning closures, and they are composable... so debugging it is rather challenging at the moment.
16:18GenericUser0(I'm doing a sort of pattern-matching over s-expressions)
16:18GenericUser0suggestions?
16:20chouserGenericUser0: do you mean besides stack traces?
16:20GenericUser0Stack traces aren't working very well for me at the moment
16:21GenericUser0All I get is something like
16:21GenericUser0java.lang.IllegalArgumentException: Wrong number of args passed to: user$lit--7233$fn (NO_SOURCE_FILE:0)
16:21GenericUser0I think I've mentioned this before.
16:22GenericUser0but I'm not sure what happened to my logs.
16:22chouser(.printStackTrace *e)
16:22chouserthat should give you the full trace. Each line of the trace should name a filename and linenumber.
16:23GenericUser0I get nil O_o
16:23GenericUser0Maybe I'm catching it wrong hang on a sec
16:24chouserwell, *e is defined at the plain repl for exceptions that bubble all the way out there
16:25GenericUser0Argh. Screw McAfee >.<
16:25GenericUser0keeps killing my IRC connection, and automatically resetting the firewall rules
16:26GenericUser0Yeah, I just nil.
16:26chouserGenericUser0: are you at a plain terminal repl?
16:27GenericUser0I'm doing basically: (try <my expression> (catch Exception e (.printStackTrace e)))
16:27GenericUser0I'm in Clojure Box's emacs
16:27chouseroh. hm. that should work
16:27chouserwithout the try/catch slime is supposed to help you out I think, but I don't do slime
16:28GenericUser0Oh... I see it now. It's hidden.
16:28GenericUser0...still not especially helpful though, unfortunately :/
16:28GenericUser0It's being raised by clojure.lang.Compiler.eval
16:29durka42try clojure.stacktrace/print-cause-trace
16:29dakronecan someone tell me what I'm doing wrong with this xml parsing? http://pastebin.com/d4b960346
16:30GenericUser0In the catch from before, instead of .printStackTrace ?
16:30durka42GenericUser0: yes
16:30durka42it chains through Exception/getCause or whatever it is called
16:31durka42dakrone: what are the symptoms?
16:31GenericUser0ClassNotFoundException: clojure.stacktrace
16:31durka42meh, isn't that what it's called
16:31durka42,(use 'clojure.stacktrace)
16:31clojurebotnil
16:31dakronedurka42: it returns (), instead of the text inside the fcttext XML element
16:31durka42,(print-cause-trace (throw (Exception. "blah")))
16:31clojurebotjava.lang.Exception: blah
16:32GenericUser0I don't seem to have that in clojure box for some reason. Huh.
16:32durka42,(print-cause-trace (Exception. "blah"))
16:32clojurebotjava.lang.Exception: blah at sandbox/eval (NO_SOURCE_FILE:-1) clojure.lang.Compiler.eval (Compiler.java:4623) clojure.core/eval (core.clj:1966) hiredman.sandbox/cond_eval (sandbox.clj:72) hiredman.sandbox/eval_in_box_helper (sandbox.clj:108) hiredman.sandbox$eval_in_box__112$thunk__117.invoke (sandbox.clj:123) hiredman.sandbox/wrap_exceptions (sandbox.clj:32) hiredman.sandbox/wrap_exceptions (sandbox.clj:28) hiredman.sand
16:32durka42GenericUser0: if you have an oldish version of clojure, it's clojure.contrib.stacktrace
16:32GenericUser0Is it very new?
16:32chouserdakrone: :forcastday -> :forecastday ?
16:32GenericUser0Ah
16:32GenericUser0now it works. Thanks
16:33dakronechouser: totally missed that typo, unfortunately it still only returns ()
16:33chouserxml-> turns out to be quite fragile like this. Not sure how to fix it. :-/
16:34dakronechouser: is there a recommended way? searching the internet reveals a number of different methods, but no real exhaustive examples
16:35chouseras in alternatives to zip-filter?
16:35dakronechouser: that or the recommended xml-parsing way
16:36chouserI dunno. I wrote zip-filter exactly for scenarios like this, but each time I use it spend some amount of time fiddling with filters that just return empty seqs.
16:36chouserI used enlive once, but for XML you have to hack around it a bit, and I haven't used it enough to know if it's any less fragile in this way.
16:37dakroneso, should I parse it with java libraries instead of in a clojure way?
16:39chouserdakrone: try leaving off the initial :forecast
16:40chouser(xml-> feed :txt_forecast :forecastday :fcttext text)
16:41dakronechouser: yep, that fixed it
16:44dakrone_chouser: how does the (text ...) call know that the content is inside a :content tag?
16:44chousertext is c.c.zip-filter.xml/text, specific to the maps produced by c.xml/parse
16:45dakrone_oh okay
16:46dakrone_makes much more sense now
16:51chouserrhickey: when there are collections that support primitives and/or fns with primitive args, with the interfaces support all types but throw runtime errors on incorrect types, or will there be multiple interfaces (presumably with almost nothing in common)
16:51chouserrhickey: I ask because I'm thinking about primitive measure/reduce for finger-tree
16:53rhickeychouser: don't know yet - certainly they must support the object interfaces for compatibility. There may be parallel interfaces for long/double, or methods next to existing (although not type-overloaded - new type-qualified names, e.g. valAtLong)
16:53chouserok
16:56chouserRight now I have [(fn measure ...) (fn reducer ...) init-val]. So I'm thinking those could be methods of a reify with IMonoid
16:56rhickeyI do know I want to restrict it to long/double at the interface, i.e. that is all that will be supported by fn (eventually).
16:56chouseryep, and that makes sense to me.
16:58chouserIt's hard to see how else to allow primitives for my IMonoid methods without ILongMonoid and IDoubleMonoid, and then not have those either checked at runtime or bubble all the way up to IFingerTreeMeasureLong and IFingerTreeMeasureDouble
16:58chouserwell, anyway, gotta run. Thanks for your answers.
17:20kanakHi. Can someone tell me whether cons is lazy by default, or if it is lazy only when wrapped around lazy-seq?
17:20hiredmanlazy-seq
17:21kanakthank you.
17:21kanakis there a way for me to check if something is a lazy seq?
17:23digash`,(instance? clojure.lang.LazySeq (lazy-seq []))
17:23clojurebottrue
17:24kanakthank you digash.
17:27kanakCan someone tell me when i should prefer cons to conj (or vice versa)?
17:29cemerickkanak: can only "add" to a list (or nil). conj will "add" to any collection.
17:30rhickeykanak: conj in almost all cases other than when building a lazy sequence using the general form (cons first-item (recursive-call to build rest))
17:31kanakthank you rhickey and cemerick.
17:33rhickeykanak: sure
17:40twbrayI have a big list and I want to map a function onto it, but the function is mostly (send ), no useful result, is there an equivalent of (map that doesn't bother returning the new list?
17:41kanaktwbray: doseq?
17:41rhickeytwbray: what map actually returns is lazy (the list doesn't yet exist), you can call dorun on that and it will walk it (for effects), discarding the result
17:41rhickeybut sometimes that is better expressed with doseq
17:41twbrayOh cool. Thanks
17:46technomancyit's not an optimization if you use doseq to communicate intention... using map on some level implies you're interested in the return value
18:02st3fanhm how do i filter on a map?
18:03st3fanfilter on a map seems to return a vector instead of a map
18:03Chousukeyou can treat it as a seq of [k v] vectors
18:03st3fanhmm
18:03st3fani basically want to filter out some key/value pairs as part of a swap! operation
18:04Chousukeso (into {} (filter (fn [[k v]] ...) amap)
18:04technomancyst3fan: you can also reduce conditionally
18:04technomancyinto is probably clearer though
18:04st3fani'll give it a try
18:06st3fangot it!
18:16rhickeydoc update in progress: https://www.assembla.com/wiki/show/clojure/Datatypes
18:27kanakIs the idiomatic way to do letrec (scheme)/lables (cl) in clojure just using a private function using defn- ?
18:31rhickey,(doc letfn)
18:31clojurebot"([fnspecs & body]); Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body. fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+)"
18:32rhickeykanak: letfn ^^
18:33kanakrhickey, thanks again :)
19:23kanakhmm. why does (seq? [1 2 3]) return a false?
19:25Chousukekanak: a vector is not a seq by itself. You need to call seq on it to get a sequence view of it.
19:26kanakI see. So how do i test if something is a clojure sequence?
19:26technomancykanak: iseq? tests if it implements the seq interface
19:26technomancyor if it can "become" a seq
19:27Chousukethere actually is such a function now?
19:27technomancyerm; it's called something else
19:27Chousuke,(seqable? "foo")
19:27clojurebotjava.lang.Exception: Unable to resolve symbol: seqable? in this context
19:27Chousukehmm
19:27Chousukesomething likethat was in contrib
19:27Chousukebut nothing in core :/
19:28technomancywouldn't be the first time
19:28kanakcontrib.core has seqable
19:29gthompsondoes sequential? do it?
19:31kanaksequential? gives the desired results but I wonder if using it in this sense is misusing it.
19:41gthompsonI'm new to clojure so I don't know what the intended use of sequential? is? I just found it with autocomplete in slime ;)
19:48kanakgthompson: sequential? checks if the object implements Sequential, whereas I want to test if something implements Seqable (i.e. supports first, rest, and next). So i think like its just a coincidence that it gives the right answer right now :)
19:50gthompsona happy coincidence today is the road to a horrible bug tomorrow :)
19:50kanakmy thoughts exactly :D
20:13bitbcktA little word-of-tweet goes a long way.
20:13terrycojonesbitbckt: :-P
21:37cemerickwhoa, since when is #clojure dead on a Friday night? :-P
21:38Knekksince everyone is attending halloween parties dressed up as Scala and Haskell
21:39terrycojonesclojure doesn't need a costume to look scary :-)
21:41_atoterrycojones: http://dorophone.blogspot.com/2009/05/clojure-style-destructuring-binding-for.html
21:41_atounfortunately elisp is too limited to be able to be morphed completely into clojure via macros :(
21:45terrycojones_ato: thanks!
21:45chouserterrycojones: it is inevitable that many will try. likely that most will fail.
21:46chousermaybe we'll be lucky and one wil succeed.
21:47terrycojoneschouser: hope so.
21:47froogis the problem with mutual recursion by design or implementation?
21:48chouserfroog: implementation. JVM.
21:48_atofroog: you mean the lack of tail call optimization?
21:48froog_ato: I mean like: http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Mutual_Recursion
21:49froogthat you have to make a forward declaration
21:49chouseroh
21:49chouserrequiring forward declarations is a design choice I believe.
21:50froogchouser: pity, its a bit of a wart, I think
21:51chouserfroog: you're not alone in that opinion. If you check the google group you'll find it's been discussed a bit.
21:55chouserI haven't found it to be a problem.
21:57froogchouser: its not enough to put me off clojure :)
22:15cemerickit seems that someone could make a better emacs using clojure and one of the IDEs out there. Building from scratch seems a little nuts
22:19steigeremacs is very big and quite complex, and great. i see no point in re-doing it
22:19cemerickI agree on the big and complex part, but lots of people like tilting at that particular windmill.
22:21froogIt seems that for every language, at least one person thinks emacs should be rewritten in it
22:21froogmaybe not brainf*ck
22:25notallamamit scheme is emacs redone in scheme, isn't it?
22:30cemerickIt's just a scheme impl AFAIK
22:31cemericknotallama: maybe you're thinking of PLT scheme, which has a pretty decent IDE?
22:31chouserwell there scratch and scratch. Java swing comes with pretty much an entire programmable text editor built right in.
22:32_atowell rewriting emacs in clojure wouldn't do it as the whole reason emacs is great is that it has so much code already for it
22:33_atoit'd be nice if someone did something that let you write clojure code to drive emacs and interoperate with elisp libraries, like how you can write clojure code that interoperates with java libraries
22:53notallamacemerick: i'm thinking of edwin. it comes with mit scheme, and it knows how to eval scheme, but i'm not sure if it's written in it or not.
22:54cemerickchouser: yes, the javax.swing.text API is pretty good, as such APIs go
23:06hiredmanI sent and email about my reader to clojure-dev
23:06hiredmanand screwed up the quickstart instructions twice
23:06chouserhiredman: we won't hold it against you. :-)
23:07hiredman:)
23:34chouserI just glanced at my email and saw "Kevin ... Reader - I have written a Clo..." and I thought a *third* person has written a Clojure reader in Clojure!?
23:34chouser...before remembering hiredman's real name. :-)
23:34hiredman:P
23:35hiredmanI would love to have a third implementation
23:44cemerickhiredman: hah, I had no idea what your name was -- I thought, wow, everyone's got their own clojure reader impl these days. :-)
23:45cemerickOf course, chouser just said exactly that. Wow, I'm tired.
23:45chouserI haven't talked much about my reader, but it's better than everyone else's. It uses monads.
23:46chouserI mean it *is* a monad.
23:46froognight all!
23:49chouserhttp://tinyurl.com/yf76rln
23:51notallamamaybe i'll write a clojure reader in clojure. by the time i get to it, it won't be third, though.
23:52ambientthis like a competition or something? write a clojure reader and win a prize? :p
23:52notallamareader golf, perhaps