#clojure logs

2015-10-30

00:55kenrestivowhy do so many people use (alter-var-root #'system component/start)) instead of (defonce system (atom nil)) (swap! system component/start) ?
00:55kenrestivois there any real advantage to using alter-var-root instead of a clojure ref type?
01:39pyonHow do I case-analyze a sequence, depending on whether it's empty, or it has a head and tail?
01:45TEttingerif you mean for a function checking its args, there's pre and post conditions
01:45TEttingerin general, checking for empty is done with
01:46TEttinger,(if (seq []) "it has stuff in it" "it's empty")
01:46clojurebot"it's empty"
01:46TEttinger,(if (seq [:a]) "it has stuff in it" "it's empty")
01:46clojurebot"it has stuff in it"
01:46TEttingerthe head and tail stuff is more interesting
01:47TEttingerjustin_smith may have used preconditions before, or quite a few other people I'm sure
01:50pyonAh!
01:50pyonTEttinger: thanks!
01:53TEttinger,(defn checker [coll] (if (and (seq coll) (rest coll)) "it has a head and tail in it" "it has one or fewer elements"))
01:53clojurebot#'sandbox/checker
01:53TEttinger,(checker [])
01:53clojurebot"it has one or fewer elements"
01:53TEttinger,(checker [:a])
01:53clojurebot"it has a head and tail in it"
01:53TEttingerah I screwed up
01:53TEttinger,(rest [:a])
01:53clojurebot()
01:53TEttinger,(defn checker [coll] (if (and (seq coll) (seq (rest coll))) "it has a head and tail in it" "it has one or fewer elements"))
01:53clojurebot#'sandbox/checker
01:53TEttinger,(checker [])
01:53clojurebot"it has one or fewer elements"
01:53TEttinger,(checker [:a])
01:53clojurebot"it has one or fewer elements"
01:53TEttinger,(checker [:a :b])
01:53clojurebot"it has a head and tail in it"
01:54pyon:-O
01:54TEttingerrest will return an empty seq if there's nothing to get after the head
01:54TEttingercalling seq on an empty sequence returns nil (which is considered false in conditions)
01:55TEttingerbut the empty sequence itself is not nil. most clojure core fns use that idiom of calling seq on any collection they are given to ensure it is treated as a seq (not some arbitrary type) but also to make sure it isn't empty
01:56pyonAh, makes sense!
02:03pyonIn Emacs' clojure-mode, what's the command for firing the REPL?
02:22pyonIs there any pastebin site with Clojure highlighting? Which pastebin site is preferred here?
02:33pyonI'm trying to translate a toy program to symbolically compute derivatives of monomials and polynomials from Haskell ( http://lpaste.net/144231 ) to Clojure ( http://lpaste.net/144242 ), but the translated version doesn't work. Could anyone explain to me why?
02:36pyonI'm representing polynomials as sequences of monomials (summands), and monomials as sequences of symbolic factors.
02:56neoncont_pyon: one thing that stands out to me is the second argument to map. It seems like from your base case, mono returns a seq, however map takes a function and a coll
02:56pyonOh.
02:56pyonWhat's the difference?
02:57neoncont_I'm still getting used to this myself. It's a big difference from other lisps: http://clojure.org/sequences
02:57pyonChecking. :-)
02:57pyonAlso, it strikes me as weird that a seq isn't a coll.
02:57pyonAren't sequences particular kinds of collections?
02:59neoncont_That's a good point, actually. I would expect seq to be a subtype of coll, now that you mention it
03:01neoncont_Dang. My cafe's closing now and I gotta go. I'm curious the answer myself :)
03:49owlbirdIs there some tools that can generate SQL like mybatis' OGNL ?
03:52owlbirdwhich can switch on/off SQL segments with a set of k/v pair
04:27TheBraynhi
04:31TEttingerhi TheBrayn
04:37pyonHow do I get a string from a sequence of characters?
04:38oddcullyclojure.string/join or apply str
04:38pyonThanks!
04:38oddcully,(apply str (seq "zerg"))
04:39clojurebot"zerg"
04:42Glenjaminhi all, anyone know if there's a way to get lein to shut up about repositories in profiles.clj?
04:43TEttingertechnically, rm -r /*
04:44TEttingerit would also make everything else shut up, but still
05:27yenda(apply max '(1 2 3 1))
05:27yendais it better than (reduce max '(1 2 3 1)) ?
05:31Bronsayenda: apply max still ends up using reduce max internally
05:34SchrostfutzIs there a syntax to put the individual values of a sequence to parameters?
05:35SchrostfutzSo that I can do (max [1 2 3])
05:35spradnyeshgetting the following "failure" when using expectations (lein autoexpect)
05:35spradnyeshin expected, not actual: [{:close 94.2, :low 92.1, :open 93.6} {:close 95.2}]
05:35spradnyeshin actual, not expected: [{:open 93.6, :close 94.2, :low 92.1} {:close 95.2}]
05:35spradnyeshany idea what might be going wrong? i'm stumped
06:30spaceplukSchrostfutz: apply?
06:32hyPiRionspacepluk: might be a floating point issue
06:33pyonI want to make a macro that's used like this: (deffoo bar [[0 :a :b] [1 :c :d] [2 :e :f]]), and expands into (defstruct bar0 :a :b) (defstruct bar1 :c :d) (defstruct bar2 :e :f). How do I do this?
06:36pyon(Well, it doesn't have to be exactly like this. But, in general, what I want is the ability to “append suffixes” to identifiers, as in bar0, bar1, bar2.
06:36pyon)
06:38hyPiRionpyon: something like (defmacro [prefix & elems] `(do ~(map (fn [[suffix & items]] `(defstruct ~(symbol (str prefix suffix)) ~@items)))))
06:38pyonhyPiRion: Thanks!
06:40hyPiRionhm, that didn't work as expected
06:40pyonMmm...
06:41hyPiRionpyon: (defmacro deffoo [prefix & elems] `(do ~@(map (fn [[suffix & items]] `(defstruct ~(symbol (str prefix suffix)) ~@items)) elems)))
06:41hyPiRionThen (deffoo bar [0 :a :b] [1 :c :d] [2 :e :f]) should expand into (do (clojure.core/defstruct bar0 :a :b) (clojure.core/defstruct bar1 :c :d) (clojure.core/defstruct bar2 :e :f))
06:42pyonTrying.
06:42pyonIs there a reference explaining what `, ~ and @ mean?
06:44hyPiRionpyon: there's a long text on it here: http://www.braveclojure.com/writing-macros/
06:44pyonhyPiRion: Thanks, will read.
06:44hyPiRionBut essentially, ` is like '. Inside a `, a ~ will actually be evaluated, and ~@ will be evaluated and sliced in
06:45hyPiRionso `(foo ~(+ 1 2)) == '(foo 3) and `(foo ~@(map inc [1 2])) == '(foo 2 3)
06:45hyPiRionspliced in*
06:47hyPiRionIt's good to try it out with macroexpand and macroexpand-1
06:47pyon:-O
06:58pyonCan I call the fields of a struct :0 :1 :2 etc.?
06:58pyon(This basically means “I don't want users to directly set these”.)
07:02poweredusers of the library?
07:03pyonYeah.
07:16pyonWhat exactly does this syntax mean? (defmulti area (fn [share & _] shape))
07:17pyonWhat I don't understand is what the anonymous function there is for.
07:19oddcullys/share/shape/ right?
07:20oddcullythe result of this function call is used to pick the according defmethod
07:20pyonoddcully: Oh, yes, share was a typo
07:21pyonWhat is the function applied to?
07:21pyonThe argument list?
07:23oddcullypyon: http://clojure.org/multimethods
07:23poweredthe function is applied to the arguments of the original function call I think
07:49pyonIs there any more direct way to access the elements of a struct than ((accessor foo :bar) my-foo) ?
07:49pyons/elements/fields/
07:51rarebreedpyon you mean get a field from a defstruct?
07:52pyonYeah.
07:52rarebreedif you're using a defrecord, you can treat it like a map: (:bar my-record)
07:53rarebreeddefstructs have kind of been superceded by defstructs, but I believe they are the same
07:53pyondefstructs by defstructs?
07:53rarebreeddefrecords are kind of the replacement for defstructs. they implement PersistentHashMap, but you can attach defprotocols to them
07:54rarebreedand under the hood, they are more performant
07:54pyonOh.
07:54rarebreedsince they actually create a Java class (which is why you create a defrecord with (MyRecord. foo bar baz)
07:55pyonWhat does `defrecord` look like?
07:55pyonI mean, usage.
07:55rarebreed(defrecord Character [intelligence Strength Dexterity])
07:55rarebreed(Character. 10 15 13)
07:56rarebreedoops
07:56rarebreed(def character (Character. 10 15 13))
07:56pyonAh, nice. :-)
07:56pyonThanks.
07:56rarebreed(println "strength is:" (:strength character))
07:56Empperinot a proper D&D character!
07:56Empperimissing wisdom, charisma and endurance!
07:56rarebreedI'm old skool Empperi, I haven't played D&D since 1st ed
07:57rarebreed:p
07:57EmpperiI've played D&D from 1st ed to 5th ed
07:57Empperi:)
07:57Empperiand even 1st ed had six attributes :)
07:57pyonCan I give the fields of a record numeric names?
07:57rarebreedI bought Pathfinder, but never played it :p
07:57frenataEndurance...?
07:57Emppericonstitution
07:57Empperisorry :)
07:57Schrostfutzspacepluk: thanks
07:57pyonI'm going to autogenerate lots of records in a macro, I can't possibly come up with “normal” names for their fields.
07:58rarebreedpyon, you mean have a numeric type for the field? never tried...but it should be
07:58rarebreedpyon, you could always "keywordize" them. (keyword some-symbol)
07:58pyon`(keyword 0)
07:59pyonAnyway, (keyword 0) returns nil.
07:59pyonDitto (keyword n) for any number n.
07:59oddcully,(->Character 1 1 1)
07:59clojurebot#error {\n :cause "Unable to resolve symbol: ->Character in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: ->Character in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: -...
07:59pyonOh, it was ,.
07:59pyon,(keyword 0)
07:59clojurebotnil
08:00rarebreedinteresting, I didn't know that with keywords
08:00rarebreedalso, you can pass a map to a defrecord
08:00rarebreed(map->Character {:strength 10 :intelligence 12 :dexterity 15})
08:01oddcully,(map->Character {:strength 18/00})
08:01clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
08:01oddcullythere! no dnd!
08:01rarebreedthat's really old skool oddcully :)
08:02pyonI guess I could always prepend some fixed string, like `field`, to the field's names.
08:02pyonfield0, field1, field2...
08:03rarebreedit's a hack, but you could do this: (keyword (str 0))
08:03pyon:-O
08:04oddcullyarent those then just indices and is all your struct/type/record just a vector?
08:04oddcullywhy name it, it the name has no relevance?
08:04rarebreedI think you can't keyword a bare number, because a number by itself is not a valid symbol (the parser would have to interpret it as a literal)
08:05pyonoddcully: Well, sometimes I want two structs to have the same number of fields. Even then, I want to treat them as different entities.
08:05pyonThat's why I can't use vectors.
08:05rarebreedwhich i think is why you also cant do (keyword '0)
08:05pyonThough I guess I could use a struct containing a single vector.
08:05pyonAnyway, this thing really has to be amenable to code generation.
08:09pyonI've updated my Stack Overflow question: http://stackoverflow.com/q/33431224/46571
08:09pyonThis is assuming that I've understood multimethods right.
08:12tommohi guys, i'm using prismatic schema to define a simple schema, but i'm not sure how to validate a schema-in-a-schema, can anybody help out?
08:13rarebreedpyon I only skimmed your SO question. Is defpoly generating a bunch of vars? ie, is step-n2-0 a var that gets defined by step?
08:14rarebreedif so, then yeah, your defmulti and defmethods looks ok
08:15pyondefpoly is generating structs
08:15pyonOh, I want all the multimethods to be generated by `defderiv`.
08:16pyondefpoly probably also needs to generate an auxiliary var, saying which struct fields are r's and a's.
08:17pyonOtherwise defderiv couldn't work.
08:17rarebreedso, if you use defrecords instead of defstructs, defrecords actually create a type
08:17rarebreedso for your dispatch function, instead of second...I would make the dispatching function type or class
08:17pyonAh!
08:17rarebreedthen you can dispatch based on the type...ie step-n2-0 (if it's a defrecord) is actually a concrete type that you can match on
08:18pyonI only need to dispatch on the class of the second argument, though.
08:18pyonSo, would it be (comp class second) ?
08:18rarebreedyeah you could do something like that
08:19rarebreedor if you want to be more performant....create a defprotocol that has a method....undo-step
08:19rarebreedand make all your defrecords implement it
08:20rarebreed(defprotocol Derive (undo-step [this]))
08:20rarebreed(defrecord step-n20 [...]
08:20rarebreed Derive
08:20rarebreed (undo-step [this] ...))
08:21pyonI'd be happy if it works at all. I'll worry about performance later.
08:21rarebreedhehe...Donald Knuth "premature optimization is the root of all evil" :)
08:21pyon:-)
08:52steerioHi! I've started having NoClassDefFoundErrors for an extend-type out of nowhere. It has worked so far, and I haven't changed anything around it.
08:52steerioI am using the clojure.data.json/JSONWriter protocol, and it doesn't find the underlying interface.
08:52steerioHaven't updated the library.
09:02steeriosolved. :)
09:05pyonClasses can be used as keys in maps, right?
09:05pyonI mean, classes themselves, not instances of them.
09:13mpenet,(hash java.util.Date)
09:14clojurebot1173145383
09:14mpenetif it has a hashCode it can I guess
09:19pyonWhat does the following mean? “CompilerException java.lang.RuntimeException: Can't create defs outside of current ns, compiling:(NO_SOURCE_PATH:70:1) ”
09:44snowellpyon: It means you have a (def) outside of your (ns) declaration
09:50pyonJust to be sure, this macro is okay, right? (defmacro data-ctor [name & args] `(defstruct name ~@(map (comp keyword str) (take (count args) (range)))))
09:50pyonIt's supposed to be used like this: (data-ctor foo :a :b :c)
09:50pyonAnd it's supposed to expand to (defstruct foo :0 :1 :2)
09:52magopianhello there, I'm having a real hard time configuring my environment to have: 1/ figwheel 2/ vim connect to the repl (using vim-fireplace)
09:52magopianwhat i've tried so far: launching "lein repl", and trying the method in https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl (but I get FileNotFoundException Could not locate figwheel_sidecar/repl_api__init.class or figwheel_sidecar/repl_api.clj on classpath.
09:53oddcullymagopian: do you have this problems since figwheel 0.4.x?
09:53magopianuncommenting the ":nrepl-port" figwheel option in my project.clj (I can connect my vim to it, but I can't evaluate anything)
09:53oddcullymagopian: also there is #clojurescript
09:53magopianoddcully: i'm a noob, I'm just trying to set all that up (I've started from https://github.com/bhauman/lein-figwheel and wandered quite a bit to investigate/test various options)
09:54magopianoh, maybe I should be asking in #clojurescript then, thanks :)
09:54oddcullyno problem. there is much overlap with both channels, but it's more of a cljs problem
09:55pyonI have a sequence of length n. What's the shortest way to turn it into :0 :1 :2 :3 ... :(n-1) ?
09:55oddcullymagopian: i use a pachted fireplace for figwheel and i had to add some cider-stuff in my configs since 0.4.0
09:55pyonI came up with (map (comp keyword str) (take (count original-sequence) (range)))
09:56pyonBut there has to be something smaller.
09:56oddcullyshorter: (range (count n))
09:56pyonAh!
09:57magopianoddcully: sounds painful :/
09:58pyonWhat's the easiest way to map a macro, rather than a function, to the elements of a list?
09:58oddcullymagopian: well i just submoduled another fireplace into my ~
09:59oddcullymagopian: and it takes about 5 lines of changes to the default figwheel to have it going
09:59pyons/map/apply/
09:59pyonI want something like (apply some-macro some-list)
10:00magopianoddcully: well, ok, thanks :)
10:00magopiani'll try downgrading to figwheel 0.4.0 then?
10:00magopianor before?
10:01gfrederickspyon: what's your use case?
10:01magopian0.3.9
10:01pyongfredericks: let me create a paste
10:01pyongfredericks: http://pastebin.com/nRJt082V
10:02pyonIf another pastebin site is preferred here, please do tell me.
10:02oddcullymagopian: the patched fireplace was needed before
10:02magopianoh
10:02magopianman, this is sad :/
10:03oddcullymagopian: https://github.com/tpope/vim-fireplace/pull/222
10:03magopiani was working on a "show and tell" demo, to show my colleagues about clojurescript, and how easy it is, and how powerful with the connected repl and everything
10:03magopianbut seems it's not quite there yet
10:03snowellpyon: Lots of us like refheap.com, mostly because it has good clojure support
10:03oddcullyclearly cljs fault ;P
10:04magopianoddcully: that's not what i'm saying:)
10:04magopianjust saying that i'm not sure i'll be able to demonstrate how easy and shiny it is (right now :)
10:04pyonsnowell: Nice, will take that into account. :-)
10:04oddcullywell there are a) other means to connect vim to a repl and b) other editors
10:05gfrederickspyon: you might be able to replace (apply data-ctor ctor) with `(data-ctor ~@ctor)
10:05gfredericksalso (cons `data-ctor ctor)
10:05gfrederickswhichever you find more readable
10:07oddcullyalso i think fighweel/devcards power lessens the need for e.g. fireplace. you are one save away to see the whole world unfold in your browser (with devcards even parallel universes)
10:07magopianoddcully: indeed
10:07pyongfredericks: Ah, nice, thanks!
10:07magopiani need to try devcards, haven't looked into it yet
10:07magopianconnecting the repl has nice advantages though, like querying for the source or docs
10:13pyonI have a list, whose elements I can transform into key-value pairs. How do I make a map from this list?
10:13pyonSay, I have the list '(1 2 3), which I want to transform into the map {:1 1 :2 2 :3 3}.
10:14gfredericks,(into {} (for [x '(1 2 3)] [(keyword (str x)) x]))
10:14clojurebot{:1 1, :2 2, :3 3}
10:14pyonty :-)
10:16jweissanyone know a library that will union and normalize intervals of integers? eg [[6 10] [1 7] [12 15]] -> [[1 10] [12 15]] ?
10:17jweissi looked at clojure.core.logic.fd, but i don't see how to union. it has a normalize function but it depends on the intervals being sorted already.
10:18gfredericksjweiss: I wrote some code for test.chuck that handles integer intervals
10:18gfredericksI don't know about normalizing them, as it might assume everything is always normalized
10:19gfrederickslooks like it's about unicode codepoints, but could be adapted for integers: https://github.com/gfredericks/test.chuck/blob/master/src/com/gfredericks/test/chuck/regexes/charsets.clj
10:21gfredericksI guess the abstraction is about sets of integers, internally represented as ranges
10:27jweissgfredericks: right, the idea is to not have to enumerate a set of 1..1000000
10:28jweissi think core.logic.fb/normalize is just buggy, or wasn't meant for this purpose
10:28jweiss(fd/normalize-intervals [(fd/interval 8 9) (fd/interval 1 10)]) -> [<interval:8..10>]
10:29jweissi'm not sure what question it's giving me the answer to :)
10:30jweissi guess this shouldn't be that hard to write myself, just might not be very efficient
10:32oddcullyjweiss: there where a SO question about something similar. might be useful: http://stackoverflow.com/questions/32520176/list-processing-in-clojure-tail-recursion-needed/32521995#32521995
10:33jweissoddcully: i'll check that out, thanks
10:37jweissoddcully: works for me, thanks!
10:37magopianoddcully: ok, so if I understand correctly, it's the connection of vim-fireplace with a _cljs_ repl that is having issues
10:45oddcullymagopian: no, i'd say, that the problem is figwheel centric. the patch for fireplace there tries to eliminate all "piggiebacking" that assume a regular cljs repl
10:46magopianoh
10:46oddcullymagopian: but don't take my word for granted here. i just found a way to make it work, that is good enough for me
10:46magopianeh
10:46oddcullymagopian: i totally dig, why othere have forsaken this route and just bang text over the repl
10:46magopianmy favorite thing about vim-fireplace is "gf"
10:47magopian(which worked this morning, and doesn't anymore, maybe I'm doing something wrong)
10:47magopianand then the "K" to display the doc for the string under the cursor
10:48magopianmaybe "gf" is only available when you have vim-classpath too... but i found it to slow/freeze vim on startup/quitting
10:48magopianwhich is unbearable to me
10:56jmoletjweiss: hows it going man!? :) you still have access to https://clojars.org/test_clj.testng i had to fork/rename it for an update
11:01rarebreedbtw, I'm jmolet's partner in crime at RH :)
11:01rarebreedjweiss: ^
11:01jweisshow's it going rarebreed
11:02rarebreednot too bad :) I'm writing some of the tests in clojure as we speak
11:02rarebreedor rather, I should say I'm fixing some of them
11:03jweisslet's take this to #clojure-redhat rarebreed jmolet
11:09pyonCan I have an empty struct (without fields) ?
11:34noncomhttps://twitter.com/OmanReagan/status/659778175216558081/photo/1
11:34noncompyon: afaik structs are obsolete. deftype and defrecord are the way to go
11:34pyonAh!
11:36noncompyon: and specially for such occasions there's a ritual pictogram: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
11:38pyonChecking.
11:53taylanone with a larger font would have been great
12:30irctcHi everyone.
12:30irctcI'm trying to use reagent inside my project that I created in compojure, but I keep getting errors when I try loading it.
12:32irctcFollowing instructions from: https://github.com/reagent-project/reagent I inserted [reagent "0.5.1"] into my dependencies and I put [reagent.core :as r] in my namespace, however I still get the error. Am I importing reagent the wrong way?
12:37irctcDoes anyone have any experience using reagent?
12:39oddcullyirctc: you could gist/pastebin/refheap the error you see somewhere. first guess: you require it in a cljs files (no clj file!), right?
12:41irctcoddcully, I have never had any experience with cljs. I thought I would just insert a cljs snippet of code directly into my clj file just to test out the simplest functionality that reagent can offer.
12:43irctcThis is the function I wanted to test out.
12:43irctchttp://pastebin.com/UDMduVWD
12:43irctcI thought it would work just as well in a plain clj file.
12:43irctcNothing special about it really.
12:44irctcSo my handler would just point to that function and create a new page based on that.
12:44irctcI thought that's how I could quickly test reagent functionality.
12:45oddcullywell maybe i miss the finer points of compojure here, but clj and cljs are two separate things
12:46oddcullyif you want to have some cljs/reagent app, you would compile your cljs down to js and send this js over to the client. the client then executes it
12:50dstocktoni have a few TB of data and growing across many columns and want clients to be able to drill down across as many columns as they like and do sum() and avg() type aggregations in a few seconds
12:50dstocktonright tool for the job?
12:50dstocktonhadoop, spark, hbase, onyx...
12:51dstocktonit takes far too long in postgres on a single server and postgres isn't too easy to scale
12:51irctcThanks oddcully. I'll do that then. I thought I could just do this quickly to test it out. Well back to work it is then. :)
13:07xemdetiadstockton, you could check out the (recently) open sourced greenplum? it's postgres based to an extent so existing expertise might be able to carry over?
13:09dstocktonxemdetia: thanks, definitely will
13:49justin_smithwith http-kit, the client-loop thread - is that something that you would expect, when profiling, to see constantly open?
13:50noncomjustin_smith: isn't client-loop always waiting for clients?
13:51justin_smithnoncom: yeah, looks like it. At first I thought my app was spending way to long on an http-client read. But it's a false alarm.
13:52justin_smithnow to figure out what the fuck my app was doing....
13:52justin_smith(like - it looks like it was sitting there for an hour and then resumed - but it must have been waiting on something....)
13:55noncomjustin_smith: probably. in usual ip comms, like tcp or udp for multiclient servers there's always one socket waiting for a connection. when it happens, it registers and stores the channel and keeps waiting for more
13:55noncomacceptor socket it is called if remember correctly i
13:56noncomjustin_smith: is this app open to the outer world? someone connected?
13:57noncomidk really, have no clue.. not sure even if it was the client-waiting socket...
14:03justin_smithnoncom: this is a client, not a server
14:04noncomhmmm
14:04justin_smithnoncom: this app reads http, but does not accept connections
14:04justin_smith(it basically does some very curated web crawling as part of its work)
14:04noncomso, it connected via http and hung for an hour?
14:05noncomor it simply acted like if it did that?
14:05justin_smithnoncom: it has a thread that stays open for many hours, which turns out to be an implementation detail of the clj-http client
14:05noncomah, maybe.. yeah..
14:06justin_smithnoncom: the real problem, is why a single request being handled pauses processing for like an hour - then continues
14:06justin_smithlike - I'm trying to profile and see what happens to make that hour long pause happen
14:06noncomand you see nothing special?
14:06justin_smithand the http-client thread (which showed as running) was a false lead
14:06justin_smithnot yet!
14:07noncomcould it be a hang on the server side?
14:07justin_smiththis is the server
14:08noncomyou just said:
14:08justin_smithif I had a connection open to some other server - sure
14:08noncom[21:00:41] <justin_smith> noncom: this is a client, not a server
14:08noncom:D
14:08justin_smithhaha, in the http context, sure
14:08justin_smithbut there is no http connection active during this period of time
14:08noncomah
14:09justin_smithit's a task processor that does a bunch of http requests, and db reads/writes, then does a bunch of CPU / RAM intensive graph analysis
14:09justin_smithand I'm trying to figure out why it just *takes a nap* in the middle of a job, lol
14:09noncomyeah, i got the taste of the strangeness, but the details of the wokring of the app seem to be very involved
14:10noncomOR it is a http-kit implementation detail....
14:11justin_smithI have a lot of factors I am checking out - it looks like no thread is actually reading an http socket (first guess was some server slowing us down with a lot of data on a slow connection)
14:11noncomso you don't even know in what place of the code exactly it's stopping
14:12justin_smithnoncom: well, it's not even stopping - just pausing - the job completes
14:12justin_smithI want to figure out why it seemingly stops doing work in the middle
14:12justin_smithand it doesnt' always do this, it's for a specific query that this happens...
14:12noncomprobably it does not stop in the middle, but it stopes in a specific place
14:12justin_smithusually a job is done in about ~10 minutes
14:12justin_smiththis one takes more like 5 hours
14:13justin_smiththe question is why
14:13noncomwow, serious things you have there
14:13justin_smithit's not a larger job. But now I'm just thinking out loud about the problem, the specific question I had (about http-kit client) is answered
14:14noncomso does it receive the data in full and start processing before it pauses?
14:14noncomis the pause related to data retrieval or data processing?
14:15justin_smithnoncom: thats the weird part -it's doing neither!
14:15justin_smiththe CPU is inactive, no thread is doing anything interesting, and no remote connections are feeding us data
14:15noncomso it waits even before *starting* to receive the data
14:15justin_smithand then later, suddenly we are doing work again
14:16justin_smithand this all happens in the middle - we parse a bunch of xml (rss feeds) and then dead time, then we are calculating our graph analysis
14:17xemdetiajustin_smith, is your process swapping?
14:17justin_smithxemdetia: nope, ram usage is stable...
14:17noncomso it 1) received full data, 2) stops for long, 3) processing
14:18xemdetiasounds like you just need to hook a profiler when it happens :(
14:18xemdetiaunless you have some sort of job log
14:18justin_smithnoncom: exactly (though there are complications to this story - it does also get some data later, this is a very parallelized process)
14:18justin_smithxemdetia: I am analyzing a profiler dump now, the answer is somewhere in these hundreds of threads
14:18noncomjustin_smith: looks like it is waiting for disconnect or something
14:19noncomjustin_smith: what if you repeat the quesry with curl?
14:19justin_smithnoncom: which query?
14:19noncomhttp query...
14:19justin_smithwhich http query?
14:19justin_smithwe have thousands
14:19justin_smithbut none of them are running when the dead time happens
14:20noncomhttp://www.http-kit.org/timer.html ?
14:20noncomah, i'm just asking you a bunch of info and do some wild guesses...
14:20justin_smithwe do have some requests with timeouts on them, but they are like 30 second timeouts
14:20justin_smithnoncom: sure, I appreciate that
14:21justin_smiththis feels less like coding and more like forensics
14:22noncomheh :) it also looks like i am working with javascript
14:23xemdetiajustin_smith, I like that stuff though but in this case it sounds like a log problem. Do you stream events to some sort of receiver via udp or something?
14:23xemdetiaor do you generate these pretty graphs via xvfb or something wacky?
14:24kenrestivoif i wanted to store a clojure maps (k-v) in a database with the minimum of ceremony (meaning: no ORM, no SQL), what would you recommend?
14:24noncomkenrestivo: mongo
14:24noncomkenrestivo: or datomic
14:24kenrestivoone that stores data to a disk
14:24kenrestivoi love datomic but it's too heavyweight for running on a vps
14:24noncomkenrestivo: orient?
14:25kenrestivoooh, cool, never heard of that one, will look into it, thanks.
14:25noncomkenrestivo: i'd go with mongo or orient then
14:25justin_smithxemdetia: the graphs are not visuals, they are data graphs in memory (as in the mathematical concept of graph)
14:25justin_smithxemdetia: the server is connected to other servers via kafka
14:26kenrestivothanks noncom
14:26xemdetiajustin_smith, sorry that was me projecting my problems with graphs and reports
14:26justin_smith:)
14:26xemdetiaI mean this smells like a shared resource not releasing the lock in a timely fashion,
14:27justin_smithright, but the profiler shows when threads are waiting on locks
14:27justin_smithand it isn't showing this
14:27xemdetiado you have some sort of deadlock prevention mechanism? Something that would just force restart and get the system going again after 5 hours?
14:28justin_smithsomething in onyx could have restarted something....
14:28justin_smithhmm
14:28xemdetiaI mean sometimes many problems in constantly running systems are resolved by the power of init restarts
14:28xemdetia(aka something else killing it)
14:29lnostdalhi guys, i see this: :dependencies [[org.immutant/core _] mentioned in some project.clj file .. just wonder what's meant by the underscore
14:30tcrawleylnostdal: I suspect you are looking at Immutant itself - it uses lein-modules (https://github.com/jcrossley3/lein-modules) to build
14:30lnostdaltcrawley, that's right .. i'll check the link out, thanks
14:31tcrawleyin that particular case, the _ will get replaced by the version specified in the top-level pom for all sub-projects in the org.immutant group
14:31lnostdalright
14:33noncomjustin_smith: anyway, what else can i say..... i usually apply the println-explosion tactics for similar cases... helps locating the spot..
14:33noncomidk if it is possible in this case...
14:33WorldsEndlessStupid question, but why doesn't (#("hi")) return the string "hi"?
14:33justin_smithnoncom: fair enough - right now I'm narrowing down the best places for printlns
14:34justin_smithWorldsEndless: it attempts to call the string hi with no args
14:34justin_smith,'#("hi")
14:34clojurebot(fn* [] ("hi"))
14:34justin_smithmaybe the expansion helps
14:34noncomWorldsEndless: sane problem withh happen with #([]) and its variants
14:34WorldsEndlessAh; there are a pair of parens I didn't count on
14:35justin_smithright, #() would be weird if it did not provide those parens
14:35lnostdallooks like immutant.web needs potemkin 0.4.1 to compile on recent clojure 1.8.x versions
14:35noncomi often want to return a [], but am forced to write (fn ..)
14:35justin_smith,(#(println "OK")) ; would have to become (#((println "OK"))) otherwise
14:35clojurebotOK\n
14:36tcrawleylnostdal: thanks for the report, we haven't built with 1.8 lately, I'll take a look. or you could provide a PR if you like
14:38WorldsEndlessthanks justin_smith and noncom
14:38lnostdaltcrawley, it's just https://www.refheap.com/111219 .. seems to compile and run fine on latest clojure 1.8.0 from git after this
14:41kenrestivohmm, orient looks cool, but because it's a java thing, it wants like 8GB of RAM to itself. might as well use datomic in that case.
14:41kenrestivoi might be the only person trying to run java apps on a vps.
14:41kenrestivo(a 2GB vps, specifically)
14:42yendahow do I include a file in my uberjar ? I had an edn file at the root of my project which was working fine during development in repl, and now that I'm trying to start the uberjar I get a stacktrace no such file or directory
14:42justin_smithyenda: a file must be on your classpath / source-paths / resource-paths to end up in an uberjar
14:43justin_smithyenda: also, unless you are guaranteed the jar will be extracted, you need to make sure you are using io/resource rather than file oriented ops. If you had been using io/resource, your code would not have worked (since root of the project is not on the classpath)
14:45tcrawleylnostdal: here you go: https://github.com/immutant/immutant/commit/b703138bc5b9bd425cb0312f7543cceec1cf0816
14:50lnostdaltcrawley, cool, it works here
14:50tcrawleylnostdal: good deal. I just added 1.8.0-beta2 to the CI matrix as well
14:51tcrawleylnostdal: if you have immutant-specific questions, feel free to join us in #immutant
14:53noncomyenda: yeah, there's resource-paths param for the lein project
14:59yendajustin_smith: noncom: isn't the resources directory already in the resource-paths param ?
15:04justin_smithyenda: yes, but the root of your project directory is not
15:05yendaok I put my file in resources and used (slurp (io/resource filename))
15:05yendaand it works now
15:05yendathanks
15:23eraserhdIs the nrepl protocol specified anywhere? All I've found so far is that it uses bencode.
15:24justin_smith eraserhd it's described pretty thoroughly in the nrepl project (nrepl is not part of clojure, of course) https://github.com/clojure/tools.nrepl
15:26eraserhdjustin_smith: Oh. I was looking at the wikis and finding disclaimers about everything being out of date. Got it now.
15:29mattromanhey all, New to boot-clj having problems creating a runnable uberjar.
15:30mattromanException in thread "main" java.lang.IllegalAccessError: tried to access method clojure.lang.RT.classForNameNonLoading(Ljava/lang/String;)Ljava/lang/Class; fr
15:30mattromanom class ring.util.response$loading__5340__auto____261
15:31mattromanthat's the error I get. Anyone have any experience? If so I'll post code. Thanks.
15:58amalloykenrestivo: i run several clojure servers on my linode
15:59amalloywhich only has a couple gigs
16:02xemdetiaamalloy, are you running 2gb ones or one of the 4gb ones
16:03amalloy$ cat /proc/meminfo MemTotal: 3063952 kB
16:04amalloyi've had the server for several years and it's gone through a few upgrades, i'm not sure what plan it's closest to now
16:04xemdetiaI have the same problem :V
16:05xemdetiaI wish they had some sort of storage solution
16:07amalloykenrestivo: anyway i don't know about the specific program you were thinking of, but java servers can be run in much smaller footprints than the default size the jvm allocates; you just have to be specific about what limits you want to set
16:16kenrestivoi guess i'm just not comfortable enough with jvm tuning to know what all the knobs and levers are. i've messed around with Xms and Xms, and on one app i kind of cargo-culted -XX:MaxMetaspaceSize=128m and -XX:-OmitStackTraceInFastThrow in an attempt to keep stuff from crashing
16:18kenrestivobut honestly i don't have a clue what those mean and it scares me to have to thrash around with those just to keep something running.
16:20amalloythe one you want is -Xmx to set the max heap size
16:21amalloylike lazybot runs via: $ java -XX:ReservedCodeCacheSize=6m -Xms10m -Xmx120m -cp `lein classpath` clojure.main -e "(use 'lazybot.run) (-main)"
16:22kenrestivowow, that's small!
16:22amalloywhich is obviously not ideal; an uberjar would be better than lein
16:22amalloy4clojure and refheap are both smaller than that
16:22kenrestivonice...
16:22kenrestivoand i guess visualvm to determine what it really needs?
16:22amalloyeh
16:23kenrestivowhat scares me away is i see posts like this: http://blog.sokolenko.me/2014/11/javavm-options-production.html and i don't understand what all those flags mean
16:23amalloyrun it with 40M, and if it refuses to start up or crashes try with 60. that's what i did
16:23amalloyjust ignore all that junk for running a simple server
16:23justin_smithvisualvm can help find where memory is being wasted
16:23kenrestivoamalloy: cool, thanks!
16:24kenrestivowhat does ReservedCodeCacheSize do?
16:25kenrestivobetter question: where are all these flags documented?
16:27justin_smithkenrestivo: these are all java 8 command line flags right? oracle documents them pretty extensively
16:28amalloytbh i don't know why reservedcodecachesize is set for lazybot. probably Raynes copied it from somewhere too
16:28amalloyit would be fine without that
16:29kenrestivoyeah, it seems that the defaults are like 240mb on java 8... i haven't found official docs yet on all these
16:29oddcullykenrestivo: http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
16:29kenrestivoalso glad to see i'm not the only one with jvm tuning flags who doesn't understand what they are or why they're there :)
16:30kenrestivooddcully: oh duh, thanks, they're in the freakin man page http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
16:32{blake}I'm using seesaw to make a GUI with twelve repeating components and I'm having a hard time figuring out how to cycle things. This is one row: (ss/config! p :items [(make-left-panel) (make-right-panel)])
16:33justin_smith{blake}: sounds like you want a sequence of items, each like p, then a doseq where you config! each one to contain a row?
16:34justin_smithand that sequence of items would stack top to bottom of course
16:34{blake}justin_smith: Yeah, I could do that.
16:34{blake}That'd probably be easier.
16:34{blake}I was trying to figure out how to make :items a vector of 12 left & right panels.
16:34{blake}At least one I could get config! to accept, that is.
16:35{blake}Like: (ss/config! p :items [(make-left-panel) (make-right-panel)(make-left-panel) (make-right-panel)(make-left-panel) (make-right-panel)])
16:35{blake}Doesn't that seem like a job for cycle?
16:35justin_smith{blake}: that would line them all up side by side
16:35justin_smithbut sure, cycle could do that
16:36{blake}I'm using mig-layout: make-right-panel returns has a "wrap"
16:36justin_smithexcept cycle is for immutable values, and I think seesaw wants different mutable things in each position
16:37{blake}I've tried a number of things without success, and it seems like it should be very simple.
16:37justin_smithwell, cycle is going to return that same panels over and over
16:37{blake}(Which usually means I'm forgetting something basic.)
16:37justin_smithand you likely want new ones
16:37{blake}justin_smith: Well, that ain't gonna work. Yeah, I need to actually call those functions one after the other.
16:37{blake}I think I started with dotimes.
16:38justin_smith,(interleave (repeatedly rand) (repeatedly rand-int))
16:38clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/rand-int>
16:38justin_smith,(interleave (repeatedly rand) (repeatedly #(rand-int 10)))
16:38clojurebot(0.9898270533245493 1 0.05506501946454245 6 0.300150269264995 ...)
16:38justin_smithsomething like that?
16:39{blake}maaaybe....I didn't try interleave.
16:39justin_smithyou would want the (repeatedly n f) version of repeatedly
16:42{blake}Yeah, I've hung up my REPL more than once.
16:46{blake}Damn.
16:46{blake}AH! Got it!
16:48{blake}(inc justin_smith)
16:48{blake}Still no lovebot.
17:01magopianso, I follow https://github.com/boot-clj/boot#install to install boot on mac osx with brew (so "brew install boot-clj")
17:02magopianthen I do a "boot -h", and it pulls a bunch of jars, and ends with "Please download latest Boot binary: https://github.com/boot-clj/boot#install&quot;
17:02magopianand now, whatever I do (boot -u, boot -h, boot repl -h), it gives me the very same message
17:02magopianam I doing something wrong?
17:03magopianboot -u gives me https://www.refheap.com/111223
17:05oddcullymagopian: when on a boot 2.0.0 version and using boot -u i got the same error. i had to fetch the recent boot.sh
17:06magopianboot.sh?
17:06oddcullythen renamed to boot
17:08magopianso you're saying I should use https://github.com/boot-clj/boot#unix-linux-osx ?
17:09oddcullyexcept the /usr/local/bin thing - unless you want to
17:09oddcullywell that fixed it for me on linux - ymmv on osx
17:10magopianthanks a lot for your answer, i'll try that
17:10oddcullybut i have all my tools installed in ~/bin (sdkman, lein, boot) since distributions hand you down archaic versions
17:10magopianahhhh, it does seem to work better :)
17:13magopiannice
17:38g00shello, was reading about clojure on android here https://blog.swiftkey.com/what-makes-clarity-keyboard-tick-clojure/ ... they mention skummet; does clojure 1.8 have anything in the way of android specific optimizations - or will skummet be needed for the forseable future?
17:42postpunkjusting00s: I haven't seen anything in the recent release notes for 1.8 that mention Android
17:42g00spostpunkjustin ok thanks !
18:19irctcHi everyone. :)
18:20irctcIs it possible to use core.async without using clojureScript so I could display some text on my page until the back end process is ready to display its results?
18:21irctcSo in short I would like to use core.async only in Clojure but I don't know how it's done.
18:24irctcWhen I try to do this in my views, my application still blocks until the results return from the process.
18:30amalloyirctc: have you thought about how this is going to work in terms of networking, http, html, and so on? completely brushing aside what core.async is going to do inside your server. how is your server going to return a response to the client and then later somehow update it?
18:30irctcThat's what I would like to figure out. I'd like to do everything in Clojure but I have the same question you posed.
18:31TEttingers/in Clojure/in real life/
18:33irctcRight now I am annoyed with clojure script tutorials, because I am new to clojure script, and clojure in general. The tutorials fro clojure script are often too specific to a certain combination of tools and I find that I spend way too much time figuring out what each of those tools does and how that affects the application than actually learning how to use clojure scipt. Taht's why I'd like to try doing everything in clojure.
18:33amalloymy point is, forget about clojure. pretend your server is operated by an omnipotent genie, who can produce any HTTP responses you want. what do you wish it could return? is there any HTTP response you could provide that would cause the user's client to behave the way you want? if no, you can give up on the project completely; if so, then you can start thinking about how to actually implement that genie
18:35irctcWell for a newbie like me it would probably be even harder to implement that genie.
18:35TEttingerI'm leaning toward the "this isn't a disney movie" approach
18:35irctc?
18:36irctcRight, the no genie approach. Sorry it's a little late where I am. :)
18:36TEttingerheh
18:37TEttingerI mean, there's some approaches on the client side
18:37TEttingeryou could stick the whole page in an iframe, make the iframe part request at some interval
18:38irctcOk, about clojure script... Some have suggested I use reagent, but I don't know how to set it up. I guess I keep missing some steps or I don't quite get the concept...
18:39irctcI'm not a big fan of iframes. I'd like to use reagent if only I could figure out the idea behind it.
18:39irctcBasically right now I have a compojure application which works just fine. It does what it's supposed to do, but when a user uses the search box it blocks the user for about 6-7 seconds and I'd like to avoid that.
18:40irctcFirst I looked into core.async, but then I thought how am I going to implement this only in clojure, so naturally clojureScript came as an approach and Reagent (which is supposed to help set everything up).
18:41irctcThen I imported reagent dependencies through project.clj, but after that it all falls apart.
18:42irctcWhat is the next step after I put reagent in my project.clj :dependencies?
18:42TEttingerwhen you build with lein it should download the deps
18:42irctcDo I create a special cljs folder in which I create a cljs file and I import reagent in its namespace?
18:43irctcIt downloads the deps in my Eclips/counterclockwise editor/plugin.
18:43irctcSo that's all good. I would guess.
18:45irctcI tried to put reagent in my clojure files namespace thinking I would create a small cljs function within them, but that didn't work. So do these cljs files need to be separate and do they need to then import reagent in their namespaces?
18:56manualcrank
19:01didibusAnyone can explain to me the convention of fn*
19:01didibusI see some functions like let* and list*
19:01didibuswhat's up with the * character at the end of them
19:05irctchttps://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;cad=rja&amp;uact=8&amp;ved=0CCMQFjABahUKEwjIkrzkpuvIAhXl_nIKHWNuA8o&amp;url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F5082850%2Fwhats-the-convention-for-using-an-asterisk-at-the-end-of-a-function-name-in-clo&amp;usg=AFQjCNHoOQCS4i_DjBX7OsAWBHgcQODTPA&amp;bvm=bv.106379543,d.bGQ
19:05irctcdidibus that's what I found for the asterisk
19:06justin_smithbtw that top 0 point answer is wrong
19:06justin_smithall of those answers are pretty shitty
19:06amalloyjustin_smith: imo fix your stackoverflow sorting so that 0-point answer doesn't show first
19:07irctcFor me it shows as the last one.
19:07justin_smithdidibus: the versions with * at the end are implementation details, and arguably should have been private
19:07amalloyyeah, with no custom settings that one's last
19:07justin_smithamalloy: interesting
19:08irctcBtw, how do I compile my cljs files when I use reagent?
19:08justin_smithirctc: with cljsbuild, like you would otherwise
19:08irctcAnd how do I set up a path where they'll be compiled?
19:08amalloyinterestingly i upvoted that 0-point answer for some reason, 4 1/2 years ago
19:08justin_smithvia the cljsbuild options in project.clj
19:08irctcOh, ok, so reagent doesn't do anything special there.
19:08amalloyit really is awful
19:09justin_smithamalloy: even the comment correcting him is wrong
19:09amalloyyeah
19:09justin_smiththe wrong is everywhere
19:10justin_smithtechnomancy's answer is closest to being helpful
19:10irctcAnd where do you usually put your cljs files? In resources folder?
19:11FregionThis is probably more helpful http://stackoverflow.com/questions/31661187/difference-between-let-and-let-in-clojure?lq=1
19:11justin_smithirctc: in my sources, and then I compile the js to output to resources
19:12irctcO, ok. Thanks. :)
19:12didibusUh, ok I see.
19:14irctcI'm off to bed. Thanks fo your help everyone.
19:14irctcTake care and have a good weekend. :)
19:16justin_smithFregion: yes, that one is much better, and the other one should be deleted and just redirect to that one
19:23didibusjustin_smith: If a macro is important for ease-of-use, expose the function version as well. Open question: should there be a naming convention here? A lot of places use "foo" and "foo*"
19:23didibusI think this explains why they were not made private
19:24justin_smithbut let* and fn* are not functions, they are special forms
19:24justin_smithwhich are effectively macros, minus some implementation details
19:24justin_smithdefinitely not functions
19:25didibusYa, it's slightly stretching the defenition, but I believe it's the same idea. Some other macro might want to use them, so they were exposed
19:56pyonHow do I make a definition (function, macro, whatever) local to a file?
19:57justin_smithpyon: this is what the :private metadata is intended for (see also defn- which is like defn but it adds the :private metadata to the var), but it's a convention and quite easy to circumvent if that matters
19:57justin_smith(doc defn-)
19:57clojurebot"([name & decls]); same as defn, yielding non-public def"
19:57pyonOh.
20:08pyonWhat's the proper way to format docstrings spanning multiple lines?
20:08pyonNever mind, already found it, thanks.
20:13sdegutis,(def at-least max)
20:13sdegutis,(-> 4 (- 2) (at-least 3))
20:13clojurebot#'sandbox/at-least
20:13clojurebot#error {\n :cause "Unable to resolve symbol: at-least in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: at-least in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: at-leas...
20:14sdegutisum
20:14sdegutis,(-> 4 (- 2) (at-least 3))
20:14clojurebot#error {\n :cause "Unable to resolve symbol: at-least in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: at-least in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: at-leas...
20:14sdegutisYOU JUST DEFINED IT
20:15justin_smithsdegutis: the "every 15 minute reset" isn't a reset 15 minutes after your def, it's a whole new sandbox every 15 minutes
20:15sdegutis,(def at-least max)
20:15clojurebot#'sandbox/at-least
20:15sdegutis,(-> 4 (- 2) (at-least 3))
20:15clojurebot3
20:15sdegutisOh.
20:15sdegutisSo I literally put those right between the cut-off.
20:16sdegutisThe first time.
20:16sdegutisRight?
20:16justin_smithyup
20:16sdegutisCool.
20:16sdegutisAnyway at-least is a fun name for max.
20:16sdegutis(def at-most min)
20:16sdegutis,(def at-most min)
20:16clojurebot#'sandbox/at-most
20:16sdegutisThat too.
20:16sdegutis(-> 5 (at-most 3))
20:16sdegutis,(-> 5 (at-most 3))
20:16clojurebot3
20:16sdegutis,(-> 2 (at-most 3))
20:16clojurebot2
20:16sdegutisI like it.
20:17justin_smith,(at-most 4 3 42 -10 2)
20:17clojurebot-10
20:20pyonHow do I undefined something I previously defined in the REPL?
20:47sdegutisjustin_smith: it only works when using -> with numbers
20:47sdegutiswhich turns out to be very useful for basic arithmetic
21:15htmldrumHappy Halloween, spooky clojure peeps.
21:23michaelsTo you as well, htmldrum!
22:02pyonHow could I make a macro like `defrecord`, but where fields are indexed by numbers (0,1,2...) rather than by names?
22:03pyonOne way I thought I could do it is to just use a sequence, whose first element is the “type”, and whose remainder are the fields' values. But it would be too easy for users to inspect this representation.
22:14justin_smithpyon: there's an argument to be made that information hiding becomes much less useful when your datatypes are immutable
22:16justin_smithpyon: remember that in clojure you can only have methods via an existing protocol or interface. Instead of hiding the implementation of methods, document that your protocol should be used and not the concrete type, then implement the protocol using whatever details you like in a defrecord or deftype
23:21TEttinger(doc undefine)
23:21clojurebotIt's greek to me.
23:21TEttinger(doc undef)
23:21clojurebotTitim gan éirí ort.
23:21TEttingerhuh
23:22TEttingerI thought there might be one
23:22justin_smithTEttinger: do you want ns-unpmap?
23:23TEttingerunmap ?
23:23TEttingerI guess
23:23TEttingerit was to answer pyon
23:23pyonTEttinger: Ah, thanks!
23:23TEttingerthanks justin_smith!
23:24pyonNone of (undef foo), (undefine foo) or (unmap foo) works in the REPL, thoguh.
23:24pyonthough*
23:24TEttingerns-unmap
23:25justin_smitherr, unmap
23:27justin_smithheh, my internet is super slow right now
23:31justin_smith,(def foo 2)
23:31clojurebot#'sandbox/foo
23:31justin_smith,foo
23:31clojurebot2
23:31justin_smith,(ns-unmap *ns* 'foo)
23:31clojurebotnil
23:31justin_smith,foo
23:31clojurebot#error {\n :cause "Unable to resolve symbol: foo in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: foo in this conte...
23:38pyonCan normal `def`s have docstrings the same way `defn`s and `defmacro`s do?
23:38justin_smithabsolutely
23:38justin_smith,(def foo "this is a foo" 2)
23:38clojurebot#'sandbox/foo
23:38justin_smith,(doc foo)
23:38clojurebot"; this is a foo"
23:39pyonSweet! :-)