#clojure logs

2010-12-18

00:38devnHow do people live without a real REPL?
00:41Derander_I don't know
00:41Derander_clojure/emacs/slime is making me consider writing a swank-ruby
00:41Derander_irb is not good enough
00:45Derander_I wonder how difficult that would be
00:45Derander_I know nothing about swank
00:45amalloyDerander_: ask technomancy
00:46Derander_amalloy: well, if he saw your ping and feels like talking I will
00:46amalloydevn: i recently discovered someone wrote a php repl. not very fancy, but better than having to use php -r, or (god forbid) write test.php files all over
00:46Derander_I started to read swank-clojure, but I had trouble grokking it
00:47amalloyDerander_: yep, that was the idea :)
00:51DeranderThere we go.
00:51Deranderfixing that w/ znc was surprisingly annoying
00:55joshua__Derander, something like this already exists.
00:55DeranderI've been looking for a few days and haven't found it
00:56Deranderif it does exist than I would love to find it
00:56joshua__wait, nevermind it is for vim
00:56joshua__slime.vim extension
00:56joshua__http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
00:57joshua__it is hackish though, basically you set up a screen session running irb
00:57Deranderyeah
00:58DeranderI'd rather make it work directly w/ slime
00:58Derandera solution like slime.vim comes w/ ruby-mode
00:58joshua__Oh! I didn't know that.
00:58joshua__I don't actually program in ruby.
00:58Deranderno worries :-)
00:59Deranderit seems like ruby is flexible enough to do it though. you can get method args, redefine methods and reload files dynamically
00:59Derandermethod arglists
01:03joshua__amalloy, I have a question about sandboxing.
01:03amalloyjoshua__: i have an answer
01:04joshua__amalloy, (:answer amalloy)
01:04RaynesHahaha, asking amalloy questions about sandboxing.
01:04amalloyi know, right?
01:04Raynesjoshua__: You misspelled Raynes.
01:04amalloyjoshua__: seriously Raynes wrote the sandboxer himself; i just made him do several things in less awful ways
01:05Raynesamalloy and I are a team. <3
01:05RaynesI write things and he fixes them!
01:05amalloyin the sense that he shits all over the place and i clean it up
01:05joshua__All right so here is the question. How secure is sandboxing really? Like can you give two different people code access to a machine and make sure that they can't effect each other?
01:05amalloyjoshua__: it could be done, but we don't do it
01:05joshua__The idea being that these users are malicious.
01:05Raynesjoshua__: The JVM sandbox is pretty hardcore.
01:06amalloythe easiest way would be to spawn a new jvm for each user, but that's expensive
01:07joshua__amalloy, why don't you do it?
01:07joshua__amalloy, hard?
01:07Raynes<amalloy> ... but that's expensive
01:08amalloyjoshua__: yeah, basically
01:08joshua__Raynes, I've felt the same way about working with him.
01:08amalloysexpbot runs in a persistent clojure process, joshua__. if users do *anything* to the global environment there, it's visible to everything running in that jvm. we try to make it impossible to affect the environment in any permanent way, and the jvm does a good job stopping you from touching anything outside the repl
01:09RaynesThe idea behind clojail and any Clojure sandboxing will always be to just avoid state. The JVM sandbox can prevent I/O and other dangerous stuff, but it can't do anything for state. Any Clojure sandbox is vulnerable unless it forbids state.
01:09RaynesClojail tries to do that. Mostly succeeds, failing in other ways.
01:10bortrebis there any reason that partial doesn't work with just one argument and return the function it's given?
01:10joshua__Raynes, can you allow network IO (like requesting files) but not read/write to the filesystem?
01:10Raynesbortreb: Well, that wouldn't be very useful.
01:10amalloyjoshua__: you could, for sure
01:10Raynesjoshua__: Yes, with some JVM permission stuff.
01:11amalloyif you're into that kind of thing, you want to look up JVM permissions/policies
01:11joshua__Raynes, cool that pretty much answers my questions
01:11RaynesYou can't do that with clojail though.
01:11RaynesThe JVM stuff is locked down tight. Once I learn more about it, I might open that up some more.
01:12bortrebRaynes: it's useful for a base case
01:13bortrebfor when you may be partialing a function with zero or more args and you don't know how many
01:20joshua__&map (fn [k] [k]) [1 2 3])
01:20sexpbot⟹ #<core$map clojure.core$map@d6eb4b>
01:20amalloyjoshua__: are you planning to use this somehow for your stackoverflow/hn thing, or is this a separate project?
01:20joshua__&(map #([%1]) [1 2 3])
01:20sexpbotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentVector
01:20joshua__amalloy, oh god no
01:20amalloy&(map vector [1 2 3])
01:20sexpbot⟹ ([1] [2] [3])
01:20joshua__amalloy, this is just an idea that was swimming around in my head.
01:21joshua__Is there a good reason that the first doesn't work?
01:21amalloythe actual first, with [k]? it's cause you forgot some parens
01:21amalloy&(map (fn [k] [k]) [1 2 3]))
01:21sexpbot⟹ ([1] [2] [3])
01:21joshua__Meant the second, sorry. It seems to me that (fn [k] [k]) and #([%1]) should be equivalent.
01:22Raynesjoshua__: #([%1]) -> (fn [] ([%1]))
01:22Raynes#([%1]) -> (fn [k] ([k]))
01:22RaynesCopy paste fail.
01:23joshua__#({%}) -> (fn [k] ({k}))
01:23joshua__?
01:23amalloyjoshua__: well yeah, except that both of those are compile failures so it doesn't really matter
01:25joshua__I guess it isn't a big deal. All cases in which it is a problem are solved fairly trivially.
01:26amalloyright. especially because (fn [x] [x]) is succinctly described as just vector
04:24amalloyso what's the "best" way to do testing in clojure these days?
05:16currentBshould refs generally not be viewed/bound outside of a dosync or are there times when it's fine?
05:17mduerksencurrentB: viewing can be done whenever you want - that's one of the beauties of the STM model of clojure. i'm not sure what you mean by binding refs. do you mean vars?
05:18currentByeah
05:20mduerksenvars are a complete different concept, vars can have a different value in each thread. dosync is for refs
05:21mduerksenif you want thread-safe state, take refs. if you just need a thread-local value, you can define a var (or create a thread-local binding for a var)
05:21currentBacutally I meant for like let bindings, sorry about that
05:21currentBstill really new at this
05:22mduerksenno problem :) a let-binding is thread-local and also bound only in the lexical scope of the body of your let form. outside, the let, your binding is gone
05:24mduerksenfor a more complete explanation, you can read http://clojure.org/vars for vars, and http://clojure.org/special_forms for the let form (and other related stuff)
05:26currentBthanks! so there's no need to worry about like you let binding to the wrong variable due to concurrency stuff?
05:30mduerksenthat depends: when you bind to the value of a var, that value could be specific to the current thread. when you bind the the value of a ref (e.g. (let [w @world] ... ), you have bound w to the state of the world-ref which can be modified at any time. but you don't have to worry inside your let-form: @world gives you a snapshot of the world at that moment, and your bound symbol "w" won't change at all, even when the state of the worl
05:31mduerksenin short: you can be sure that the value of w NEVER changes. which lets you sleep better at night ;)
05:38currentBok nice got it now, thanks a ton!
07:57lpetitHello
07:58lpetitI don't remember the syntax for explicitly, in gen-class, specifying *which* method flavor (in case of overloading) you want to override. Any idea ?
08:03ducki2plpetit: :methods ?
08:04lpetitsay I extend a class, which declares 2 methods with same name, same arity, but different param types. eg foo(String x, String y) and also foo(int x, int y)
08:09ducki2plpetit: you can put the argument types in the function name; http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html
08:09lpetitthx, that's the link I was searching!
08:16lpetitthanks again, and that's a great blog post, btw
10:08zakwilsonHas anyone attempted to write a native code compiler for Clojure?
12:05jweissi have a macro that calls a fn in the same ns as the macro. the only real public api in that ns is the macro. but i find that if i "use" :only the macro, it can't find the fn it needs to call.
12:06jweissis there a way to save callers of the macro from having to know about the fn as well?
12:06raekjweiss: are you syntax-quoting the name of the function?
12:07raek`(foo 1 2)
12:07raek,[`(foo 1 2) '(foo 1 2)]
12:07clojurebot[(sandbox/foo 1 2) (foo 1 2)]
12:07jweissraek: yeah, i am
12:07raekif the macro has been loaded, the function is loaded too
12:07jweissoh you know what, it is a function defined in a protocol (also in that ns)
12:08jweissso i did extend-protocol and added that fn to a java type
12:08raekshouldn't make any difference, I think...
12:09raekI guess you could try to look at the macro expansion for things like typos, etc
12:10raek(preferably, do the macro expansion in the namespace that :uses it)
12:11raekanother test: try to eval macro.name.space/the-protocol-fn in the dependent namespace
12:13raek(if that doesn't work, there's problably something suspicious with the defprotocol)
12:14jweissraek, ah silly me. it was a forward definition. didn't see it before because i had been developing in the repl and the fn was already defined.
12:22replacajweiss: (answering your earlier question): you can make the fn private and then access it by full var syntax: i.e., #'clojure.pprint/init-navigator
12:23raekthe @#'foo/bar hack adds an extra step of indirection, right?
12:24replacaraek: you don't need an @
12:24raekah, yes... they implement IFn...
12:24replacaright
12:25replacaif you're trying to pull a private variable binding, I think you do need @ though
12:25raekexactly
12:49patrkriscake question: i cloned the cake repository and when I run `cake deps` it complains that it cannot localte uncle/core.clj, presumably because that dependency has not been downloaded yet. How can I remedy this?
12:50patrkrisah sorry, should probably ask this in #cake.clj
14:00mduerkseni want to take my clojure programming "to the next level" - and by that i mean i want to start building an abstraction level over my existing code. i guess clojure's macros are well suited for that, but i'm not sure where to start and what to consider. are there any good learning ressources especially for abstractions in clojure (or lisp in general)?
14:01mduerksensomething like "meta-programming"
14:03ducki2pmduerksen: chapter 12 of practical clojure?
15:24arohneris there a library out there that does DB operations in memory, on sets? kind of like clojure.set/index on steroids?
15:32kumarshantanuarohner: can't use an in-memory database? like H2, HSQL-DB or Derby?
15:33arohnerkumarshantanu: I want to do DB-like manipulations on clojure datastructures, not a real DB
15:33arohnerlike I said, clojure.set/index on steroids
15:34kumarshantanuarohner: Maybe rql? https://github.com/MrHus/rql
15:35kumarshantanusorry I am just guessing...haven't looked at rql deeply
15:35arohnerkumarshantanu: that's almost exactly what I'm interested in. thanks
15:36fliebelarohner: FleetDB is written in Clojure, so I assume you can use it directly.
15:36kumarshantanuarohner: there's also a close cousin to rql, called mql: http://techbehindtech.com/2010/09/08/mql-a-clojure-library-for-querying-nested-maps/
15:40arohnerfliebel, kumarshantanu: thanks
15:50LauJensenarohner: clojureql is based off relational algebra, hook the backend up to an in memory db and you're all set
16:26charliekiloStupid question: since Clojure's data structures are immutable are they always passed by reference into functions?
16:26amalloycharliekilo: yep
16:28charliekiloamalloy: Thanks
16:29fliebelcharliekilo: If they are immutable, why would you care?
16:30charliekiloamalloy: Are you aware of an easy code snipped that shows that behavior or would I need to drop down to Java and/or a memory analyzer?!?
16:31amalloycharliekilo: you just have to open a java tutorial. it's not possible to pass objects by value in java
16:31amalloyall object references are pointers; the pointer is passed by value, which is a reference to the original object
16:32charliekilofliebel: I am wondering if I have a large hash I can pass it around without duplication
16:33amalloyyou can. don't worry about it
16:33charliekiloamalloy: yep thats how I remembered it from way, way back, but wanted to make sure ... thanks again!
16:33amalloyif you really want to see it happen, you can AOT compile your classes, then inspect the generated bytecode with javap -c
16:34charliekiloamalloy: hmm ... thats a good idea!
17:50FireSnakeI'm looking for a pair programming buddy --- right now teaching myself to build and deploy clojure web applications on compojure and GAE. Anyone interested?
18:42FireSnakeAnyone know how to integrate JQuery and CSS with Compojure 0.5.3? or if not which Compojure is better?
18:42FireSnakeI have seen tutorials on the web talking about include-css and include-js but those commands do not work with Compojure 0.5.3
18:42FireSnakethere is only a compojure.core and compojure.routes file
18:42FireSnakethe compojure.routes has a command files but not sure how to use it
18:43FireSnakeis there some other version from Clojars I should be using?
18:43FireSnakeMy static CSS/HTML and JQuery files are breaking my application
18:43FireSnakeI get 500 errors
18:51dnolenFireSnake: I think you probably need to use the Ring static files middleware. Not well documented, I would ask your question on the Ring Mailing list
18:51FireSnakemaybe I am doing this stupidly -- I am fine with include-css and include-js but they don't seem to be working
18:52FireSnakeother things are
18:52FireSnakeI am including compojure.core
18:52FireSnake:use -ing to be precise
18:52amalloyFireSnake: also, if you're interested in pair programming you should probably mention where you live. of course anything is possible with the internet, but proximity still helps
18:52FireSnakeI'm in New York
18:52FireSnakeCity/Long ISland
19:08cpfrFireSnake, nyc or long island city
19:09FireSnakenew york city or garden city on long island
19:15cpfrah ok
19:15cpfryou guys got a good clojure group over there
19:27FireSnakeyes we have rich hickey
19:29cpframong others
19:33FireSnakewhere are you cpfr
19:34cpfrlos angeles
19:34FireSnakewhat kind of programming do you do?
19:34cpfrdata mining
19:34FireSnakefinancial?
19:35FireSnakeor marketing?
19:56jweisshuh, i'm noticing in my repl, macroexpand won't expand anything inside a let.
19:56jweissit just expands let -> let* and stops
20:00jweissoh duh, it's not supposed to
20:01Clintegerhm
20:01Clintegerwhat's the best way to get clojure installed on windows? i'm obviously new here :p
20:02Clintegeri tried clojure box but its emacs is broken on my computer :|
20:08TakeVIs there anyone here who uses Penumbra with Lein?
20:38amalloy|awayClinteger: do you have either cygwin or ruby?
20:38Clintegeri have both
20:38Clintegertrying to fix emacs atm, though
20:38amalloythen probably cake is a good bet
20:38qbgClinteger: You could install Eclipse and Counterclockwise
20:38amalloy$whatis cake
20:38sexpbotcake does not exist in my database.
20:38Clintegereww, eclipse :(
20:39amalloy$google clojure cake github
20:39sexpbotFirst out of 648 results is: ninjudd/cake - GitHub
20:39sexpbothttps://github.com/ninjudd/cake
20:39amalloyit's a build tool that will fetch all the dependencies for your projects, including clojure itself
20:39Clintegeryeah i've heard about it
20:39Clintegeri didn't know how difficult it was to install though
20:39amalloyClinteger: there's a ruby gem of it
20:40lazy1What's the best way to get the body of POST request in Compojure?
20:40amalloyor you can just git-clone the cake repo and add it to your PATH
20:41Clintegerhm
20:41Clintegerwell i'm going to try to get emacs to work right now XD
21:06amalloyhurrah for emacs
21:09Clintegeramalloy if it worked, yes :(
21:10TakeVIs there any reason why lein can't seem to extract files when I run native-deps?
21:10amalloyClinteger: tbh i switched from cygwin to ubuntu not long after i started using clojure. so far the only thing i miss is netflix streaming :P
21:11Clintegeramalloy well...i would miss iTunes too much. i have an iPhone
21:11Clintegerand my computer doesn't have hardware virtualization (bah i know its old) so I can't run iTunes in a VM
21:12amalloyClinteger: http://blogote.com/2010/linux-tips/top-itunes-alternatives-for-linux.html maybe? i don't use itunes, so i can't really speak with authority
21:13amalloybut i guess you should stick to one massive change at once, like learning clojure :)
21:14Clintegeramalloy the problem is usually that they don't work with iPhone 4
21:14Clintegeror they really just sync music
21:22RaynesClinteger: You could duel boot windows or run windows in a virtualbox if the only reason you needed to run Windows was just iTunes.
21:23RaynesClinteger: Does gtkpod support iPhone4? gtkpod is the monster truck of iPod software on Linux, so if anything supports it, it'd probably be newer versions of gtkpod.
21:24Clintegeromg Raynes you're the person who inspired me to learn Clojure
21:24Rayneso.o
21:24Raynesdual*
21:24Clintegersorry, </stalker>
21:24amalloylol
21:24RaynesHow did I manage that? :>
21:24amalloyRaynes refuses to admit he's a celebrity
21:25ClintegerRaynes because you're a year younger than me and have accomplished a lot more. I've realized I have to catch up :p
21:26RaynesI have? Awesome!
21:26Clintegeryes, i'm a loser :(
21:27RaynesSurely not. None of my fans are losers.
21:27amalloyRaynes: crushing the souls of young people everywhere
21:27RaynesExcuse me, I need to feed my ego some apple sauce.
21:28amalloyClinteger: hey, since we have someone from Raynes's fan club here: i'm in the middle of adding a quick-start guide for developing sexpbot
21:28ClintegerI...don't really know what you're getting at here :p
21:29amalloyi mean, once you know something about clojure, you could contribute to his most famous project
21:29Clintegerah i see
21:29Clinteger:p yeah i'd love to help, i love irc bots >_>
21:29Raynesamalloy: I was under the impression that my most famous project was tryclojure. In principle.
21:29ClintegerRaynes maybe someday I would help out with that
21:29RaynesOr was, anyway. It was the most exciting development in the world, and then suddenly everybody forgot it existed.
21:30sexpbotClinteger: irc bots love you too
21:30Raynes$botsnack
21:30RaynesSurly amalloy didn't break that.
21:31amalloysurely not
21:31Raynessurely, even
21:31RaynesOh, but somebody did.
21:32RaynesThis is the part of Liar Liar where someone farts and I say "It was meeee"
21:33RaynesClinteger: Welcome to the wonderful world of Clojure. Enjoy the ride.
21:34Raynes$reload
21:34sexpbotReloaded successfully.
21:34Raynes$botsnack
21:34sexpbotRaynes: Thanks! Om nom nom!!
21:34RaynesGood boy.
21:35Clintegeri've always been interested in the various lisp dialects, CL just never seemed...right. lets hope clojure does.