#clojure logs

2012-10-21

00:22ForSparePartsOnce I write some java code, tell lein about it, and do lein javac, it should be available to import within my project, right?
00:23ForSparePartsI've checked, and my classes were generated, but for some reason they're not found when I do an import.
00:38ForSparePartsSo, now I've looked at the output of lein classpath: it seems that lein has not added [project-root]/classes to my classpath -- but I'm not sure how to force it to do that, or to shove the java classes in target/classes. Any ideas?
00:39mikerose357anyone tried to use drip with leiningen?
00:40callenClojure needs a mascot. Ideas?
00:40callenwhat about a cormorant?
00:41callenCrow?
00:41xeqiForSpareParts: do you set the :compile-path in the project? it should default to target/classes
00:41ForSparePartsI just tried setting that by hand to "target/classes" -- no dice.
00:42xeqiForSpareParts: what `lein version`?
00:42ForSpareParts2.0.0-preview10
00:53callenCow.
00:57tomojI just realized what datomic can do for automated testing
00:57tomojwow
01:13callentomoj: I just realized how sweet it would be to have a Clojure Cow.
01:13callentomoj: also, fixtures serve the purpose you're thinking of.
01:13callentomoj: you dump and reload the database from fixtures for stateful tests.
01:14tomojthat's what I don't want to do
01:16tomojalso nice to be able to run tests without even talking to something like a sql database
01:18SgeoClojure Cow?
01:18SgeoOh, as mascow
01:18Sgeomascot
01:19tomojis there an easier way to write #(apply vector (f (first %)) (rest %)) in core or useful?
01:22callenamalloy_: ^^ you're the one-liner hero.
01:22callenSgeo: or Crow!
01:24SgeoDoes destructuring count as easier?
01:25SgeoWait, no
01:25SgeoOh, just applying f to the first element?
01:35callendoes anybody actually do arity-based dispatch in production code? I thought people just did it through let/destructuring.
01:37tomojI do arity-based dispatch wherever I want
01:38callenI'm just wondering how applicable it is.
01:38callenI don't have any real doubts that those present are capable of exhibiting volition and making the choice to use it.
01:38callenI'm angling for a use-case.
01:39tomojyou mean a use case for (fn ([x]) ([x y])) over (fn [x & [y]]) ?
01:40callenyes.
01:40tomojthe latter is uglier (to me)
01:40tomojand has some overhead
01:41tomojperformance overhead but also sometimes cognitive overhead, imo
01:41tomojthat function also will accept and ignore more args after the second
01:43tomojalso (fn foo ([x] (foo x 42)) ([x y])) looks better to me than, uh
01:43tomojwell
01:43tomojimpossible with destructuring, huh?
01:43tomoj(fn [x & [y :as args]] (let [y (if (seq args) y 42)])) ?
01:44callenhrm.
01:44callenI'm comparing it in my head to the pattern matching in erlang and haskell.
01:44tomoj[x & [y]] is convenient sometimes but it really seems weird to me
01:44tomojit says too much
01:45tomojsince it's common it's not so bad, but then that's another cryptic thing you do
01:45tomojwell, sometimes that might be pretty much exactly what you mean
01:52callenDoes anybody know whether BSON, JSON, protocol buffers, or thrift tend to be the most compact?
01:55amalloytomoj: #(update-in (vec %) [0] f)?
01:56amalloya wasteful vec call, but shorter code
01:56tomojah
01:57tomoj(inc amalloy)
01:57lazybot⇒ 32
01:57ForSparePartsWhat's the easiest way to get lein to add a few jars to the javac step if they're not available in Maven?
01:58Frozenlo`Send them to clojars? :p
01:58callentomoj: I told you amalloy was the brevity champ.
01:59ForSparePartsIt's for jogl -- the versions in Maven are way, way out of date. I've messed around with lein localrepo, but it's a bust so far.
02:02callenApage43: you should chuck a before/after on refheap.
02:03Apage43callen: protobufs/thrift can wind up being more compact since you actually give them schema
02:03callenApage43: erm, yes, I figured but I do need SCIENCE?! for this.
02:03callenhttps://github.com/Raynes/refheap.el/blob/master/refheap.el does anyone know if this is stable/working?
02:03callenRaynes: ^^
02:03Apage43but jackson SMILE, which the cheshire JSON lib will serialize to, is pretty compact
02:04Raynescallen: Yes.
02:04Raynescallen: I maintain it.
02:04RaynesNo new commits because it hasn't broken yet. :p
02:04callenRaynes: much joy be upon you then. Thanks!
02:04Apage43it will collapse repeated strings and stuff
02:04Apage43and unlike BSON can always be round-tripped with JSON
02:06callenRaynes: btw I used your code that you wrote refheap-the-site in to help me learn clojure web dev. Much thanks for githubbing that.
02:07Apage43callen: if your data fits a schema nicely and you don't have to attach some associative map "extra junk" structure, protobufs/thrift will still pretty much always be smaller than JSON, BSON, or SMILE though
02:07callenApage43: well, more 'an likely, any dynamic extras are going to be a rolled-up hash-map assigned a meta field.
02:07Raynescallen: Cool! Happy you got some use out of it.
02:07callenApage43: I'm trying to avoid over-relying on smushed clojure data.
02:07Apage43depends how big that is
02:08Apage43if that's the -meat- of your data, then just use SMILE
02:08callenI would *like* to lift the clojure data up to the explicit level.
02:08tomojnil is never a valid attribute value in datomic, right? :D
02:10Raynescallen: At least, refheap.el worked on my old computer. I'm having some issues getting it working on this new one. Tell me if you get it working so I know I'm not crazy.
02:11callenRaynes: I'm actually a good test-case for this. I have a portable Emacs env that gets auto-deployed to a lot of computers with mac and linux.
02:12callenRaynes: bad news chief: https://www.refheap.com/paste/5998
02:12callenRaynes: worked fine :P
02:12RaynesTry credentials. ;)
02:14callennon-credential'd private worked, moving onto user/token
02:14tomojhttps://gist.github.com/05dce1cde5045996d8dc ?
02:15RaynesHow dare you gist in my presence.
02:15tomojhabit
02:15tomojgist.el doesn't even work for me
02:15tomojso I should switch
02:15amalloyRaynes: https://gist.github.com/fd3fda4c707802740874
02:16callenI actually looked into refheap.el because gist.el is broken, hahahahaha
02:16callenRaynes: something to keep in mind ^ ;)
02:16tomojsuppose you could just dissoc all the nil-valued keys (my gist has the bug where false disappears)
02:16RaynesAs long as gist keeps breaking things I will be successful.
02:16Raynescallen: It's actually a pattern. Rubeque uses refheap because gist broke the API for them somehow.
02:16RaynesI'm okay with being second best. ;)
02:17amalloy4clojure uses refheap because gist makes Raynes sad
02:17callenRaynes: worked.
02:17callenRaynes: it auth'd successfully using customize'd user and token.
02:17RaynesCool. I guess my computer's broken. :p
02:18callenRaynes: Emacs 24.1.1 + Mac, and I'm 100% positive it'll work on my thinkpad + ubuntu + xmonad too.
02:18callenRaynes: what's your stack? Got an error/repro?
02:18callenRaynes: I could look into it.
02:18Raynescallen: "Could not create connection to www.refheap.com:443
02:18callenoh cute.
02:19callenRaynes: does it over and over?
02:19callenRaynes: can you snag a debug stack?
02:19RaynesI have no clue how. I think the problem may be that I screwed up my credential stuff. I have some complex code that looks for creds in a file somewhere. Going to try nixing that and seeing if I can do an anon paste.
02:20callenRaynes: you may have brought this upon yourself.
02:20RaynesI'm a terrible person.
02:21RaynesNope. Wont do it even anonymous.
02:21RaynesHow do I get debug stuff?
02:21callenRaynes: debug-on-error
02:22RaynesCool
02:23Rayneshttps://www.refheap.com/paste/9ea29d38cac4a44a8a6f10755
02:23RaynesLot's of nils there.
02:24callenRaynes: url.el is ...not great.
02:32Frozenlo`Raynes: Personna on refheap? Well, now I don't have other choice than to try it :)
02:32RaynesI used browserid before it was cool.
02:33Frozenlo`I would argue that it was always cool.
02:33Frozenlo`I was just too lazy to try it -_-
02:37michaelr525how is persona different from the sign with (google|facebook|..) button?
02:39Raynesmichaelr525: It doesn't use either of those things.
02:40RaynesThe only reason I used persona is because they had documentation that let me implement it quickly and easily and I didn't want to spend any time at all on authentication crap.
02:42RaynesTurns out that it's also really nice.
02:42callenPersona is a lot nicer than the alternatives. It's still kinda weird.
02:42callenalso, Mozilla is closer to a proper neutral party re: auth
02:43callenI don't really trust Google/Facebook to handle identity.
02:44Frozenlo`But then you'll use gmail with persona... no?
02:45callenFrozenlo`: not a safe assumption.
02:45Apage43if you have your own domain you have the option to decide not to trust gmail at one point
02:46Frozenlo`indeed
04:25AtKaaZ,(dorun (map println '(1)) nil)
04:25clojurebotnil
04:25AtKaaZ,(dorun (map println '(1)))
04:25clojurebot1
04:26AtKaaZ,(dorun 12 (map println '(1)))
04:26clojurebot1
04:27AtKaaZ,(dorun 12 (map println '(1 2 3)))
04:27clojurebot1
04:27clojurebot2
04:27clojurebot3
04:29AtKaaZwhat do you call this, in the case of the first one being no error, something like optimistic something?
04:29AtKaaZbased on dynamic typing maybe?
04:30AtKaaZanyway, to the list with it :)) https://gist.github.com/3895312
04:40tomoj,(dorun (java.util.Date.) '())
04:40clojurebotnil
04:41ForSparePartsIs it conventional to have a core.clj in every namespace?
04:42ForSparePartsLein generates the initial namespace that way, but I'm not sure what the broad conventions are.
04:42arrdemForSpareParts: it seems to be, but you are by no means required to keep it so
04:43ForSparePartsarrdem, OK.
04:47RaynesForSpareParts: That's what lein generates and what most people do, but it's generally accepted that it is better if you come up with more meaningful namespaces.
04:49tomojI think the reason is that you shouldn't have a single-segment namespace
04:49tomojso if your library is called foo, you have to come with foo.something
04:49tomojmaybe
04:49tomojlike (use 'clojure) would be cool, but..
04:52ForSparePartsThanks, guys.
05:53alex_baranoskyis there something I should be doing to my ClojueScript data structures before passing them to JS libraries as inputs?
05:54alex_baranoskymaybe apply a ->js function like this one? … (defn ->js [v] (.-strobj v))
05:55tomojthere is a clj->js floating around
05:55alex_baranoskytomoj: does it work recursively?
05:56alex_baranoskyyeah here's one that is recursive: http://mmcgrana.github.com/2011/09/clojurescript-nodejs.html
06:23brainopiais there a function which returns always true for any arguments :)
06:26AtKaaZ,(fn [& _] true)
06:26clojurebot#<sandbox$eval27$fn__28 sandbox$eval27$fn__28@f0622e6>
06:26AtKaaZ,((fn [& _] true) )
06:26clojurebottrue
06:26AtKaaZ,((fn [& _] true) 1 2)
06:26clojurebottrue
06:27brainopiaAtKaaZ: so, nothing built-in?
06:27brainopiaat least for one argument?
06:27AtKaaZ,(#(do true #_%&) 1 2)
06:27clojurebottrue
06:27AtKaaZbrainopia, no idea to be hones:)
06:27mindbender1,(constantly true)
06:27clojurebot#<core$constantly$fn__2351 clojure.core$constantly$fn__2351@e13b3d1>
06:27AtKaaZ$find-fn 1 2 3
06:28AtKaaZthanks mindbender1
06:28mindbender1np
06:28brainopiamindbender1: awesome
06:29AtKaaZ,((constantly 1) 2 3)
06:29clojurebot1
06:29AtKaaZ$find-fn true true
06:30AtKaaZ$findfn true true
06:30lazybot[clojure.set/union clojure.set/intersection clojure.set/difference clojure.core/== clojure.core/time clojure.core/dosync clojure.core/true? clojure.core/distinct? clojure.core/boolean clojure.core/doto clojure.core/macroexpand-1 clojure.core/or clojure.core/comp... https://www.refheap.com/paste/6004
06:31AtKaaZit didn't find it:))
06:31AtKaaZoh right, because it returns a function
06:32AtKaaZwonder what $findfn would find constantly, if possible
08:21wingyi have a number and want to build a sequence that has that many elements as the nr
08:21wingyas many elements as the nr
08:21AtKaaZ,(repeat '1)
08:22clojurebot(1 1 1 1 1 ...)
08:22wingythx
08:26AtKaaZnp, ignore the ' though:)
08:57tgoossenshi
08:58tgoossensabout 15 hours ago (for me yesterday evening) I ran into a problem with string escaping
08:58tgoossensI described the problem in a blogpost http://tgoossens.wordpress.com/2012/10/20/funix-enhancing-the-linux-terminal-by-thinking-functional/
08:58tgoossenssomeone of this irc channel suggested
08:58tgoossensprn
08:58tgoossensbut that doesn't seem to work
09:05AdmiralBumbleBeetgoossens: pretty sure the problem is not string escaping
09:05AdmiralBumbleBeesince that outputs the correct string
09:06tgoossensso you get what i want to do right? (grep "test" (ls -la)) must be printed as ls -la | grep "test"
09:06AdmiralBumbleBeeyep
09:06tgoossensalso i got problems with things like
09:06tgoossens(ls Documents/)
09:06tgoossens(ls ~)
09:07tgoossensi guess i'll have to encode those symbols in some way
09:07tgoossensen decode them at the very end
09:08tgoossensor do you have other suggestions?
09:08AdmiralBumbleBeeI'm trying to figure out your code atm
09:08tgoossensok thanks :)
09:08tgoossens(ps do you like the concept? :p )
09:09AdmiralBumbleBeeit's ok I guess
09:09AdmiralBumbleBeeI never thought it was a problem that needed solving, but it's a neat idea
09:10tgoossensi'm still not sure whether people would event want to do that. But i just saw it as a great exercise for myself (after playing around with clojure for one month)
09:11tgoossensi'm starting to think that the ref i used isn't necessary
09:11AdmiralBumbleBeeit's not
09:11AdmiralBumbleBeethat's what's making me wonder if I'm not understanding the code, or if it's really goofy
09:11AdmiralBumbleBeeI'm leaning towards goofy
09:11tgoossenswhat do you mean with goofy?
09:11AdmiralBumbleBeeI see no reason to use a ref
09:11tgoossensme neither anymore
09:12tgoossensi'll change that in the future. but it's not the main concern :D
09:13tgoossensstill exercising to minimize necessity of refs :)
09:13AdmiralBumbleBeestring-to-stack should just return a new stack
09:13AdmiralBumbleBeethat's all
09:13AdmiralBumbleBeeno need for the ref
09:14tgoossensyou are absolutely right
09:14AdmiralBumbleBeeerr, list-to-stack
09:14AdmiralBumbleBeeboth actually
09:16tgoossensfor the rest? is the code a bit clean? i'm curious on how to do this better
09:16AdmiralBumbleBeeit looks like python with parenthesis to me
09:17tgoossensnever wrote python before :D
09:17AdmiralBumbleBeei'm pretty sure there's a much more succint way to write list-to-stack
09:18tgoossensif i strip off the ref stuff then it is already much cleaner no ?
09:18AdmiralBumbleBeeyep
09:19tgoossensdone :)
09:36wingyAntelopeSalad: learning how to deploy it to Heroku now
10:04antares_wingy: heya
10:04wingyantares_: hey
10:05antares_wingy: do you have 10 minutes or so?
10:05wingyantares_: sure
10:05antares_wingy: you came to Clojure from JS, right?
10:06antares_wingy: do you mind reading http://clojure-doc.org/articles/language/concurrency_and_parallelism.html and telling me how much sense it makes to you? Especially the identity/values separation part.
10:06wingysure
10:09wingyantares_: you want feedback on what could be more explanatory?
10:09antares_wingy: yes, anything you did not understand or find not explanatory enough
10:09antares_of missing
10:09antares_(missing in the structure, we obviously have TBD sections)
10:52wingyantares_: https://gist.github.com/3927167
10:54antares_wingy: I added a couple of pictures, refresh
10:55wingyantares_: i updated as well .. refersh .. easier to read
10:55hyPiRionIs there any preferred way to convert a record to a map?
10:56antares_wingy: several points are covered by earlier guides
10:56wingyi c
10:56antares_wingy: some others I will try to expand. I don't know if we can turn it into a generic concurrency tutorial, at least some basic understanding is probably necessary.
10:56hyPiRionOr well, I suppose a record is a map.
10:56wingyantares_: the picture is great
10:56wingyi understand it even more now :)
10:56wingyone picture is better than 1000 words
10:57wingymore pics!
10:57hyPiRion1001 words are better than one picture.
10:57AtKaaZlol
10:58antares_wingy: we will add more, for sure
10:58antares_wingy: and for functions such as map, filter, remove, too
10:58wingywow that would be cool
11:04wingythats why i love head first series
11:04wingythey have a lot of pictures
11:10ScorchinAnyone with any experience of using the betamax mocking library around? https://github.com/wjlroe/betamax/
11:10ScorchinCurrently getting the following exceptin: actual: java.lang.Exception: No track in cassette: example.com matches required url, method and request
11:10Scorchin(betamax/with-cassette "example.com"
11:10Scorchin (is (= nil
11:10Scorchin (:request (get-json "http://example.com&quot;)))))
11:10Scorchinthat's ^ the code I'm using that causes the exception
11:11Scorchinand I have an example.com file in resources/cassettes. Really not sure what's going on. All I want to do is mock out clj-http requests
11:11AtKaaZ,(nil? nil)
11:11clojurebottrue
11:11AtKaaZ,(nil? 1)
11:11clojurebotfalse
11:12madsy,(nil? '())
11:12clojurebotfalse
11:12AtKaaZ,(empty? '())
11:12clojurebottrue
11:12AtKaaZ,(empty? nil)
11:12clojurebottrue
11:13AtKaaZ,is
11:13clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: is in this context, compiling:(NO_SOURCE_PATH:0)>
11:50antares_wingy: better now? http://clojure-doc.org/articles/language/concurrency_and_parallelism.html
11:50antares_wingy: we probably don't want to turn this guide into a book about concurrency but I find it helpful to cover most commonly used terms. I want to heavily focus on examples, though.
11:50wingyantares_: big W on description to Concurrency :)
11:50wingyyeah
11:50antares_W for win?
11:51wingywhen multiple are making progress, whether it is via time-slicing or parallelism
11:51antares_ah, it is not capitalized
11:51antares_corrected
11:51wingyyeah short descriptions are very iseful
11:52wingyWhen multiple are making progress, whether it is via time-slicing or parallelism
11:52wingymultiple what?
11:52wingythreads?
11:53antares_corrected
11:58antares_wingy: so you think this is an improvement over what we had?
11:58wingyantares_: yeah
11:59wingyits definitely good to know the words that are being used
11:59wingyi personally find it distracting to have to lookup every word in a new tab
12:03antares_wingy: ok, cool
12:19jasonleafHi, what's the best way to print the current executing function name?
12:22gfredericksthere is no easy way to do that
12:24wingyhow do i wrap the prices in a <strong> in this hiccup template [:li {:data-role "list-divider"} "Buffet 85:- Take-away 75:-"]
12:26wingy[:li {:data-role "list-divider"} "Buffet <strong>85:-</strong> Take-away <strong>75:-</strong>"]
12:26wingyor is there an idiomatic way?
12:27mpenetwingy: a span with a class and change the style there, it is more flexible imo
12:27gfredericks"Buffet " [:strong "85:-"] " Take-away " [:strong "75:-"]
12:27wingycool
13:17goraciohi trying to call function in clojurescript something like this - service.store(data, {:width 80 :fit "scale"},callback) and seems like {} thing doesn't convert properly, i get an error
13:19goracioin js code i see cljs.core.ObjMap.fromObject(["\ufdd0'width", "\ufdd0'fit"], {"\ufdd0'width":80, "\ufdd0'fit":"scale"}) wich converts to cljs.core.ObjMap not {}
13:19goracioso how to send js object properly ?
13:20octagongoracio: https://github.com/ibdknox/jayq/blob/master/src/jayq/util.cljs is that what you mean?
13:21octagongoracio: i meant https://github.com/ibdknox/jayq/blob/master/src/jayq/util.cljs#L18
13:21goracioclj -> js ?
13:21octagongoracio: you want to pass a js object there, but you have a cljs map, right?
13:22goraciooctagon: exactly
13:22octagongoracio: so you can do (clj->js {:foo "bar"})
13:22goraciook will try :)
13:22octagonto obtain a js object {foo: "bar"}
13:23frozenlockI'm still baffled by the fact that this isn't in cljs by default. Apparently there's cases where it doesn't work.
13:23zoldar,(-> {:latitude 1 :longitude 2} ((juxt :latitude :longitude)))
13:23clojurebot[1 2]
13:23zoldar,(-> {:latitude 1 :longitude 2} (juxt :latitude :longitude))
13:23clojurebot#<core$juxt$fn__2474 clojure.core$juxt$fn__2474@7f81c084>
13:23frozenlock/s/is/are
13:24zoldar... I'm probably missing on something obvious but why the second form returns the function itself?
13:24octagonfrozenlock: i've heard this also, but i don't know what the details are
13:24hyPiRionzoldar: Look at how it expands
13:25hyPiRion,(macroexpand-1 '(-> {:lat 1 :long 2} (juxt :lat :long)))
13:25clojurebot(juxt {:lat 1, :long 2} :lat :long)
13:25hyPiRion,(-> {:lat 1 :long 2} #(juxt :lat :long)) ; should solve it
13:25clojurebot#<CompilerException java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.ISeq, compiling:(NO_SOURCE_PATH:0)>
13:25hyPiRioner.
13:25hyPiRion,(-> {:lat 1 :long 2} ((juxt :lat :long)))
13:25clojurebot[1 2]
13:26zoldarhyPiRion: ok, thanks for clarifying
13:27gfredericks-> is all syntactic so it can't tell whether or not you're using an HOF
13:35octagonis there a document that describes the model for how metadata is treated in clj?
13:35octagoni mean like under which operations should metadata be preserved, and which not?
13:37octagonalso i was looking at the source for clojure.zipper, and i see that the zipper data structure is storing its information as metadata on a vector. i haven't seen this approach anywhere else in clj so far, and i'm curious about it
13:37gfredericks,(meta (-> [2 3] (with-meta {:foo :bar})))
13:37clojurebot{:foo :bar}
13:37gfredericks,(meta (-> [2 3] (with-meta {:foo :bar}) (conj 8)))
13:37clojurebot{:foo :bar}
13:37gfredericks,(meta (-> [2 3] (with-meta {:foo :bar}) (conj 8) (empty)))
13:37clojurebot{:foo :bar}
13:37gfredericksfascinating
13:37hyPiRion,(meta (-> 2 (with-meta {:foo :bar})))
13:37clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IObj>
13:38hyPiRioncareful though.
13:38hyPiRion,(meta (-> #"foo" (with-meta {:foo :bar})))
13:38clojurebot#<ClassCastException java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to clojure.lang.IObj>
13:38octagoni'm implementing my own deftype as an immutable thing, and i want to make sure i deal correctly with metadata
13:39gfredericks,(let [meta-m (fn [x] (with-meta {x x} {x x}))] (meta (merge (meta-m :foo) (meta-m :bar))))
13:39clojurebot{:foo :foo}
13:41octagonas i understand it, the purpose of metadata is data that can be associated with a thing without altering the identity of the thing
13:41hyPiRiongfredericks: That's probably how merge operates.
13:41hyPiRion&(source merge)
13:41lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
13:41hyPiRion,(source merge)
13:41clojurebotSource not found
13:41hyPiRionbleh.
13:42gfrederickshyPiRion: I was just experimenting with a function of two objects that is conceptually somewhat symmetric
13:42chouserDoes anyone know how to set a jira ticket's status? I need to set a ticket to "Ready for Screening" but can't find any such field after clicking "edit"
13:44octagonalso why would zipper be implemented using metadata to store properties instead of as a set of protocols?
13:44chouseroctagon: zippers predates protocols
13:46octagonchouser: interesting, so it could have been done using protocols if they had existed?
13:46chouserI haven't thought about it. It's an interesting question.
13:49octagoni have a deftype that is essentially zipperlike, and i'd like to just prepopulate the metadata in my constructor to make it a zipper, but i don't really understand the rules for when metadata is preserved (like if an operation on an immutable object produces a new object, under which conditions should metadata be preserved?)
13:54muhooi wouldn't want to mess around with implementation details of zippers
14:02chrixHi, does anyone know how I can use seq-utils with Clojure 1.4? I'd like to use the seq-utils/find-first but I don't find it with the new contrib hierarchy :/
14:05gfredericksis find-first just (comp first filter)?
14:07chrixIt's the function that returns the first found item in a list.
14:12gfredericksby that description it sounds identical to first
14:12gfredericksanyhow I bet (comp first filter) does the same thing
14:13chrixthanks gfredericks, our messages passed each other :)
14:13gfredericksah
14:45antares_2nd progress report from our Clojure documentation project (http://clojure-doc.org): http://t.co/0dkLj2uw
14:45SgeoOh hey antares_, what was your Haskell question?
14:45SgeoIf you didn't already get an answer.
14:45antares_Sgeo: it turned out to be a bug in Aeson :/
14:46antares_which there is a pull request for but the maintainer is shy from pulling it in until some other guy gives it a look. But that guy does not care.
14:46antares_So I just implemented what I needed in something other than Haskell :)
14:46SgeoAh. Well, I haven't even heard of Aeson until now
14:46SgeoOh, JSON processing
14:47antares_Sgeo: thanks for remembering, though
14:47Sgeoyw
14:58edlichClose
14:59ks`What can I do with clojure script is the same as what can I do whith java-script, or just a part of possibilities?
15:13ForSparePartsWhat does a variable preceded by an ampersand (no space) in a function definition indicate?
15:13ForSparePartsi.e. (fn [a &b] ...)
15:13metellusit means that the function can take 2 or more args
15:14metellusand every arg after the first will be in a vector
15:14ForSparePartsmetellus, I thought that was for [a & b]
15:15metellusthe space doesn't make a difference
15:15ForSparePartsI was looking at the source for defn and saw this: [&form &env name & fdecl]
15:16ks`(do (fn aga [x] (reverse (first x))) aga '(1 2 3)) # returns (1 2 3) - what I do wrong ?
15:17ForSparePartsThat might not actually be the args list for defn itself, I'm still not great at reading this stuff, but it can't mean "the rest" in that context, can it? For &form and &env, I mean.
15:18metellusForSpareParts: I don't know, sorry
15:20Sgeoks_ks, your function does three things, (reverse (first x)) which is a value that gets ignored, because it's not the last value or used somewhere etc.. Then, free floating aga, whcih gets ignored for the same reason. Then, '(1 2 3), which is the last value so is the return value.
15:21SgeoForSpareParts, &form and &env are usable in macros
15:22Sgeo&form is the s-expr of the macro call, and &env is the lexical environment, a map of symbols to ... stuff. Lexical environment, as in when you're in a let form
15:22lazybotjava.lang.RuntimeException: Unable to resolve symbol: form in this context
15:23ForSparePartsSgeo, Ah, okay.
15:25Sgeohttp://ideone.com/z6MTLx
15:25ks_ksSgeo, thanks!
15:25Sgeoks_ks, you're welcome
15:27ks_ksSgeo, but if i do (do (defn aga [x] (first (reverse x))) aga '(1 2 3)) I'm getting the same result.
15:27ks_ksI think arg [x] = '(1 2 3), then it should be reversed
15:27SgeoYou're defining a function aga which returns '(1 2 3)
15:27ks_ksclj.core> (reverse '(1 2 3))
15:27ks_ks(3 2 1)
15:27ks_ks
15:28SgeoYou're not even calling aga again in the function, if that's what you meant to do
15:29ks_ksI want just get 3 as a result
15:29SgeoYou're parenthesizing wrong, I think
15:29SgeoThe (fn...) or (defn...) needs to be contained in a a set of... oh, I misread
15:30SgeoYou call functions like this (aga '(1 2 3)) not like aga '(1 2 3)
15:30ks_ksSgeo, got it :0
15:31SgeoOh, I also misread your first example
15:31ks_ks:)
15:31SgeoCool
15:31ks_ks(do (defn aga [x] (first (reverse x))) (aga '(1 2 3)))
15:31Sgeo,((fn [x] (first (reverse x))) '(1 2 3))
15:31clojurebot3
15:32ks_ksor like that
15:33ks_kswhat does it mean ',' before list ?
15:34Sgeoks_ks, just tells clojurebot to do it
15:34ks_kshm
15:34Sgeo,(println , , , , "Although, note that in Clojure, , are whitespace" , , , ,,,,,,, , , ,)
15:34clojurebotAlthough, note that in Clojure, , are whitespace
15:35ks_ks:D
15:36ks_ksI think so not only
15:36Sgeo&(println "There's also lazybot")
15:36lazybot⇒ There's also lazybot nil
15:36ks_ksclj.core> ,((fn [x] (first (reverse x))) '(1 2 3))
15:36ks_ks3
15:36ks_ksclj.core> (do (fn [x] (first (reverse x))) '(1 2 3))
15:36ks_ks(1 2 3)
15:36ks_ksclj.core> (do ((fn [x] (first (reverse x))) '(1 2 3)))
15:36ks_ks3
15:36ks_ks
15:36SgeoAnd you can trigger ##(println "lazybot from within a line of chat.")
15:36lazybot⇒ lazybot from within a line of chat. nil
15:36ks_ksOh, my head.. )
15:37Sgeoks_ks, the second one makes the function but does nothing with it
15:37SgeoAll that do does is group statements together
15:37ks_ksyep
15:37Sgeo,(do (println "Hello") (println "There"))
15:37clojurebotHello
15:37clojurebotThere
15:37ks_ksthird and first variant of decision different by a couple of commas
15:38ks_ksstrange syntax Clojure after python usage :)
15:38ks_ksso many constructions
15:39SgeoThere's a good reason for it
15:39SgeoCode is data
15:40Sgeo(+ 1 2) will evaluate to 2, but it's also a list of the symbol + the number 1 and the number 2
15:40clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.NumberFormatException: For input string: "+">
15:40Sgeo?
15:40ForSparePartsI'm trying to wrap my head around defmacro and macroexpand -- could someone explain where I've gone wrong here? https://gist.github.com/3928201
15:40SgeoBecause of this, you can write macros, which will take as arguments your code
15:40SgeoAnd return new code
15:41ks_ksyep it's great .. but I can understand this may be in 2014 :)
15:41SgeoForSpareParts, looks like test-macro will try to call 'a with the argument s
15:41SgeoYou need to return a list, not do a list
15:41SgeoYou might write (defmacro test-macro [s] `(a ~s))
15:42SgeoBut that won't give you what you expect because of something interesting that happens with `
15:42SgeoForSpareParts, try this:
15:42Sgeo(defmacro test-macro [s] (list 'a s))
15:42SgeoI think that what that does should be sufficiently clear
15:43ForSparePartsSgeo, Yep, that's perfect. Two questions:
15:43ForSparePartsIs there a difference between ' and `?
15:43ForSparePartsand
15:43ForSparePartsWhat does ~ do, in the context of the other code you suggested?
15:44SgeoBoth questions are related
15:44Sgeo` is quasiquote, which is like ` except it allows you to actually call code within it
15:44Sgeo,`(a b c ,(+ 1 2) (+ 1 2))
15:44clojurebot(sandbox/a sandbox/b sandbox/c (clojure.core/+ 1 2) (clojure.core/+ 1 2))
15:44Sgeooops
15:44Sgeo,`(a b c ~(+ 1 2) (+ 1 2))
15:44clojurebot(sandbox/a sandbox/b sandbox/c 3 (clojure.core/+ 1 2))
15:44SgeoThe ~ within the ` allows you to evaluate the code
15:45ForSparePartsAh, cool!
15:45ForSparePartsThanks!
15:45SgeoAnother thing that ` does is stick the namespace name on all the symbols
15:45SgeoThere is also
15:45ForSparePartsIs that good? Do I want it to do that?
15:45SgeoOften, yes, but there might be exceptions. You could use something like ~'foo in that case
15:46ForSparePartsOK.
15:46SgeoHaving ` stick the namespace in front helps prevent collisions between symbols in the expanded result and lexically defined symbols in the code
15:46Sgeo(let [a 1 b 2] ... )
15:46Sgeoa and b are not namespaced.
15:47SgeoNote that there are considerations you need to take in mind when writing macros
15:47SgeoI think this feature actually prevents one possible hygiene issue by yelling at you if you try it, but let me check
15:48SgeoAwesome, it does
15:48Sgeohttp://ideone.com/PgiIQd
15:49dsopis it just me or is java.jdbc not handlign escaping of tablenames, etc correctly?
15:50ForSparePartsSgeo, So, I can see it prevents you from using a in a let binding (and based on that, I can imagine some other things it would probably yell at you for), but would it be bad to force that let binding with 'a?
15:50ForSparePartsI ask because I intended to use the macros I want to write inside of functions with some arg naming conventions, to make my code more readable/writable
15:51SgeoForSpareParts, yes. What happens if the macro gets expanded inside something else that's (let [a ...])?
15:51ForSparePartsAh.
15:51Sgeo,`(let [a# 5] a#)
15:51clojurebot(clojure.core/let [a__105__auto__ 5] a__105__auto__)
15:51SgeoDo something like that
15:52SgeoOr, if you can't, because you need the same symbol across different `, do something like
15:52Sgeo,(let [a-var (gensym)] `(let [~a-var 5] ~a-var))
15:52clojurebot(clojure.core/let [G__134 5] G__134)
15:53SgeoThere's another pitfall I need to show you, hold on
15:56SgeoForSpareParts, http://ideone.com/S9NlWq
15:57SgeoAlthough, of course, note that you wouldn't use a macro for doubling stuff
15:57ForSparePartsRight.
15:57ForSparePartsDoes # mean something special in these contexts? Or is it just something you tack on to keep names unique...?
15:58SgeoIt means something special in the context of `
15:58Sgeoblah# expands in a ` to a unique symbol which is the same for all blah# within the `
15:59Sgeo(Unless you're nesting ` I think)
15:59Sgeo,`hello
15:59clojurebotsandbox/hello
15:59Sgeo,`hello#
15:59clojurebothello__53__auto__
15:59Sgeo,`hello#
15:59clojurebothello__80__auto__
15:59Sgeo,`[hello# hello#]
15:59clojurebot[hello__107__auto__ hello__107__auto__]
15:59TimMc,`[`a `a]
15:59clojurebot[(quote sandbox/a) (quote sandbox/a)]
15:59ForSparePartsAlright. Hm.
15:59TimMcheh
16:00ivan`does Clojure on Android still require sattvik's fork? and is there a patchset that I can apply to clojure master?
16:16SgeoForSpareParts, ##(`(1 2 ~(list 3 4 5) 6))
16:16lazybotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IFn
16:16Sgeoerm
16:16SgeoForSpareParts, ##`(1 2 ~(list 3 4 5) 6)
16:16lazybot⇒ (1 2 (3 4 5) 6)
16:17SgeoForSpareParts, ##`(1 2 ~@(list 3 4 5) 6)
16:17lazybot⇒ (1 2 3 4 5 6)
16:17SgeoAlso, the way to force an un-namespaced symbol through (be careful with this) ##`~'a
16:17lazybot⇒ a
16:17Sgeo##`(~'a 'a a)
16:17lazybot⇒ (a (quote clojure.core/a) clojure.core/a)
16:17ForSparePartsSgeo, ## means evaluate here?
16:18ForSparePartsSorry, I'm a little lost...
16:18SgeoForSpareParts, yeah, it's just a thing that lazybot will recognize in the middle of a line
16:18ForSparePartsOh, ok.
16:18SgeoNothing to do with Clojure itself
16:18ForSparePartsAnd @? I thought that was for deref...?
16:19Sgeo~@ is different from ~ and different from @
16:19clojurebotAlles klar
16:19hyPiRionHm, did out bot just learn that
16:19hyPiRion~@
16:19clojurebot@ is splicing unquote
16:19ForSparePartsOK.
16:19SgeoHmm, that does raise the point of absentmindedly doing ~@blah when you wanted ~(deref blah)
16:20ForSparePartsSomething else I'm having trouble googling: is there a version of map I can use on a vector to get back a vector?
16:20Sgeo,(into {} (map inc [1 2 3 4 5]))
16:20clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
16:20Sgeo,(into [] (map inc [1 2 3 4 5]))
16:20clojurebot[2 3 4 5 6]
16:21hyPiRion,(mapv inc [1 2 3 4 5]) ; usually turns out the same
16:21clojurebot[2 3 4 5 6]
16:21Sgeo(doc mapv)
16:21clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
16:21Sgeo$findfn inc [1 2 3] [2 3 4]
16:22lazybot[]
16:22ForSparePartsIs there a situation in which the two aren't equivalent? Something to do with order...?
16:22hyPiRionForSpareParts: mapv can take in anything, but spits out a vector.
16:22Sgeo,(mapv inc {1 2 3 4})
16:22clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.MapEntry cannot be cast to java.lang.Number>
16:23ForSparePartsAlright.
16:23hyPiRionSo the difference between map and mapv is essentially this: map is lazy, mapv is not. map returns a seq, mapv returns a vector. Both can take in any collection.
16:24hyPiRionBoth spits out the same result, but with different data structures.
16:35ForSparePartsSo, I've been trying to string together this stuff to write a macro I need, and I've hit another wall -- hard to describe without showing the code. Would you guys mind taking a quick look at this? https://gist.github.com/3928404
16:35hyPiRionI'll have a peek
16:36ForSparePartsThanks!
16:36ForSparePartsRight now, out-path is ignored -- I'm going to do something with it once I've got this version working.
16:36hyPiRionSo, first of all, what are you trying to achieve?
16:38ForSparePartsOne sec, I'll make a pretend thing that calls it -- I think it'll make more sense than trying to write it out here.
16:38hyPiRionok
16:44ForSparePartshttps://gist.github.com/3928414
16:44ForSparePartsBasically, I want to generate a function that will take a state and return a transformed version of the state, based on the behaviors provided in defsignal
16:45ForSparePartsactually, I guess the :a argument to defsignal should be [:a], because it could be a chain.
16:46ForSpareParts(e.g. [:a :b :c] to get {:a {:b {:c result}}}
16:46ForSpareParts)
16:46ForSparePartsEr, where states are maps. I should've said that before.
16:46hyPiRionYeah, gotcha.
16:47ForSparePartsI'm trying to hack together a FRP system. Which is way the hell over my head, but, well, this is how we learn, right?
16:47hyPiRionOne thing I wonder about. Why the multiple :a's in your example?
16:47hyPiRionAnd yeah, that's how I work at least.
16:48ForSparePartsmultiple :a's? You mean in my call to defsignal, or...?
16:48hyPiRionyeah
16:48hyPiRion(defsignal inc-a [a [:a]] [:a] (I would assume, for chaining reasons.)
16:49hyPiRionSo I suspect that the first is the input variable, and that the second is the output variable. Right?
16:49hyPiRion"variable"
16:49ForSparePartsThe first is a set of input bindings, because there could be more than one. The second is a path to an output in the resultant map.
16:49hyPiRionokay, got you.
16:50ForSparePartsAnd yeah, that was another derp on my part. Should've been [a [:a]], like you said.
16:52ForSparePartsSo, as far as I can tell, my problem right now is that I can't grab state# in the middle of evaluating the map that transforms my input bindings.
16:52ForSpareParts(which I need in order to make the closure for map)
16:52SgeoHmm
16:53SgeoThere's a way to do let stuff safely without #
16:53SgeoIf that helps
16:53hyPiRiongensym can do it.
16:53SgeoIn fact, Common Lisp doesn't have # (although there are macros to add similar features)
16:53hyPiRionsecond.
16:54Sgeo,(let [state-sym (gensym)] `(let [~state-sym (make-a-state)] blahblahblah))
16:54clojurebot(clojure.core/let [G__29 (sandbox/make-a-state)] sandbox/blahblahblah)
16:55ForSparePartsSo I wrap the whole function definition in a let that defines the symbol I want?
16:55ForSparePartsUsing (gensym)?
16:56SgeoThe let that uses gensym should not be resulting code, but executed by the macro
16:56SgeoLook again at my line. It executes a let form, and returns a let form
16:56ForSparePartsRight, that's what I thought.
16:57ForSparePartsBut in my case, I'd execute a let form and return a defn form, right?
16:57SgeoI haven't been paying close attention, but that sounds about right
16:59hyPiRionhttps://gist.github.com/3928475
16:59hyPiRionForSpareParts: Look at that, it expands from what I can see correctly.
17:01ForSparePartshyPiRion, Still not totally clear on what ~@ does
17:01SgeoForSpareParts, it splices a lis
17:01Sgeolist in
17:01SgeoSo effectly instead of bringing in a list, it ...
17:02Sgeo,`(a ~@'(b c d) e)
17:02clojurebot(sandbox/a b c d sandbox/e)
17:02hyPiRionIt removes a set of parens from the part after ~@.
17:02hyPiRionor brackets.
17:02hyPiRion([])
17:04xeqihttps://www.refheap.com/paste/6012 is what I came up with
17:04ForSparePartsOK. I'm still parsing what you did in your gist, but I'm learning a lot in the process.
17:04ForSparePartsEr, that was directed at hyPiRion.
17:04hyPiRionForSpareParts: Wish I would've time to explain. Unfortunately I have a deadline I have to reach =/
17:04ForSparePartshyPiRion, Not a problem at all! You've been super helpful!
17:05hyPiRionForSpareParts: Hopefully you've got something to digest :)
17:05ForSparePartsAbsolutely : D
17:09SgeoIs that namespaced inc-a acceptable in a defn?
17:11ForSparePartsxeqi, would your solution work if there were multiple input bindings, i.e. [a [:a] other-binding [:b :c]]? It seems like it would only handle the one.
17:11xeqiit was limited to one
17:12ForSparePartsOK.
17:12xeqiwould end up with a partition similar to hyPiRion's
17:12ForSparePartsRight.
17:15frozenlockI have an installation wrapper asking me for the main class of my ubejar. I assumed it was my_app.core, but it throws an error. Am I missing something?
17:35kmicu, (+ nil 1)
17:35clojurebot#<NullPointerException java.lang.NullPointerException>
17:38S11001001,(do (use 'clojure.core.incubator) (doc -?>))
17:38clojurebot#<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/core/incubator__init.class or clojure/core/incubator.clj on classpath: >
18:04ivan`I typed (range) in nrepl.el, hit ctrl-c ctrl-b to interrupt, and now Emacs is permanently locked up
18:05ivan`oh fixed after I killed java
18:08SgeoKilling Java is always the best idea :D
18:18ivan`appears to be fixed in 0.1.6-preview
18:35Sgeo,`do
18:35ivan`anyone know what stopped vanilla clojure from supporting Android? doesn't look like a lot of changes, other than the com.android.dx import
18:35clojurebotdo
18:35Sgeohmm
18:35Sgeo,(clojure.core/do 1 2)
18:35clojurebot#<CompilerException java.lang.RuntimeException: No such var: clojure.core/do, compiling:(NO_SOURCE_PATH:0)>
18:35SgeoHmm.
18:35SgeoI don't like this
18:36ivan`&(do #())
18:36SgeoNo complains about (def do 5) under ideone.com
18:36lazybot⇒ #<sandbox7657$eval318214$fn__318215 sandbox7657$eval318214$fn__318215@47a729>
18:36SgeoBut how do I get back to the old do?
18:37SgeoOh, apparently, I simply can't refer to my custom do directly
18:37ivan`you want to remove `do` from your namespace?
18:37ivan`oh
18:38SgeoIf I :refer-cloure :exclude [+], I can have my own + in the namespace. I don't think do and other special forms work by the normal rules
18:39amalloySgeo: they don't
18:39gfredericksspecial forms are special
18:40SgeoIf I'm doing code-rewriting, and see a do symbol, I can assume that it's actually the special form?
18:40SgeoAnd is there a function to ... get the namespace that a symbol resolves in?
18:40gfredericksas long as it's at the beginning of a list
18:40ivan`gah
18:40gfredericks,(namespace (resolve 'first))
18:40clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var cannot be cast to clojure.lang.Named>
18:40gfredericks,(.namespace (resolve 'first))
18:40clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: namespace for class clojure.lang.Var>
18:40gfredericks,(.getNamespace (resolve 'first))
18:40clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: getNamespace for class clojure.lang.Var>
18:40gfrederickswell I'm sure there's something like that.
18:40amalloy/ban gfredericks
18:41amalloy&(keys (meta #'first))
18:41lazybot⇒ (:ns :name :arglists :added :static :doc :line :file)
18:41SgeoAha.
18:41SgeoNeat
18:41gfredericksdoesn't being interned imply more than just some metadata?
18:42gfredericksor is that not from the var's perspective?
18:42SgeoMeans namespace contains it, I think
18:42Sgeo,(keys *ns*)
18:42clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Namespace>
18:42ivan`(remove-ns 'user) ; fun times after doing this
18:44SgeoI take it clojurebot will block (remove-ns 'sandbox)
18:44Sgeo,(remove-ns 'sandbox)
18:44clojurebot#<Namespace sandbox>
18:44Sgeo..?
18:44Sgeo,(+ 1 1)
18:44clojurebot2
18:44Sgeo(doc remove-ns)
18:44clojurebot"([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
18:44Sgeo,*ns*
18:44clojurebot#<Namespace sandbox>
18:45Sgeo,(remove-ns 'user)
18:45clojurebot#<Namespace user>
18:45Sgeo,(remove-ns 'asdf-is-a-common-lisp-thing)
18:45clojurebotnil
19:02tomojso suppose (= 10 (let [[a b (c :or 10)] [1 2]] c))
19:03tomojcan has (nil? ((fn [x (y :or nil)] y) 42)) ?
19:03tomojamalloy: ^ (s/:or// for your proposal)
19:04amalloytomoj: i doubt the function one will happen
19:04tomojit would require changes to fn, I think?
19:05tomojbut you could have (fn [x & [(y :or nil)]]) with no changes :/
19:07amalloytomoj: the changes to fn you could do yourself easily enoguh, and add, say, fn+. changing the rules of destructuring at all (other) destructure points needs help from core
19:08amalloyand i don't think :or would appear in function signatures even if it appeared in other places, just like :as isn't allowed to bind all the function args
19:12tomojdoesn't seem worth it to get it in fn
19:12tomojor to write fn+
19:12tomojbut nice to have it in all non-root binding forms
19:14amalloyi'm not sure it really belongs in vectors either
19:15amalloy(let [[a (b :or 5)] x] [a b]): what does this return when x is nil? or when it's '[foo nil]?
19:16tomojrespectively [nil 5], '[foo nil]
19:16tomojI'd think
19:19amalloyagreed, and yet you can't really get that without changing how vectors are destructured. right now it's with nthnext/nth, which doesn't have a not-found argument
19:20tomojnthnext doesn't, that's a problem?
19:21tomojnth does
19:21SgeoCommon Lisp: http://ideone.com/jpMzYT
19:21SgeoClojure: http://ideone.com/48IlsM
19:21tomojnthnext just returns nil if the index is too big
19:21tomojdoesn't seem like a problem to me, but I haven't thought about what you'd have to change
19:23tomojSgeo: wow, how do you fix that bug in cl?
19:24antoineBSgeo: what is the difference?
19:24SgeoWithin a package, avoid fletting a name that is used by a function in the package, I think
19:26SgeoIn Common Lisp, the reader gives all symbols a package name (what Clojurists would call a namespace) (I might be wrong about terminology). In Clojure, symbols are only namespaced if explicitely namespaced
19:26SgeoBut in Clojure, ` namespaces all the symbols it sees.
19:27antoineBok
19:27SgeoSo, in Clojure, in the letfn, f is the symbol that the letfn sees and exposes, but f-macro emits code referring to user/f (or whatever the current namespace is)
19:28SgeoIn Common Lisp, the package is the same for both fs, so the flet overwrites the visible f lexically.
19:28SgeoI'm not entirely certain that that's a perfect and perfectly accurate explanation, but it is my understanding.
19:28tomojso that bug won't happen for users of your library, since their locals have a different package
19:29SgeoYes.
19:29SgeoAlso, when I first tried to write it, I used let, but that was a mistake, because functions are in a different namespace from other things. (f f) in Common Lisp refers to two different fs. The f function, then the f value.
19:30SgeoSince flets and labels aren't used as often as let, that probably helps ameliorate the problem.
19:30SgeoAnd is in fact the reason that some people believe that CL-style macros are only acceptable in a Lisp-2.
19:33SgeoI vaguely remember seeing an SO question where someone porting a CL macro stumbled upon the issue
19:34SgeoI have to admit, I initially hated the way Clojure did things, but it makes far more sense to me now
19:34Baldanders`There's a semi-famous c.l.l Erik Naggum rant on the subject of hygiene and Lisp-Xs. He coul be a bit strong n how he put things, but it's interesting reading, IMHO. Of course this predated Clojure by a bit.
19:35tomojdoes clojure satisfy his concerns?
19:36Baldanders`I think it does so a lot better than Scheme does, if I understand what Clojure does correctly.
19:37Baldanders`But I am still learning Clojure. And I wouldn't presume to know what Erik would say about it ;).
19:37SgeoBaldanders`, Scheme side-steps the issue entirely by not having CL-style macros, but its own thing which I don't understand at all.
19:38SgeoWhich apparently gives perfect hygiene but ... is harder to understand.
19:38Baldanders`Well, a lot of Schemes do have CL-style macros alongside hygienic macros.
19:42tomojI hope someone implements expansion-passing style for clojure
19:42Sgeoexpansion-passing style?
19:42tomoj(then I won't have to try to understand the paper..)
19:43tomojgoogle has the correct results on top
20:41amalloySgeo: i read http://www.nhplace.com/kent/Papers/Technical-Issues.html a few weeks ago. long paper about the tradeoffs between lisp-1 and lisp-2. (a) it exposed me to some dangers i hadn't thought about in lisp-1, and (b) helped me see how clojure's model addresses a lot of the lisp-1 problems
20:43unnaliSgeo, tomoj: late to this party, but to get the equivalent of the CL code: http://ideone.com/zdcQOo
20:43unnali(i.e. just don't use syntax-quote due to the fact that it puts in namespaces)
20:44Sgeounnali, `(~'f ~x) should also work, I think
20:44unnalitrue!
20:44SgeoBut I feel like 11 is the more correct answer
20:44unnaliI'd be inclined to agree.
20:57frozenlo`Is there a way to make 'spit' create directories on the fly?
20:57amalloy$javadoc java.io.File
20:57lazybothttp://docs.oracle.com/javase/6/docs/api/java/io/File.html
20:58amalloyhm, i thought there was a method to create parents, like mkdir -p
21:09frozenlo`Well at least I can create a directory with (.mkdir (clojure.java.io/file <some-path>...
21:10amalloyoh, mkdirs
21:11frozenlo`Wait, I think make-parents in clojure.java.io could do it.
21:11frozenlo`Yup it works :)
21:11frozenlo`Thanks for the hints!
21:30ivancan I monkeypatch something in a namespace before it loads?
21:31ivanit's too late after it loads; a bunch of functions then reference the old function
21:31ivan(also does anyone else use Windows and never want to see \r\n printed anywhere?)
21:36Sgeoivan, I _think_ in newer Clojure you actually can change the function
21:36SgeoAfter other things use it
21:36SgeoI'm not sure
21:36SgeoUnless it's actually called upon loading the namespace, of course
21:36Sgeo(doc alter-var-root)
21:36clojurebot"([v f & args]); Atomically alters the root binding of var v by applying f to its current value plus any args"
21:36ivanoh, thank you
21:36Sgeoyw
21:36SgeoI might be wrong though. And/or it might be newer versions of Clojure.
21:38Raynesivan: The idea is that usually you don't refer to the thing inside the var, but the var itself which is mutable. You can use binding to change explicitly dynamic vars, and with-redefs and alter-var-root to change all of them.
21:38danlarkinplease don't go "monkeypatching" namespaces
21:39danlarkinyou're going down the wrong path if you think you have to do that
21:39SgeoI take it not a fan of Smalltalk or Ruby?
21:39RaynesI'm sure there are a interesting places where that'd be useful. Especially for experimentation and such.
21:40RaynesMonkeypatching-like things have been useful for me for sandboxing and such.
21:40ivanmaybe someone should not have implemented OS-inconsistent printing behaviors then
21:40RaynesThere are usecases for this sort of thing. Not sure that is one of them.
21:40TimMcivan: What's the specific problem?
21:41danlarkinthere's like one or two usecases
21:41danlarkinand I'm gonna assume if he doesn't know about alter-var-root he's not tackling them
21:41RaynesI think it's better if he just explains his problem and let's people help him with a solution.
21:42ivanTimMc: nREPL in Emacs showing ^M (and I want to see ^M in files); files created with \r\n
21:42ivanbut I should have my own printing functions and fix everyone's bugs, sure
21:42TimMcAnd it's doing this because you're on Windows?
21:42danlarkinno, you should submit a bug report
21:42ivanTimMc: yeah
21:43danlarkinnot going to some assbackwards function injection nonsense
21:43ivanit's just for playing around until I find a better solution
21:43TimMcSounds fine for your REPL, I guess.
21:44danlarkinif you solve it with hackery then it's solved for you, but if you submit a bug report (or better yet a patch) then it's fixed for everyone
21:44TimMcWhy not both?
21:44danlarkinbecause monkeypatching is stupid and wrong
21:44RaynesWow.
21:45danlarkinhahah
21:45RaynesRawr.
21:45TimMcdanlarkin: Look, if he's not shipping it...
21:46SgeoI should make a language where monkeypatching is the ONLY way to do things
21:46danlarkinTimMc: that's how it starts..
21:46TimMc(I assume "he", because "ivan".)
21:46danlarkinslippery slope!
21:46ivanmonkeypatch main to get started
21:46TimMcSgeo: JS? Ruby?
21:46SgeoTimMc, more extreme
21:49SgeoAlong the lines of monkeypatching main, yeah
22:02yediis prismatic's graph library theoretically similar to using promises
22:10ivanyedi: I think it's far more advanced
22:10ivanyedi: their graph library also implies a global view everything, not necessarily the case with promises
22:10ivanthough maybe they support working on a graph with unknown subgraphs, I dunno
22:14ivanyedi: I think of promises as going in the reverse direction of Graph, with a lot less global knowledge
22:37tomojprismatic's graph library is released?
22:37tomojor just described?
22:42ivanjust described
22:44ivanhttps://www.youtube.com/watch?v=A7de6pC-tnU I hope Christopher Petrilli is going to the conj as the official conj bootlegger
22:53ynnivis there a quickstart for clojurescript that gets me from clojure forms to a JavaScript string without all the tooling?
22:53ynnivstarting off with a command line invocation of a compiler that relies on an environment variable to a checked out repository seems… a little heavyweight
22:55ivanynniv: https://github.com/emezeske/lein-cljsbuild
22:55ynnivmaybe parenscript has spoiled me, but anything involving "lein" is not what I'm looking for
22:56ivanwell, it can recompile your code in the background
22:56ynnivI'm at the repl. I have clojure forms. I would like a JavaScript string. go.
22:57ynnivI don't want to manage external tooling, and I'm serving pages out of compojure
22:57xeqihow are you getting the compojure dep?
22:58ynnivlein deps? I don't understand your question.
22:58xeqiI misread - anything involving "lein" is not what I'm looking for as - not using lein
23:00ynnivoh, no. I mean, I want to load a library, pass it some forms, and get a string. I don't want to interact with an external process, or pre-compile js files.
23:00xeqifrom a repl, the closest might be https://github.com/cemerick/piggieback
23:00xeqithough thats still not quite what you want
23:00ivanI don't think ynniv wants a CLJS REPL, just a function to compile forms
23:01ynnivivan: *nod*
23:06ivanynniv: you might not like the size of the output before it's run through Closure Compiler's advanced_optimizations passes
23:06ivanI can't find the function you're looking for compiler.clj
23:06ivanperhaps because ClojureScript participates in Closure's multi-file goog.require/goog.provides system
23:08ynnivyeah, reading the source keeps going in circles involving shell outs. this looks far more tangled than I was hoping
23:09xeqiwonder if (partial cljs-eval (rhino-repl-env)) ; https://github.com/cemerick/piggieback/blob/master/src/cemerick/piggieback.clj#L77
23:10xeqi* wonder if ... could do whats desired
23:11ynnivyeah, that calls cljs.repl/evaluate-form