#clojure logs

2011-03-02

00:01amalloytomoj: (concat (drop x) [(first x)]) and (cons (last x) (butlast x)) seems to work okay; if you require that the input is a vector you can do these operations in constant time
00:01amalloythe issue of course is that what you get out is no longer a vector
00:01tomojand I'd want constant in the number of rotations as well
00:03amalloytomoj: you can implement a new thing like subvec
00:03tomojno fair that rich gets to use inheritance for that
00:03tomojwhereas the first thing I think of is a nasty deftype that just delegates everything with a few minor change
00:05amalloytomoj: proxy APersistentVector?
00:07amalloy$findn 2 [1 2 3 4 5] [4 5]
00:07amalloy$findfn 2 [1 2 3 4 5] [4 5]
00:07sexpbot[clojure.core/take-last]
00:15amalloy$findfn 2 [1 2 3 4 5] [1 2 3]
00:15sexpbot[clojure.core/drop-last]
00:16amalloythree cheers for findfn, joshua____
00:18joshua____`(repeatedly 3 #(cheer "findfn"))
00:20joshua____$findfn [1 2 3] [3 1 2]
00:20sexpbot[]
00:20joshua____No rotate.
00:20amalloytried it already
00:33DespiteItAllDoes findfn just try all the functions?
00:33joshua____DespiteItAll, yes.
00:33amalloyDespiteItAll: yeah. for given values of "all", anyway
00:33DespiteItAllNice
00:35DespiteItAllLooking at the source I couldn't really tell where the functions were coming from. But I see the call to ns-publics now.
00:35joshua____Why is it take-nth, but just plain drop for drop?
00:36joshua____Seems inconsistent.
00:36DespiteItAllthey do different things
00:36amalloyjoshua____: take-nths is different
00:37amalloy&((juxt take drop take-nth) 2 (range 10))
00:37sexpbot⟹ [(0 1) (2 3 4 5 6 7 8 9) (0 2 4 6 8)]
00:37DespiteItAlltake-nth is like "take every third". drop is like "drop 3".
00:38DespiteItAllI guess there is no drop-nth
00:38joshua____Oh.
00:38DespiteItAlldrop-last is interesting. How can it be lazy and know how many items are left at the same time
00:39amalloyDespiteItAll: it has to buffer N items
00:39amalloyi believe
00:40DespiteItAllIt does something weird. I'm not sober enough to understand it right now.
00:40amalloy$source drop-last
00:40sexpbotdrop-last is http://is.gd/JdGkUR
00:41amalloyoh hahaha
00:42amalloyit takes advantage of (map foo a b) stopping after the shorter of a or b ends
00:42DespiteItAlloh, hahahah, nice
00:42amalloyto basically map identity over s, until (drop n s) is empty
00:42joshua____https://gist.github.com/850531
00:42amalloythat's pretty sneaky
00:43joshua____Implemented rotatel and rotater
00:43joshua____Might not be as perforfmant, but at least it is out there now.
00:43amalloyjoshua____: i'm actually working on a tool called hot-potato that will include these as well as reordering function args, as of discovering that they don't exist
00:44amalloyfwiw i like (apply concat ((juxt drop take) n col))
00:44joshua____What happens if they say rotate 1000 with that call?
00:44amalloysame as for you. they're identical
00:44joshua____Oh.
00:44joshua____Oh!
00:45joshua____and rotater would be: (apply concat ((juxt drop-last take-last) n col)) ?
00:45amalloyright
00:45joshua____,(doc juxt)
00:45clojurebot"([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, a...
00:46joshua____amalloy, thanks for the heads up on that function. It seems like it will help make my code that much more concise.
00:53amalloyjoshua____: i use (juxt identity some-fn) a whole lot. i want to give it its own function but i can't decide exactly how it should behave
00:54amalloy((decorate class) myobj), or (annotate class myobj)? both names and usages seem to make sense
00:56joshua____preserve and maintain are what popped to my mind. Yours seem fine too.
00:56amalloyyeah, i'm less bothered about the name than about whether it returns a juxt-ish function or immediately returns its result
00:58joshua____I would skip the issue by writing both.
00:59amalloyhm
01:00joshua____Then I would use the more concise (returns results directly) form whenever I wasn't calling the function in multiple places.
01:00amalloy(def decorate (partial juxt identity)), (defn annotate [& args] ((apply decorate (butlast args)) (last args)))?
01:01joshua____,(doc partial)
01:01clojurebot"([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. ...
01:01joshua____,(doc butlast)
01:01clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
01:01amalloyjoshua____: sexpbot doesn't trim the docs
01:01amalloy&(doc partial)
01:01sexpbot⟹ "([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args."
01:03joshua____Something like that. I think. I haven't actually run the stuff though.
01:03amalloyneither have i :P
01:05joshua____amalloy, seems to work, though it doesn't work for functions that take multiple arguments.. though I don't expect that to be your intention.
01:05amalloyreally?
01:06amalloyoh, i forgot an apply
01:06amalloyoh right
01:06amalloyno the point was that it can't work for multiple args
01:06amalloysince identity has to work
01:06amalloyi've forgotten and re-discovered that five times today :P
01:20amalloyhm. clojars tells me the group name "amalloy" is already taken, even though i own the username amalloy and have no projects with a groupid of amalloy
01:21amalloyi'm still fairly clueless about clojars. anyone have useful advice?
01:22tomojgroupids are free for the taking
01:22tomojmaybe there's someone you can complain to, though?
01:23tomojeasier to complain about a domain groupid I'd imagine..
01:23amalloytomoj: sure, but nobody else has a project with groupid amalloy as far as i can tell
01:24tomojoh, weird
01:24amalloyi guess i can make it org.clojars.amalloy
01:24amalloywhich i clearly do own
01:24amalloybut blech
01:42kilo_hi, is there a equivalent for clojure skill levels - like this article ? http://www.scala-lang.org/node/8610
01:50midskilo_: only if you play it on the xbox
01:52kilo_mids, xbox ? no understand....
01:56amalloymids: gotta choose your audience more carefully, it seems
02:03Scriptorkilo_: I think mids just means it's not really the best way to look at learning a language as an absolutely established series of steps like that
02:10amalloyScriptor: a much more eloquent translation than i was able to come up with
02:14Scriptoramalloy: thanks :)
02:17amalloyi guess cdddr and joshua are both gone now, but i've pushed 0.1.0 of hot-potato to clojars
02:29kilo_Scriptor : thanks for the explanation.. mids, too
02:37kilo_I was just wondering if there's some sort of map to follow while learning
02:48LauJensenkilo_: Solve Eulers 1 - 50 use purely functional constructs. Thats the roadmap :)
02:59kilo_LauJensen : thanks
03:42amalloy$source fn?
03:42sexpbotfn? is http://is.gd/V6o9rh
04:05Ptivalcan someone point me to the right way to have clojure.contrib available in a lein repl?
04:09bobo_Ptival: its in the default projekt when you create a projekt with elin, so lein new myproject, cd myproject, lein deps, lein repl
04:15Ptivalbobo_: ok I got it working thanks
04:28Ptivalhttp://paste.lisp.org/display/120114 what's wrong with this?
04:33thorwilPtival: is the the dot at the end of java.text.SimpleDateFormat. supposed to be there?
04:34Ptivalthorwil: well, I think :\ I am trying to call the constructor for SimpleDateFormat object...
04:34clgvPtival: the constructor call seems correct
04:35clgvcan you print the stacktrace? the you'll know which line it caused
04:35clgvthere is a print-stack-trace in clojure.stacktrace
04:36clgvprobably you should use it like (print-stack-trace (.getCause *e))
04:36PtivalI'll try
04:37thorwilPtival: how/where is the "format" in (. formatter format date buffer 0) defined?
04:37hoeckPtival: the last arg to format must be a java.text.FieldPosition
04:37Ptivalhoeck: oh...
04:37hoeckat least thats what the javadocs about .format say
04:37Ptivalyes, I overlooked that
04:37Ptivalthanks I'll fix it
04:38hoeck(java.text.FieldPosition. 0)
04:38clgvthere is a buildin format within clojure
04:38Ptivalalso, is there a way I don't have to fully qualify every Java class?
04:39clgvoh well wrong method.
04:39raeknote that java methods that are variadic (e.g. int a, int... foo) needs to be called with an array as the last arg
04:39clgvbut a short version: (.format (SimpleDateFormat. "yyyyMMdd-HHmm") (Date.) )
04:39kilo_got mah first projet-euler solution right !! huzzah for loop and recur....
04:40clgv,(.format (SimpleDateFormat. "yyyyMMdd-HHmm") (Date.) )
04:40clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: SimpleDateFormat
04:41clgv,(.format (java.text.SimpleDateFormat. "yyyyMMdd-HHmm") (java.util.Date.) )
04:41clojurebot"20110302-0132"
04:41Ptivalthanks clgv
04:42kilo_http://paste.lisp.org/display/120116 - any comments
04:44kilo_am i using recur right ?
04:53clgvoh just noticed that (dorun (map ...)) has a significant overhead over loop-recur. in the case I rewrote the loop-recur version isnt even looking more complex
04:54clgvso I guess if I use (dorun (map ...)) I should generally consider using loop-recur instead if it isnt more complicated.
04:54clgvright?
05:11hoeckclgv: right, map is not good for hot inner loops, because of the laziness overhead it has
05:14hoeckclgv: most of my loops are expressable with reduce, and I'm really only using loop/recur where I'm caring about performance
05:15clgvhoeck: ok thanks. I am using loop-recur in some reduce cases - but the first reason was that I dont have to go over the whole sequence which is not possible with reduce
05:16midskilo_: who do you need recursion for that?
05:24midsoh euler...
05:24mids(apply + (filter multiple-of-3-or-5? (range 1 1000)))
05:28Ptivaldoes someone know where clojure.contrib.logging actually logs to?
05:31midsPtival: to Apache
05:31midscommons-logging, log4j, and finally java.util.logging
05:33zoldarmids, what if there was max accumulated sum condition? would it be possible without loop-recur? I've tried to think out something along take-while with iterate, but it would include using refs..
05:35Ptivalmids: well yes, the doc says that this should be my "preferred logging system", yet I don't know what it is or where the data is actually sent...
05:38midsPtival: I think the default output of jaba.util.logging is stderr
05:38Ptivalmids: ok thanks
05:40PtivalI don't know, maybe the repl is eating my logs for dinner
05:41midswhat level are you logging at?
05:41midszoldar: maybe the sum condition could be added to the reduce function; not that it would make things simpler
05:46ronnie`how does "resources" work with lein. I got a few txt files (maps/maze layouts), I need to read one of these files (filename as command line arg), just trying to work out the correct way to refer to that folder.
05:46zoldarmids, well, from what I see, reduce would blow up on infinite seq
05:46Ptivalmids: I tried trace and debug
05:49__name__good day
05:51midsPtival: that might be below the default log level
05:53Ptivalmids: ok, I'll check this, thanks
05:53midsPtival: http://www.paullegato.com/blog/setting-clojure-log-level/
06:52octecan i extend a java class and define fields in it somehow?
06:53octeseems i can only define methods on proxies
06:53Dranikocte, you can't define fields but you may define getters/setters
06:53Dranikah, sorry
06:54Dranikthere is a special option in genclass, if I not mixing something
06:56zoldarocte: there's :state parameter in gen-class, maybe this will do
06:57zoldarocte: however, this won't be a field in the meaning of object member
06:58octezoldar, yeah, that's what i need
06:58octejava interop
07:53octe,(deftype B [a] clojure.lang.IPersistentMap)
07:53clojurebotsandbox.B
07:53octe,(do (deftype B [a] clojure.lang.IPersistentMap) (B. 1))
07:53clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.AbstractMethodError>
07:53octeshouldn't that work?
08:19seancorfieldyou haven't defined any methods on type B
08:20Chousukeocte: Yeah, you're not actually implementing IPersistentMap, you just claim you do :P
08:20octe"If you specify IPersistentMap as an interface, but don't define methods for it, an implementation will be generated automatically.⇧
08:21Chousuke$source deftype
08:21sexpbotdeftype is http://is.gd/Y341QH
08:21Chousukeseems a bit broken :P
08:21octeyeah
08:22octefrankly, deftype feels a bit too magical.. you can specify an interface, protocl or Object. Specifying some special interfaces will automatically generate methods
08:23timvisherhi all
08:23octemarking a field as mutable implies creating your own getters and setters
08:23ChousukeYou're not supposed to use deftype anyway
08:23Chousukeunless you really need to
08:23timvisherI'm trying to write a doseq expression that 'maps' fs/copy+ over two seqs
08:23timvisherI'm struggling to write the biding expression though
08:23octeChousuke, maybe not, playing around with it..
08:23timvisherI had a working version with map, but that's 'wrong', yes?
08:24Chousuketimvisher: not really, just use doall
08:24octewow, has java.net been down for everyone for the whole day?
08:25Chousukeocte: actually the docstring for deftype makes no mention of IPersistentMap. Are you sure you're looking at recent documentation :/
08:25Chousuke+?
08:25clojurebot,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is a")) )] (testar 11 25))
08:25octeChousuke, perhaps not, i'm looking at http://www.assembla.com/wiki/show/clojure/Datatypes
08:25timvisherChousuke: hmm. My problem isn't with the expression not being evaluated (although I've only used it from the repl at this point so that could easily turn out to be the case). My problem was using map to get side effects
08:25Chousukeocte: yeah, assembla is old
08:25octewhich might just be rich's mental notes?
08:26octe:p
08:26octeoh ok
08:26timvisherI thought the idiomatic way to do that was to use one of the various 'do' constructs
08:26octeif assembla is obsolete, shouldn't it be taken down or something?
08:26Chousukehttp://dev.clojure.org replaced assembla
08:26Chousukeocte: it should link to the new dev forum :/
08:26octeChousuke, yeah
08:26octethe banner should say that everything was moved to dev.clojure.org, not just the issue tracking :)
08:26Chousukeit does on the main page I suppose.
08:27octeah
08:27octewhat i'm playing around with is a way to define structs in clojure that i can use with jna
08:28octesince i can't extend Structure and define java fields in clojure
08:28sattvikocte: Have you looked at defrecord?
08:28octei suppose i should look at that instead
08:29sattvikA defrecord type can act like a map within clojure, but also create immutable fields that may be easier for interop.
08:29octewill (keys some-record) return the keys in the same order as the they're defined?
08:29octesattvik, i'd actually prefer mutable fields in this case
08:30octebut it doesn't really matter i suppose
08:30sattvikAh, in that case, defrecord is out.
08:30octewell it's just a preference, which is why i looked at deftype
08:30octebut if i'm not supposed to use it..
08:31octethat leaves defrecord
08:31timvisherAnyone mind checking this defn to see if I'm doing side effects right? https://gist.github.com/850917
08:32ChousukeI wonder if it's possible to make the dev.clojure.org link to JIRA on the main page. Or does it do that already?
08:32sattvikI don't think you're not supposed to use it. It's simply a bit lower-level, but not as low level as gen-class. I think you are, in general, encourage to use higher level abstractions, but the low-level stuff is there for interop.
08:33Chousukesattvik: Clojure itself uses deftype to implement gvecs AFAIK.
08:33Chousukeand records of course
08:34Chousukeit's there if you need it but most common things are done for you. :)
08:53sattvikChousuke: That's true.
08:53sattviktimvisher: I think it looks OK. If you don't need to hold on to the results of the map, you can use dorun instead of doall.
09:06timvishersattvik: thanks!
09:20fliebelIs Cake able to compile java source files?
09:20dpritchettthis isn't really a clojure question per se but i figured there are people here who could help me understand anyway...
09:20dpritchettgiven that mod_php was crucial to PHP's growth, how hard is it to build something that works similarly for other languages like node or clojure?
09:20fliebelI found some that are not even worth a maven file, but to large to convert to Clojure for fun.
09:21fliebeldpritchett: You mean fastcgi?
09:21dpritchetti might mean if i knew more about fastcgi ;)
09:22dpritchetti am not sure exactly how cgi/mod_php work under the covers, i'm just thinking of the experience of being able to build a web app by dropping 1+ .php files into ~/public_html on a cheap host
09:22dpritchettnevermind services etc
09:22fliebeldpritchett: You wont be able to run Clojure on a cheap PHP host ;)
09:23fliebelBut you can generate a war file from a Ring app and drop that in a Java host.
09:23fliebelSo, Ring is the way to go.
09:23dpritchetti guess it needs to be an interpreted language to have a hope there
09:24fliebeldpritchett: What does being interpreted have to do with it?
09:25clgvhow can I check if something is a double array?
09:25dpritchettreplicating the "drop in a text file, click f5" deployment method
09:25dpritchetti guess you could have some build daemon to fake that
09:26TimMcdpritchett: You really don't want to start the JVM for each request.
09:27fliebelTimMc: Isn't that what FastGI and Cake are all about?
09:27TimMcOh, does FastCGI keep a process up?
09:27dpritchettperhaps something like pharen would be a quicker solution
09:28dpritchettheck it even says on its front page: "This combines Lisp’s advantages of uniform syntax and homoiconicity (among others) and PHP’s advantage of…being everywhere."
09:28dpritchetti'm going to read up on how python's wsgi servers work, it might give me some needed perspective
09:29fliebeldpritchett: wsgi = rake = ring
09:29fliebel(not sure about the ruby name)
09:29dpritchettunicorn & passenger i think
09:34dnolenfliebel: been digging into that arithmetic bug. Hope to have that wrapped up today or tomorrow.
09:35fliebeldnolen: Fantastic! Do you know where the problem lies yet? Is it in the scheme code, in my code or in Logos?
09:36fliebel"cake compile ;; Compile all clojure and java source files." So where do I put these java files?
09:37dnolenfliebel: I think mplus-concat is still wrong. it's still going eagerly down some branches when it should not.
09:38fliebeldnolen: So, the duplicate results I was seeing are due to interleaving?
09:38dnolenfliebel: and the stack overflow errors as well. They are related.
09:39dnolenfliebel: been working out adder-o operation by hand to see what's going on :)
09:40fliebeldnolen: How are you doing that? I found it was to complex to keep in mind, but I was unable to find a way to clearly capture the recursion in writing.
09:41dnolenfliebel: well I wrote out most of the earlier code in TRS so I got used to writing it out in a way that made sense to me.
09:41dnolenpencil and paper all the way.
09:43fliebeldnolen: Of course pencil, but once you start binding conses, and recur on the rest, I have trouble writing that out.
09:44fliebelgen-adder-o, for example...
09:46dnolenfliebel: yeah that's tricky. Just came up with a simple way to show backtracking. Stating which step to go back to fill in the newly ground vars.
09:48fliebeldnolen: hm, I'll have to try it.
10:07TimMcIs the following a true statement? "Symbols evaluate to a lexically bound value, vars evaluate to a dynamically bound value."
10:09TimMcIf so, I think I finally understand their relationship.
10:10opqdonutsymbols evaluate to values, vars are values that can be dereffed
10:10opqdonut:)
10:10TimMchmm
10:11TimMcOh! So they can. (deref (var foo)) works for (def foo ...)
10:12TimMcBUt the value they deref to may depend on the dynamic environment?
10:12opqdonutit does depend
10:13TimMcIs it fair to say that all those environments share the same var, even though it derefs to different things?
10:13TimMc(different threads, different (binding ...) clauses)
10:16TimMcIt's just not fair... Java's scoping rules are so damn easy! :-P
10:18Fossiorly?
10:19TimMcI found them so.
10:20TimMcI think what's bugging me here is namespaces, actually.
10:20_fogusThe whole point of things like AspectJ is to put dynamic binding into Java.
10:22TimMceep
10:22dnolen_fogus: there's some interesting papers about Datalog + AspectJ point cuts that I recently ran into.
10:22_fogusdnolen: !!! links please :-)
10:23dnolenhttp://abc.comlab.ox.ac.uk/documents/abc-2006-2.ps
10:23dnolenhttp://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.96.974&amp;rep=rep1&amp;type=pdf
10:23dnolenthere' s more, Google Datalog AspectJ point cuts should reveal a couple others.
10:24_fogusThese couldn't have come at a better time.
10:24_fogusThank you
10:24dnolennp
10:28TimMcOK... would it be fair to say that symbols without a namespace qualification are just a shorthand?
10:28TimMcI feel like I don't have a good formalization of symbols, namespaces, and vars in Clojure.
10:33TimMcOK... let's try this again.
10:34raekTimMc: for symbols that represents vars, yes. but symbols can also represent values bound by let, function parameters, special forms, etc
10:34clgvTimMc: I think there is the following connection. A symbol is nothing more than a name. symbols can be resolved to vars
10:35TimMcI'm ignoring special forms for now -- I just assume the compiler intercepts those.
10:36TimMc"Symbols eval to values. Some are via lexical scope, and others are via dynamic scope, using the namespace as a lookup table for vars. (Unqualified symbols use the current ns.) Vars are automatically dereferenced in the current environment when used this way."
10:37TimMcI take it that macros receive the qualified versions of the symbols?
10:37raekit's actually syntax-quote that does that part
10:38raek,`foo
10:38clojurebotsandbox/foo
10:40TimMcAh, yes it is. (defmacro foo [x] (println x)) shows me that the macro can receive unqualified symbols just fine.
10:40raekmacros should always emit qualified symbols when the symbols represent vars
10:40raeksince you don't know where the macro may end up being expanded
10:40raekand syntax-quote makes that easy
10:40TimMcMakes total sense.
10:43TimMcWhat do you think of my longer statement just before the macros one?
10:46raek"Symbols eval to values" - when normal evaluaiton rules apply (i.e. this may not hold when the symbol is and argument to a special form or macro)
10:47raekvariables are always lexically scoped
10:48raek(but vars may be rebound dynamically)
10:48raekwhen a symbols does not represent a function parameter, let'ed value or special form, it is resolved to a var
10:49raekand the namespace is used as a lookup table for that
10:50TimMc(defn maker [] (defn bar [] (println "bar!")) nil)
10:50TimMc(defn flurb [] (bar))
10:51TimMcIf I run (flurb) now, I get an error about user/bar being unbound. Does that mean that the lookup in the namespace failed?
10:52raekfirst of all, defn creates or updates a global var, so it not limited to the scope of the make fn
10:52TimMcright
10:52raek(so in this manner, defn is very different from scheme's define)
10:53TimMcOnce (maker) is run, (flurb) will work.
10:53raekyes, when flurb is evaluated, bar will be resolved
10:53raekand the compiler will look for the var #'user/bar
10:53raekwhich does not exist yet
10:54TimMcOh! (ns-interns *ns*) shows that user/bar is already there!
10:54TimMcSo the compiler discovers internal defns and interns the names, but until the defn is *run* the var is just unbound.
10:54raek(normally, you should not execute any def or defn forms at run time)
10:55TimMcYeah, I discovered this by acciden before I was using paredit. :-P
10:55raek(since those are meant to be used to hot-swap code fixes)
10:56AWizzArdWhen something is resolved, what is it then? A resolution? i.e. (let [resolution (resolve my-symbol)] ...) ?
10:56raek,(class (resolve 'inc))
10:56clojurebotclojure.lang.Var
10:57raekTimMc: the compiler will not intern anything related to "bar" in your maker function
10:58TimMcThat's not what I saw in my REPL.
10:58raekthe bar parameter to defn will not be evaluated, since defn is a special form
10:58raek(...) in your maker function, when (defn maker ...) is evaled
10:59TimMcIf I do (defn a [] (defn b [] (defn c [] nil))) then (ns-interns *ns*) gives {b #'user/b, c #'user/c, a #'user/a}
11:00raekhrm. this is unexpected...
11:01raeklooks like this did not quote work as I thought it did
11:02raekTimMc: you are right. the compiler discovers the defs and interns vars for them.
11:02raekhowoever, having nested defns is expremely rare
11:02TimMcUnderstood.
11:03TimMcI can't think of a valid use-case.
11:05raekthis makes sense.
11:07raekTimMc: anyway, sorry for spreading false information :)
11:07TimMcheh, no worries
11:08TimMcOne thing that was not really discussed when I learned Scheme was homoiconicity.
11:09TimMc(This was in school, BTW.) I mean, we learned that "code is data" and had a little exposure to macros, but I never got that names like "apply" were symbols too.
11:12ChousukeOne of the main reasons I like Clojure is that it gives vectors and maps a place as "code" too.
11:12ChousukeYou can design more expressive macros since you have additional elements available.
11:13TimMcI thought that was *fantastic* when I found out.
11:13Chousukesets, too, I guess, but those really don't get much use in macros :P
11:15TimMcSo vars are discovered via namespace lookup, and dereferenced according to their dynamic binding.
11:15Chousukein eg. common lisp you only really have lists and symbols to work with, really, so you need to "overload" the semantics.
11:17ChousukeTimMc: 1.3 changes that a bit I think. If you want dynamic vars you need to be explicit about it.
11:18TimMcThat's reasonable.
11:19TimMcAt usage or definition time?
11:19Chousukedefinition
11:19TimMcOK, yay! raek, Chousuke -- thanks. I think I get vars and namespaces and symbols now.
11:20ChousukeWell, symbols in clojure are pretty simple. They're just names. In other lisps they're also containers :/
11:21TimMclalalalala I can't hear you :-P
11:21Chousukethe mapping goes symbol (name) -> var -> value
11:22Chousukeexcept with locals, where there is no var involved
11:22fliebelChousuke: When is something local?
11:22Chousukeinstead there is some magic storage somewhere that holds the name -> value mappings.
11:22TimMcChousuke: lexical scope, yeah?
11:22Chousukefliebel: let-ed things or function parameters I guess.
11:22Chousukeyeah
11:23fliebeloh, right. I've been doing to much 7 languages.
11:23companion_cubethis implementation must be quite slow, isn't it ?
11:24Chousukewhy would it be?
11:24Chousukethe symbol -> var mapping is done at compile time
11:24Chousukeand getting the value is just a deref
11:25Chousukeand as far as I understand, in 1.3, you'll get static behaviour by default which means there won't even be derefs in most cases.
11:25Chousukebut I don't know the details about that so take it with a grain of salt :P
11:25cdddramalloy_: Awesome.
11:28fliebelUgh, this gets me every time. When I do ->, I can use ->> once to move the argyment to the back, but when I do ->>, there is no obvious way to get it as the first argument.
11:29fliebel(->> for (#(except % this)))
11:29TimMcHaha, that's terrible!
11:30ahihihow does an atom behave if it's dereferenced while being mutated? does it return the previous value instantly, or b[C[C[C[C[Clock?
11:30ahihiwow, sorry. block*
11:30fliebelahihi: Previous
11:30fliebelRead up on MVCC if you want to know more.
11:31ahihiok, thanks :)
11:31fliebelTimMc: It totally is :(
11:32TimMcfliebel: Could you write a <<- macro or something to move it back?
11:33fliebel(defmacro <<- [form] (#(except % this)))) ;) almost… at least…
11:37TimMcOr a new macro that used some unhygienic marker for the stitch points.
11:37fliebelTimMc: Go wash your mouth! haha
11:38TimMc(--> (foo <> 4) (bar 5 <>) qux)
11:38fliebelTimMc: There are proposals like that floating around. I got one that involves letting % repeatedly.
11:38TimMcOr use amalloy's fantastic new hot-potato library to reorder the functions' arguments!
11:39fliebelwhat?
11:39clojurebotwhat is cells
11:41TimMcfliebel: https://github.com/amalloy/hot-potato <- It's a library of higher-order functions that rearraange the arguments passed to other functions.
11:42TimMchttps://github.com/amalloy/hot-potato/blob/master/test/hot_potato/core_test.clj
11:43fliebelscary...
11:43TimMc:-)
11:44TimMcAs far as readability is concerned, marking the stitch points explicitily seems superior.
11:45cdddrI am proud to be a small cause of that coming around, having irritated amalloy into writing it down. ;)
11:45TimMcI wonder if anyone will use it in a non-horrifying manner?
11:46cdddrDoes reordering for partial count as horrifying?
11:46fliebelTimMc: https://gist.github.com/9b5abe112cf69ea5356e
11:47cdddrThat said, I've discovered that nested defs really do away with 90% of the case I might want to use partial.
11:48TimMcfliebel: I'm trying to decode that thing...
11:48fliebelTimMc: macroexpand is your friend ;)
11:48TimMcNo, I think I've got it...
11:49TimMcThat's pretty fantastic, although unary functions will still have to be used like (identity %).
11:49TimMcVery clever.
11:49fliebelIt was written long ago by someone else in here. I had a macro that was far more complex, and actually nested stuff.
11:50TimMcA little preprocessing before the interpose step ould take care of that.
11:52TimMcWhat does nesting give you?
11:58jweiss_is there something i am missing in my leiningen project.clj that gives me line numbers in stack traces that contain my code?
11:58jweiss_currently I get "Unknown source"
11:58jweiss_and that's using the classes compiled by lein
11:59TimMcjweiss_: You're using lein compile, and then java -jar to run?
11:59jweiss_TimMc: well, java -cp `lein classpath`
12:00jweiss_basically the same i guess
12:00TimMc(Right, I was thinking of lein uberjar, nvm.)
12:02TimMcLet me try this out on my own code.
12:02TimMcNope, I'm getting line numbers.
12:02TimMcYou're using pretty much the default project.clj?
12:03jweiss_TimMc, it's a project mixed java/clj. some of the clj is AOT
12:03TimMcEeep, OK. I wouldn't know, then.
12:03jweiss_but java classes don't get line numbers
12:04jweiss_so i don't think it has anything to do with clj or aot
12:07TimMcIf you write a little Java class that just throws an exception in main, and compile and run that, do you get line numbers?
12:32fliebelHm, pity methods are not real functions.
12:39Kruppefliebel: care to elaborate?
12:40fliebelKruppe: Try (apply .someMethod arg arg2 argseq)
12:41Kruppefliebel: oh you meant java methods?
12:41fliebelyea
12:41Kruppefliebel: i thought you meant clojure methods, like defmethod
12:42Kruppefliebel: and yeah it's kind of annoying :(
12:43TimMc&(apply (memfn toString) "r")
12:43sexpbot⟹ "r"
12:43TimMc:-/
12:43fliebel&(doc memfn)
12:43sexpbot⟹ "Macro ([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."
12:44KruppeTimMc: annoying as in an irritant, not as in impossible to work with
12:44TimMcHence the :-/
12:44TimMcI wonder if there's anything blocking the compiler from automatically converting .foo into (memfn foo) when not in head position.
12:45TimMcIt's not a legal name anyway.
12:45KruppeTimMc: if this were CL I would play around with it
12:46KruppeTimMc: I think . is implemented in java though
12:46dnolenthere are so many times where you don't want to overhead of converting Java method to an fn.
12:46KruppeTimMc: some kind of reader macro
12:46TimMcdnolen: This would be an extension, though -- it wouldn't change existing code.
12:47dnolenTimMc: what do you mean, like a compiler flag?
12:47TimMcNo, a change in the default behavior of the compiler.
12:48TimMcI don't think (... .foo ...) appears in existing code.
12:48TimMc(modulo any rearrangement by macros)
12:49dnolenTimMc: how would you turn off this 'default behavior'?
12:49TimMcIf someone wants to use a .method across a bunch of values, won't they write (memfn .method) anyway?
12:49TimMcdnolen: Why should it be turned off?
12:49dnolenTimMc: I never use memfn
12:50TimMcOK, so you write #(.method %) instead?
12:51TimMcLet's say you want to (map .toString some-stuff) - what do you generally write?
12:51technomancyTimMc: generally for. but yeah, I agree about the overhead being negligible
12:52dnolenTimMc: depends on what I'm doing. I wouldn't use map at all if I care about performance. If I don't care, (map #(.toString ..)) sure.
12:53TimMcAnd that's appreciably faster to run than using memfn?
12:54dnolenTimMc: Maybe in some cases it can be JITed away, not sure. Write you own simple test and compare :)
12:56TimMcI suppose that using a function literal takes away the need for arity-based dispatch.
12:57TimMcIs your concern that given a shorthand for memfn, people would use that instead of a (potentially faster) function literal and unknowingly incur a performance hit?
12:58dnolenTimMc: memfn is the shorthand for what you want. JVM methods cannot be made first class.
12:59TimMcThis machine will be going down in a few minutes. Switching over...
12:59not-timmc...to this nick.
13:01dnolennot-timmc: unwrapped methods also have the benefit of flowing type information and not boxing.
13:02not-timmcOh, good point.
13:33fliebelWhy can't Incanter just plot some vectors/maps of data… I am making a heat-map, and it wants a function.
13:48fliebel32 is more than 0 is it? Or is there a branch of statistical computing where this is not so? user=> (view (heat-map (partial heatfn *2) 0 32 0 32)) => java.lang.IllegalArgumentException: Requires lowerBound < upperBound.
13:50Raynesfliebel: There is a parallel universe that I visit on the weekends where negative numbers are greater than positive numbers.
13:50amalloyer...mod 33? whatever makes 32 === -1
13:51TimMcBegone, pale imitation!
13:51Raynesamalloy: http://raynes.me/logs/irc.freenode.net/atomo/2011-02-08.txt Looks like he has been in #atomo as well.
13:51RaynesEr, wrong channel.
13:51amalloylol way to mischan
13:52TimMcMuch better.
13:52amalloyTimMc: stylish
13:53fliebelBut, anyone know what I do wrong?
23:20joshua__This: http://www.amazon.com/gp/offer-listing/0070131511/ref=tmm_hrd_used_olp_sr?ie=UTF8&amp;condition=used
23:20joshua__This: http://www.amazon.com/gp/offer-listing/0072970545/ref=tmm_hrd_used_olp_0?ie=UTF8&amp;condition=used
23:20joshua__What is the difference? Is it just the CD?
23:21joshua__Can I get the book that doesn't have the CD safely?
23:21joshua__I'm having trouble wrapping my head around the CD being valued at 20ish dollars.