2012-03-04
| 16:58 | qbg | I once tried to port condp to my syntax-rules system. Ouch |
| 16:59 | amalloy | hm. i can't tell what part of that dnolen is loud (excited?) about |
| 16:59 | dnolen | heh, nah - it's a micro optimization, but good to know |
| 16:59 | qbg | Yeah, that cond clause bugs me too :) |
| 17:02 | dnolen | qbg: always feel free to leave comments on GitHub about things you think are worth improving. |
| 17:02 | dnolen | I'm excited that more folks are digging into how core.logic actually works. |
| 17:03 | qbg | dnolen: Leave comments how? |
| 17:04 | dnolen | qbg: oh darn, I guess you can only comment on commits |
| 17:08 | bsteuber | did -?> survive the new contrib? |
| 17:08 | bsteuber | can't find it anywhere |
| 17:09 | scriptor | is clj-http the recommended way to make http requests in clojure? |
| 17:09 | technomancy | scriptor: yeah |
| 17:11 | ibdknox | bsteuber: I think it's in core.incubator |
| 17:12 | amalloy | really? |
| 17:12 | bsteuber | nice, thx |
| 17:13 | amalloy | apparently yes |
| 17:13 | amalloy | ugh, and it still has the same bug i tried to fix ages ago |
| 17:14 | bsteuber | amalloy: that would be? |
| 17:15 | amalloy | specifically if you (refer-clojure :exclude [->]) or other similar things, it doesn't work. it macroexpands to (-> ...) instead of to (clojure.core/-> ...) like it should |
| 17:15 | technomancy | has anyone gotten kibit to emit any output? |
| 17:15 | RickInGA | In emacs, I have a file date-operations.clj with ns test-proj.date-operations at the top. In another file in the same directory, I have :use test-proj.date-operations and I get an error when I try and evaluate |
| 17:16 | technomancy | it just says "done." for every project I've tried so far, even some with purposefully-crappy code |
| 17:17 | scriptor | hmm, created a new project with lein new, plugin installed swank-clojure 1.4.0, did M-x clojure-jack-in |
| 17:17 | pandeiro | ibdknox: was afk, so you think my probs are all that same issue with aot compilation? do i just need to keep rm -rf class/-ing constantly ? |
| 17:17 | scriptor | but when I try to compile, it says it's unable to resolve symbol defproject |
| 17:18 | ibdknox | pandeiro: I sent mail to the list, just set ^{:skip-aot true} on your :main entry. (example in the readme) |
| 17:18 | scriptor | oh, I see |
| 17:19 | scriptor | can't do C-c C-k from project.clj |
| 17:19 | pandeiro | ibdknox: cool, that's not too painful |
| 17:19 | ibdknox | eh, I'm not happy about it |
| 17:19 | pandeiro | ibdknox: you don't like the env variable solution? |
| 17:19 | ibdknox | but once the lein-newnew template exists for cljs projects it won't matter |
| 17:19 | pandeiro | of just having a $CLOJURESCRIPT_HOME? |
| 17:19 | ibdknox | oh definitely not |
| 17:20 | ibdknox | it's completely unacceptable to require people to download a repo of CLJS |
| 17:20 | pandeiro | k, i withdraw that suggestion then |
| 17:20 | pandeiro | scrub the logs please |
| 17:20 | ibdknox | moreover that won't work in tons of hosted scenarios |
| 17:20 | ibdknox | lol |
| 17:20 | pandeiro | ok |
| 17:20 | ibdknox | it's fine for alpha stuff |
| 17:20 | brehaut | i had a crack at integrating cljs into a python web workflow on the weekend |
| 17:20 | ibdknox | but long term, we need something better :) |
| 17:20 | ibdknox | brehaut: oh? |
| 17:20 | brehaut | ibdknox: moderate success |
| 17:20 | pandeiro | right, i also thought it's more economical just having the canonical repo in one place |
| 17:21 | brehaut | i think i could get a polished demo going |
| 17:21 | Bronsa | amalloy: wouldn't be enough to substitute ~'~non-safe-name with ~non-safe-name to fix it? (here https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L25) |
| 17:21 | pandeiro | but i see that's impractical when you're talking about deployment and stuff |
| 17:21 | brehaut | but having to call cljsc is painful |
| 17:21 | pandeiro | ibdknox: can you elaborate on the lein-newnew thing? is that something i can get already? |
| 17:22 | ibdknox | pandeiro: it allows you easily create templates. It will replace lein-noir once lein 2 comes out |
| 17:22 | pandeiro | brehaut: when i was trying to use cljs for couchapps, i was using chris' cljs-watch tool, which is simple and awesome imo |
| 17:23 | pandeiro | cljs-watch used $CLOJURESCRIPT_HOME, didn't it? i guess those were the early days |
| 17:23 | ibdknox | pandeiro: it was before you *could* package the compiler in a jar |
| 17:23 | ibdknox | I think I was the first to try |
| 17:23 | ibdknox | it was a mess though |
| 17:23 | brehaut | pandeiro: sure; theres external solutions that could be applied, but it makes it awkward to integrate with python tools (due to pythons piss poor build tool situation) |
| 17:24 | pandeiro | yeah but it worked :) |
| 17:24 | ibdknox | brehaut: noir.cljs.watcher might be useful |
| 17:24 | ibdknox | brehaut: you could probably package that into an uberjar and use it as a standalone build tool |
| 17:24 | pandeiro | brehaut: ah i see, i just went did building with bash and e-lisp, very ducttape style tho for sure |
| 17:24 | Raynes | ibdknox, pandeiro: It's compatible with Lein 1.x too. |
| 17:24 | ibdknox | yeah, I didn't mention that |
| 17:25 | brehaut | ibdknox: yeah, i think i need to look at something like that if i want to give this a real crack. if i can work out how to get hte webassets library to allow me to fire up a background process |
| 17:26 | technomancy | ibdknox: yeah, no need to wait |
| 17:27 | ibdknox | technomancy: but I liked only having 4 steps in my getting started thing :p I could probably add lein-newnew as a dep to my templates, but something about that seems bad to me |
| 17:27 | technomancy | well it'll only be another week before lein2 preview is out |
| 17:27 | technomancy | it's just a question of whether you want that to be a prereq |
| 17:28 | technomancy | "oh, by the way for all you OLD TIMERS who aren't already on lein2, here's a plugin install command to get you up to speed" |
| 17:29 | ibdknox | yep |
| 17:29 | ibdknox | that's what I was planning on |
| 17:29 | ibdknox | :) |
| 17:38 | tylergillies | i have a list consisting of some values e.g. (3 1 1/3) and i would like to iterate over the list, with a function and use the result of that function on the next item inthe list, keeping the same amount of elements in the new list |
| 17:39 | tylergillies | i tried redce, but it just gave me one value |
| 17:39 | tylergillies | instead of 3 |
| 17:39 | amalloy | reductions |
| 17:39 | tylergillies | reductions as in reduce function? |
| 17:40 | amalloy | &(doc reductions) |
| 17:40 | qbg | ,(doc reductions) |
| 17:40 | lazybot | ⇒ "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init." |
| 17:40 | clojurebot | "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init." |
| 17:40 | tylergillies | amalloy: thnx |
| 17:41 | tylergillies | theres so many functions to learn heh |
| 17:41 | qbg | At least they are there |
| 17:41 | tylergillies | god point |
| 17:41 | tylergillies | good |
| 17:42 | tylergillies | ah, that works nicely |
| 17:42 | tylergillies | awesome |
| 17:42 | tylergillies | thnx again |
| 17:45 | scriptor | what's the idiomatic way to reduce over a hashmap? Or should I use something else? |
| 17:46 | pandeiro | Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: re\| |
| 17:46 | pandeiro | move-aot in this context, compiling:(noir/cljs/watcher.clj:104) |
| 17:46 | pandeiro | ibdknox: ^ :( |
| 17:46 | scriptor | I'm just using the hashmap as a way to build a query string out of param-name->value associations |
| 17:46 | qbg | scriptor: reduce sounds good |
| 17:46 | pandeiro | i just cant win w/ cljs today |
| 17:46 | TimMc | scriptor: Maybe you should map and then join |
| 17:46 | ibdknox | pandeiro: hm? |
| 17:47 | y3di | does clojurescript suffer from the same spaghetti problems that js has when the js code doesn't have a framework like backbone helping it out. Or is clojurescript different because it's essentially clojure, and what works to structure clojure code will work with cljs code |
| 17:47 | pandeiro | upgraded to 0.2.1, added the :skip-aot tag, and now i get that error when i do lein run |
| 17:47 | ibdknox | oh |
| 17:47 | ibdknox | that's my fault |
| 17:47 | ibdknox | just a sec |
| 17:47 | scriptor | TimMc: map and join should do it |
| 17:47 | qbg | &(apply str (map (fn [[k v]] (str k "=" v)) {"a" 1, "b" 2})) |
| 17:47 | lazybot | ⇒ "a=1b=2" |
| 17:47 | TimMc | scriptor: That means you don't have to worry about boundary conditions either. |
| 17:48 | TimMc | qbg: *cough* URL-encoding *cough* |
| 17:48 | qbg | &(apply str (interpose "&" (map (fn [[k v]] (str k "=" v)) {"a" 1, "b" 2}))) |
| 17:48 | lazybot | ⇒ "a=1&b=2" |
| 17:48 | qbg | Yeah, you'll obviously need to encode it |
| 17:48 | TimMc | qbg: clojure.string/join, not apply str interpose |
| 17:48 | ibdknox | pandeiro: 0.2.2 lol |
| 17:48 | ibdknox | y3di: yes. ;) |
| 17:49 | scriptor | qbg: yep, I'm guessing http-get will encode it for me |
| 17:49 | scriptor | er, *clj-http |
| 17:49 | ibdknox | y3di: much like in Clojure the organization is left up to you, so how good/bad it is ends up primarily being driven by experience I think |
| 17:49 | qbg | reduce would be bad here because it'll make the computationally complexity bad |
| 17:50 | qbg | (well, if you're joining strings in the reduce that is) |
| 17:53 | amalloy | there's no way clj-http can encode it for you if you've already mashed it into a string. how can it know which & is intended to separate params, and which is part of a param value? |
| 17:54 | TimMc | Speaking of which, I hope urlencode does UTF-8 encoding by default |
| 17:54 | qbg | I hope it doesn't use URLEncoder |
| 17:55 | scriptor | true, amalloy |
| 17:56 | amalloy | besides, this function has been written a thousand times. why not find an existing implementation? |
| 17:56 | pandeiro | ibdknox: works! still find it weird it spits out the .cljs files to the output dir though... the compiler never did that before... does it do it on yours too? |
| 17:57 | ibdknox | yeah it does |
| 17:57 | tylergillies | is there a function that returns a vector from a given list? |
| 17:57 | ibdknox | ,(doc vec) |
| 17:57 | clojurebot | "([coll]); Creates a new vector containing the contents of coll." |
| 17:58 | tylergillies | ibdknox: thanks |
| 17:58 | tylergillies | i was doing ,(doc vector) |
| 17:58 | tylergillies | that didn't work |
| 18:00 | scriptor | doing (vector a) is basically the same as [a], it creates a vector containing the argument |
| 18:05 | scriptor | what's wrong with URLEncode? I've found one using that and another snippet that uses Ring's url-encode |
| 18:06 | qbg | It encodes spaces as + for one thing |
| 18:06 | weavejester | scriptor: Ring's url-encode is currently just a wrapper around URLEncoder/encode |
| 18:07 | scriptor | ah |
| 18:07 | scriptor | and doh, clj-http has a built-in way to let you pass a hash of query params |
| 18:07 | weavejester | scriptor: However, in 1.1 I'm going to fix the "+" issue so that the Ring url-encode is technically correct. |
| 18:07 | Raynes | scriptor: And form params too. |
| 18:07 | weavejester | scriptor: The Java URLEncoder doesn't strictly follow the spec. It's more a "form-urlencoded" encoder. |
| 18:08 | scriptor | weavejester: cool, is the "+" issue the only problem with it? |
| 18:08 | weavejester | scriptor: I believe so. |
| 18:11 | weavejester | Can anyone think of a good name for a function that acts like assoc, but creates an list or vector of values if the key already exists? |
| 18:11 | weavejester | e.g. (assoc-foo {} :a 1) => {:a 1} |
| 18:12 | weavejester | (assoc-foo {:a 1} :a 1) => {:a [1 1]} |
| 18:12 | weavejester | Naming things is often the hardest part :( |
| 18:13 | weavejester | Maybe… "assoc+" ? |
| 18:13 | qbg | assoc-conj? |
| 18:13 | qbg | Though that would imply it was already a collection inside |
| 18:13 | weavejester | qbg: Yeah |
| 18:13 | weavejester | assonj... |
| 18:13 | weavejester | :) |
| 18:14 | scriptor | assoc-conj-on-dup-key |
| 18:14 | scriptor | :p |
| 18:14 | weavejester | scriptor: Accurate, but a little long :) |
| 18:14 | brehaut | there are only two hard problems in computer science: cache invalidation, naming things and off by one errors |
| 18:14 | qbg | (unnamed-function 23) |
| 18:14 | weavejester | I think I might go with "assoc+"... |
| 18:15 | AimHere | brehaut > I see what you did there |
| 18:15 | brehaut | misquoted someone without attribution?> |
| 18:15 | scriptor | weavejester: I'm not sure, I feel like someone who didn't know what it did might assume assoc+ literally +'d on duplicate keys |
| 18:15 | pandeiro | ibdknox: playing around with watchtower found a typo in the readme - example is showing the watcher macro, not watch fn... just fyi |
| 18:16 | weavejester | scriptor: I'm hoping that "assoc+" would be sufficiently unusual syntax for users to check the docs quick :) |
| 18:16 | scriptor | heh, fair enough |
| 18:17 | AimHere | brehaut> the original quote didn't have the 'off by one error' either |
| 18:18 | brehaut | AimHere: theres a common joke version of it that does have it added; that wasnt original humour on the part of me |
| 18:19 | AimHere | Heh, well I think I'll attempt the 'off by one error' gag in every list of things wrong in computing/mathematics from now on |
| 18:19 | ibdknox | pandeiro: good catch :) Fixed. |
| 18:21 | ibdknox | weavejester: is that just an alias for (update-in x [:a] conj 1)? |
| 18:22 | ibdknox | I guess if you always want it to be a vector it's a bit more than that |
| 18:24 | scriptor | hmm, I'm doing (:require [clj-http.client :as client]), but I'm still getting 'get already refeers to #'clj-http.client/get in namespace: my-proj.core |
| 18:29 | ibdknox | scriptor: you'll have to restart swank/the repl/whatever you're using |
| 18:29 | ibdknox | or unmap it |
| 18:29 | ibdknox | probably easier just to restart |
| 18:32 | weavejester | &(update-in {} [:a] conj 1) |
| 18:32 | lazybot | ⇒ {:a (1)} |
| 18:32 | weavejester | ibdknox: Apparently not |
| 18:33 | weavejester | ibdknox: It's for cases like headers and parameters where you sometimes have multiple values to a key, but most of the time it's just one value to a key. |
| 18:33 | ibdknox | ah, I missed that it's only supposed to be a coll in the > 1 case |
| 18:59 | pandeiro | ibdknox: thinking about it, since noir-cljs outputs to one mega-file, is there any real reason for :output-dir to place files in resources/public/cljs/? when deploying one would probably just delete all its subdirectories leaving just bootstrap.js anyway, right? any thoughts? |
| 19:00 | ibdknox | pandeiro: I personally prefer to have things together, but you can pass any options you want for either of those |
| 19:31 | daaku | is swank.cdt the best debugger option for emacs, or is there something better? |
| 20:00 | francisl | should "lein clojurescript watch" works on OSX or is it still in development? |
| 20:06 | Frozenlock | Ok I'm stuck in a java-to-clojure problem again... how would that translate in clojure? |
| 20:06 | Frozenlock | send(d, new CreateObjectRequest(ObjectType.analogInput, new SequenceOf<PropertyValue>(values))); |
| 20:11 | brehaut | Frozenlock: start at the inner most expressions and work outward |
| 20:11 | TimMc | Frozenlock: First off, ignore the <generics>. |
| 20:12 | TimMc | Frozenlock: http://clojure.org/java_interop |
| 20:12 | brehaut | Frozenlock: you have constructors and a class property, it shouldnt be too hard |
| 20:12 | brehaut | Frozenlock: and as timmc said, you can ignore the generics annotation; generics are elided by the java compiler and dont actually exist at runtime |
| 20:13 | Frozenlock | Given "test" as the value, I have (CreateObjectRequest. ObjectType/analogInput (SequenceOf. test))) for the inner part |
| 20:13 | TimMc | looks good |
| 20:14 | Frozenlock | TimMc: http://clojure.org/java_interop I looked at it for the better part of last hour, and still can't get how I can insert "send" in all of this. |
| 20:14 | TimMc | Ah, how to call a method? |
| 20:14 | Frozenlock | The "->" macro? |
| 20:14 | TimMc | -> just rearranges code |
| 20:14 | TimMc | Frozenlock: What is "send"? |
| 20:15 | Frozenlock | A method, as you said |
| 20:16 | TimMc | on what object? |
| 20:16 | Frozenlock | d |
| 20:17 | TimMc | I doubt that... unless it is d.send(...) in the original Java code |
| 20:18 | Frozenlock | No it's not. :( |
| 20:19 | TimMc | Then send is a method of something else. What is it a method of? |
| 20:21 | TimMc | (hint: the answer is "this") |
| 20:22 | mk | can anyone suggest some clojure podcasts/talks? (besides the ones on infoq) |
| 20:23 | brehaut | mk: mostlylazy.com |
| 20:23 | weavejester | Does Clojure have a syntax for persistent queues, yet? |
| 20:26 | mk | brehaut: thanks! any ones from there that you suggest? |
| 20:26 | brehaut | mk: theres only 4 ;) |
| 20:27 | TimMc | &clojure.lang.PersistentQueue/EMPTY |
| 20:27 | lazybot | ⇒ #<PersistentQueue clojure.lang.PersistentQueue@0> |
| 20:27 | TimMc | weavejester: Doesn't look like it ^ |
| 20:27 | mk | brehaut: :) all equal quality? |
| 20:27 | TimMc | ,clojure.lang.PersistentQueue/EMPTY |
| 20:27 | clojurebot | #<PersistentQueue clojure.lang.PersistentQueue@0> |
| 20:27 | weavejester | &(clojure-version) |
| 20:27 | lazybot | ⇒ "1.3.0" |
| 20:27 | TimMc | clojurebot is on 1.4 beta or whatever |
| 20:27 | weavejester | Hm, oh well. No big deal to write a queue function of my own. |
| 20:29 | brehaut | must be the only datastructure that hasnt got its own literal :P |
| 20:30 | weavejester | I wonder what would be the best way to make a blocking queue in Clojure |
| 20:31 | weavejester | Maybe put the queue in an atom in a promise... |
| 20:31 | brehaut | ,(java.util.concurrent.LinkedBlockingQueue.) |
| 20:31 | clojurebot | #<LinkedBlockingQueue []> |
| 20:31 | weavejester | Or that! |
| 20:31 | brehaut | theres also a blocking priority queue too |
| 20:32 | weavejester | It looks like you can have a timeout, too. |
| 20:33 | brehaut | yeah, its really quite a nice implementation |
| 20:33 | mk | if I have a function that scrapes 10 webpages sequentially, how can I make this parallel in clojure, without making it messy? |
| 20:33 | brehaut | (pmap scrape seq-of-urls) |
| 20:34 | TimMc | Hum. Can anyone recommend an RDBMS that, unlike MySQL, support a standalone mode? (DB-in-a-file, good for unit tests.) |
| 20:34 | TimMc | I'm using SQLite, which *only* operatres in standalone mode, but I'd like to find some alternatives. |
| 20:36 | mk | wait, really? that'll just create howevermany threads, but will enter and return from a function as if it were one thread? |
| 20:36 | brehaut | mk: i think its backed onto a threadpool ? |
| 20:36 | mk | is there a way to limit the number of threads? |
| 20:36 | brehaut | otherwise yes |
| 20:38 | TimMc | mk: Doubt it. |
| 20:39 | pipeline | TimMc: one of the reasons i've been wanting to learn clojure is that sqlkorma looked like such a neat library. why not just use sqlite behind orm for tests, postgres behind orm for real? |
| 20:39 | brehaut | mk: i think its limited by the number of cores on the machine |
| 20:39 | TimMc | pipeline: Urgh, good point. |
| 20:39 | Frozenlock | TimMc: I'm lost. With: AcknowledgementService result; |
| 20:39 | Frozenlock | result = send(d, new CreateObjectRequest(ObjectType.analogInput, new SequenceOf<PropertyValue>(values))); |
| 20:39 | Frozenlock | Do I have enough info to answer the question? |
| 20:40 | TimMc | Nope. |
| 20:40 | pipeline | TimMc: or better yet, h-sql behind orm for tests -- then it can all be inside the damn build tree, w/ the db running out of a jar |
| 20:40 | Frozenlock | Damnit |
| 20:40 | brehaut | TimMc, pipeline korma lets you generate the SQL without executing it, which is potentially useful for tests |
| 20:40 | mk | hmm. I wanted to use it for scraping, which would be limited by the network. Is there an alternative to pmap that isn't lazy, and where the number of threads can be specified? |
| 20:40 | TimMc | Frozenlock: "send" is some method in the same class as that snippet. |
| 20:41 | TimMc | Frozenlock: or in an ancestor class, I guess |
| 20:41 | TimMc | pipeline: SQLite can do in-memory DBs as well, so that's nice. |
| 20:43 | TimMc | pipeline: Currently I'm just persisting stuff to DB, and doing all the real processing with Clojure functions. |
| 20:43 | TimMc | sqlkorma doesn't gain me much (yet) |
| 20:49 | TimMc | Auxiliary question to the channel: How to inject the use of (e.g.) an in-memory SQLite database for running test code? |
| 20:50 | Sgeo_ | How much does being on the JVM hurt Clojure as a language? |
| 20:50 | qbg | Sgeo_: You mean from a technical standpoint, or social? |
| 21:01 | tylergillies | how do i do (if (= foo bar) and (= bim biz))? |
| 21:01 | TimMc | I guess I'll make a db-spec var and (binding ...) it in the tests. |
| 21:01 | qbg | tylergillies: Use and? |
| 21:01 | tylergillies | qbg: thnx |
| 21:02 | tylergillies | didn't know and was a function |
| 21:02 | qbg | It is a macro |
| 21:02 | RickInGA | (if (and (= foo bar) (= bim biz)) |
| 21:03 | tylergillies | feels like a steep learning curve heh |
| 21:03 | qbg | (to be precise) |
| 21:03 | tylergillies | qbg: thats what i meant |
| 21:03 | TimMc | tylergillies: It is a macro so that it can shortcut: |
| 21:04 | TimMc | &(and 5 false (throw (RuntimeException. "oops"))) |
| 21:04 | lazybot | ⇒ false |
| 21:04 | TimMc | &(or false 5 (throw (RuntimeException. "oops"))) ;; likewise |
| 21:04 | lazybot | ⇒ 5 |
| 21:06 | RickInGA | TimMc: thanks for that explanation… I don't have any sense yet for why macros, or when, that was helpful |
| 21:06 | Frozenlock | There's many "clojure for java programmers" on the web... yet I can't find "java for lisp programmers" |
| 21:06 | tylergillies | Frozenlock: heh |
| 21:06 | tylergillies | i wish i had that problem |
| 21:07 | Frozenlock | Rather than..? |
| 21:08 | tylergillies | i don't think there is an implicit "rather than" there |
| 21:09 | brehaut | Frozenlock: there really isnt a huge amount of java you need to learn though |
| 21:10 | brehaut | Frozenlock: as long as you understand the difference between an object and a class, a method and a function, and what statics are, you are mostly done |
| 21:11 | Frozenlock | Slowly getting there. |
| 21:11 | Frozenlock | Slow-ly |
| 21:11 | brehaut | Frozenlock: have you dont any OO programming before? |
| 21:12 | brehaut | (ignoring how broad that umbrella is for the mean time) |
| 21:12 | Frozenlock | Nope |
| 21:13 | TimMc | Frozenlock: Basic rundown: In OO, "methods" are functions that run in the context of an object of a specific class. |
| 21:13 | Frozenlock | Just happily hacking my way on Lisp and Emacslisp. Clojure seemed like a nice way to jump on the JVM without touching java. *dramatic music* |
| 21:13 | TimMc | Frozenlock: A class is a type, a collection of methods, and maybe some (probably mutable) data fields. |
| 21:13 | Frozenlock | Well yeah, I get that :P I just don't immediatly see it when looking at java code |
| 21:14 | TimMc | (and there are also static methods, which just run in the context of the class, but not an instance of it.) |
| 21:14 | brehaut | finally there is constructors which are magic and in java are run by the new keyword |
| 21:14 | brehaut | but really are just a special case of functions |
| 21:15 | tylergillies | ive never met anyone with no OO experience, that is very interesting |
| 21:15 | Frozenlock | I feel like the ape in a zoo -_- |
| 21:15 | RickInGA | hehe |
| 21:15 | brehaut | tylergillies: ive met heaps; they all practise class oriented programming and call it OO ;) |
| 21:16 | tylergillies | brehaut: bwahahahahaha |
| 21:16 | TimMc | haha |
| 21:16 | RickInGA | brehaut: it took me about 3 years to make that step |
| 21:16 | brehaut | [alan kay pop culture joke here] |
| 21:16 | Sgeo_ | Frozenlock, maybe you should learn Smalltalk? Pure OO, and not ... Java. |
| 21:16 | Sgeo_ | >.> |
| 21:16 | Sgeo_ | Class-oriented OO too |
| 21:17 | Frozenlock | So to summaries: object.method(class) ? |
| 21:17 | brehaut | Frozenlock: nope |
| 21:17 | Frozenlock | summarize |
| 21:17 | Sgeo_ | object.method(argument1, argument2) |
| 21:17 | brehaut | Frozenlock: classes are a combination of struct, namespace and factory function |
| 21:17 | TimMc | Frozenlock: object.method(object object, object)... |
| 21:17 | tylergillies | i do object.method(hash) (in ruby) |
| 21:17 | tylergillies | but i guess hash == object |
| 21:17 | brehaut | Frozenlock: you can think of a method as a function that has its first argument in a funny place |
| 21:18 | TimMc | Frozenlock: If you see send()... that's this.send() |
| 21:18 | Sgeo_ | I guess now is a bad time to mention multi-methods |
| 21:18 | TimMc | Yes. |
| 21:18 | TimMc | shush |
| 21:18 | qbg | The Clojure interop method calls make that clear |
| 21:18 | Sgeo_ | Frozenlock, you never touched CLOS? |
| 21:19 | Sgeo_ | Although Java OO is less.. than CLOS |
| 21:19 | Sgeo_ | >.> |
| 21:21 | Sgeo_ | Frozenlock, note that things I say may be non-helpful. |
| 21:21 | Sgeo_ | Including that statement. |
| 21:22 | RickInGA | frozen lock do you have a desire to learn oo? |
| 21:22 | Frozenlock | TimMc: but in my example code, there isn't any this.send(), it's just send floating alone. |
| 21:22 | qbg | The this. is implicit |
| 21:23 | Frozenlock | RickInGA: If it can help me (not just in java, but everywhere) |
| 21:23 | TimMc | Frozenlock: Any chance that send() is a static method (your snippet would be part of another static method in the same class) |
| 21:24 | TimMc | Frozenlock: Did you get that code from a public website you can link to? |
| 21:26 | tylergillies | why is this false?: |
| 21:26 | tylergillies | ,(contains? ['tyler] 'tyler) |
| 21:26 | clojurebot | false |
| 21:26 | Frozenlock | It's from the source of mango bacnet4j, I pasted the part I'm currently working on here http://pastebin.com/p4EcWKcA |
| 21:26 | brehaut | tylergillies: contains? checks for the existance of a key, not a value |
| 21:26 | brehaut | ,(contains? [:tyler] 0) |
| 21:26 | clojurebot | true |
| 21:26 | brehaut | ,(contains? {:tyler :foo} :tyler) |
| 21:26 | clojurebot | true |
| 21:27 | tylergillies | i need a function for value |
| 21:27 | brehaut | ,(contains? #{:tyler} :typer) |
| 21:27 | clojurebot | false |
| 21:27 | brehaut | ~contains? |
| 21:27 | clojurebot | Cool story bro. |
| 21:27 | brehaut | ~contains |
| 21:27 | clojurebot | It's greek to me. |
| 21:27 | brehaut | ~botsmack |
| 21:27 | clojurebot | clojurebot evades successfully! |
| 21:27 | TimMc | contains? |
| 21:27 | TimMc | bah |
| 21:27 | brehaut | tylergillies: that requires a linear search of a vector |
| 21:28 | brehaut | ,(some :tyler [:a :tyler :b]) |
| 21:28 | clojurebot | nil |
| 21:28 | brehaut | damnit |
| 21:28 | TimMc | brehaut: .contains |
| 21:28 | TimMc | *shrug* |
| 21:28 | brehaut | TimMc: yeah that works, but its muddying the issue |
| 21:28 | TimMc | Frozenlock: "public static void test(LocalDevice d)" -- you're inside a static method, so send is another static. |
| 21:28 | tylergillies | looking for something that does something similar to Array#includes? in ruby |
| 21:29 | TimMc | brehaut: balderdash |
| 21:29 | brehaut | TimMc: its testing value containment on a list or vector is a bit of a code smell; .contains makes it look like it isnt |
| 21:30 | xeqi | ,(some #{:tyler} [:a :tyler :b]) |
| 21:30 | clojurebot | :tyler |
| 21:30 | brehaut | xeqi: thanks |
| 21:31 | brehaut | tylergillies: a set of one item is like that is an idiomatic alternative to #(= :tyler %) |
| 21:31 | tylergillies | on http://www.4clojure.com/problem/95 im flattening the arg and returning false if it contains () or false |
| 21:31 | tylergillies | that might be a bad idea though |
| 21:32 | Frozenlock | TimMc: ... what are the implications? |
| 21:32 | RickInGA | anyone know how I view/change my class path on a mac? |
| 21:32 | tylergillies | brehaut: not sure i understand the last statement |
| 21:33 | TimMc | Frozenlock: Do you have any idea what send actually does? :-/ |
| 21:33 | TimMc | If not, it'll be hard to translate that code. |
| 21:33 | brehaut | tylergillies: #(= %1 :a) is s function that takes one argument and returns :a (a truthy value) if its argument is equal to the keyword :a |
| 21:33 | brehaut | oh, i lie, it returns true there |
| 21:33 | brehaut | which is truthy |
| 21:33 | qbg | RickInGA: You set the class path when starting the jvm |
| 21:34 | brehaut | tylergillies: #{…} is a set literal. sets are functions of their contents |
| 21:34 | Frozenlock | Well I _hope_ it sends the create-object-request via IP to destination |
| 21:34 | brehaut | tylergillies: if a set contains the argument passed to it, it returns that argument |
| 21:34 | brehaut | ,(map #{:a} [:a :b :c]) |
| 21:34 | clojurebot | (:a nil nil) |
| 21:34 | brehaut | ,(map #(= % :a) [:a :b :c]) ;; tylergillies |
| 21:34 | clojurebot | (true false false) |
| 21:35 | tylergillies | brehaut: ahhh, interesting thnx. still getting used to the concept of data structures being functions |
| 21:35 | RickInGA | qbg I have a project with 2 clj files. when I try to refer to the code file from the test file I get a class not found error |
| 21:35 | RickInGA | which I took to mean that I must not have . in the classpath |
| 21:36 | qbg | RickInGA: Are you using a build tool such as leiningen? |
| 21:36 | RickInGA | I used lein to create the project, now I am editing the files in emacs |
| 21:36 | Frozenlock | TimMc: But I don't know how to use this method in clojure. Is the "implicit" works also in clojure? (. -implicit- (send (arguments))) |
| 21:36 | RickInGA | I just bought this computer yesterday, brand new to mac os |
| 21:36 | qbg | Are you using lein to run the project? |
| 21:37 | RickInGA | I was trying to evaluate an expression in emacs (swank) (ns test-proj.date-operations-spec (:use test-proj.date-operations)) |
| 21:39 | RickInGA | Having two files in the same project know about each other seems pretty trivial, but I don't know anything about mac, so I assume that I need to set something in my environment that I didn't know to set. |
| 21:39 | tylergillies | ,(contains? (flatten [1 [2 [3 [4 false nil] nil] nil] nil]) false) |
| 21:39 | clojurebot | false |
| 21:39 | tylergillies | .... |
| 21:40 | brehaut | tylergillies: just a hint: tree problems are frequently best approached recursively |
| 21:40 | tylergillies | brehaut: thanks, i haven't done much tree work |
| 21:40 | TimMc | Frozenlock: foo.bar(a1, a2) becomes (.bar foo a1 a2) |
| 21:40 | tylergillies | or recursion for that matter ;) |
| 21:41 | brehaut | tylergillies: the basic structure of your code probably wants to be of the form 'this is a tree if conditions C1 ; Cn are met, and the left node is a tree and the right node is a tree |
| 21:41 | TimMc | Frozenlock: Sorry, misunderstood -- no, there is no implicit "this" in Clojure. |
| 21:42 | brehaut | (except for proxys?) |
| 21:42 | TimMc | nor in static methods, in Java -- inside java.lang.Math, abs() is really Math.abs |
| 21:42 | TimMc | brehaut: shhh |
| 21:44 | TimMc | brehaut: That's just macro hax |
| 21:44 | brehaut | TimMc: sure, but its still implicit |
| 21:49 | RickInGA | do I have to build a project for one file in it to see another? |
| 21:49 | mk | what's the difference between apply and reduce? |
| 21:50 | RickInGA | mk: there isn't always one |
| 21:50 | brehaut | mk: reduce takes a function of two arguments and sequence and recursively applies it, apply takes a function of any number of arguments and a sequence of arguments |
| 21:51 | RickInGA | (apply + [1 2 3]) is 1 + 2 + 3 |
| 21:51 | scriptor | also, the function that reduce uses takes an accumulator and an element from the collectionas those parameters |
| 21:51 | scriptor | and when it's done the accumulator is returned |
| 21:51 | RickInGA | (reduce + [1 2 3]) is ( (1 + 2) + 3) |
| 21:51 | RickInGA | though maybe it would have been clearer if I used prefix notation :) |
| 21:51 | scriptor | so reduce is actually only similar to apply in very special cases |
| 21:51 | mk | so is apply (+ 1 2 3) while reduce is (+ 1 (+ 2 3)) |
| 21:52 | RickInGA | mk: yep |
| 21:52 | brehaut | not quite |
| 21:52 | brehaut | reduce is (+ (+ 1 2) 3) |
| 21:52 | brehaut | doesnt matter in this case, but it can do |
| 21:52 | mk | right :) |
| 21:53 | brehaut | haskell has a both left and right reduce's (called folds) |
| 21:53 | scriptor | one is lazy, the other tail recursive |
| 21:54 | brehaut | scriptor: im not sure that makes sense |
| 21:54 | mk | (the case in question is 4clojure's #24 - everyone solves it using apply or reduce, while #23 has many sorts of solutions) |
| 21:56 | brehaut | mk in this case, apply is used when the function takes varargs |
| 21:57 | brehaut | + for instance has an optimized internal recursive implementation that is much faster than having to make a bunch of function calls |
| 21:57 | scriptor | brehaut: hmm, it's been a while since I read up on it |
| 21:58 | brehaut | scriptor: im pretty sure haskell has many versions of at least foldl, depending what semantics you want |
| 21:59 | scriptor | + seems to use reduce1 when dealing with varargs |
| 21:59 | mk | which function is like reduce, but in unspecified order to take advantage of multicore? |
| 21:59 | scriptor | source for anyone interested https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L866 |
| 22:01 | mk | the hell... I've noticed that I'm mistyping question marks as parens, and trying to hit ctrl-enter to send messages on irc |
| 22:02 | tmciver | What's the best Clojre lib for scraping a DOM? I've been looking at enlive but it looks like it hasn't been maintained in a while. Any opinions on clojure.data.zip (used to be clojure.contrib.zip-filter)? |
| 22:02 | brehaut | tmciver: enlive is pretty solid though |
| 22:02 | mk | tmciver: an alternative is to just go with a java library |
| 22:03 | brehaut | tmciver: if you are scrapping an HTML dom you dont want to build off an xml lib |
| 22:03 | brehaut | tmciver: you want to at least use some sort of tag soup implementation (enlive is built on one; theres also a clj-tagsoup i believe - both wrap the java lib of the same name) |
| 22:04 | tmciver | brehaut: OK, so I need not be afraid that enlive appears old? |
| 22:04 | brehaut | correct |
| 22:05 | tmciver | brehaut: I'll check out clj-tagsoup as well. Thanks. |
| 22:05 | mk | I've been using enlive a bit recently and have found few problems (though I haven't figured out how to make it scrape in parallel) |
| 22:06 | brehaut | tmciver: you can always just use enlive to load the doc and then scrap with the xml libs if need be |
| 22:06 | brehaut | the biggest downside for enlive is that its documentation is terse and some things are a little confusing to work out |
| 22:07 | RickInGA | found my issue…. my files had dashes in them when they should have been underscores. date-operations ns should be in date_operations.clj |
| 22:07 | tmciver | brehaut: Yeah, I've noticed that. :/ |
| 22:08 | brehaut | tmciver: if you are just scrapping though, its pretty straight forward |
| 22:08 | brehaut | just working out how to translate the CSS selectors |
| 22:08 | tmciver | brehaut: I haven't looked too deeply at it yet, but do you know if enlive can also be used to generate generic xml? |
| 22:08 | mk | there's a reasonable tutorial at https://github.com/swannodette/enlive-tutorial |
| 22:08 | brehaut | tmciver: it depends if you need namespaces |
| 22:08 | brehaut | if you dont then you are fine |
| 22:08 | tmciver | brehaut: basically, I'm doing some relatively simple XSLT type of tranformations. |
| 22:08 | brehaut | im using it on my site to generate atom frinstance |
| 22:08 | tmciver | no, I shouldn't. |
| 22:09 | brehaut | you should be fine then |
| 22:09 | tmciver | OK. Thanks again. |
| 22:12 | RickInGA | my emacs is possessed. it keeps evaluating expressions while I type |
| 22:13 | qbg | It codes for you |
| 22:13 | qbg | Learning at a geometric rate... |
| 22:13 | RickInGA | haha |
| 22:18 | ibdknox | what should I write about tonight? |
| 22:20 | scriptor | predictive sexpr generation with modern editors |
| 22:21 | ibdknox | lol |
| 22:22 | ibdknox | I did some work on that for C# actually |
| 22:22 | ibdknox | obviously not sexprs |
| 22:22 | ibdknox | but predictive expression completion |
| 22:23 | scriptor | autocomplete? |
| 22:24 | RickInGA | ibdknox that was an improvement in vs2010 over 2008? |
| 22:24 | ibdknox | never made it anywhere |
| 22:25 | ibdknox | I actually got pretty far with it, but it's hard to make it work completely generally |
| 22:25 | ibdknox | scriptor: much smarter than autocomplete as it exists today |
| 22:25 | tmciver | ibdknox: I started watching Bret Victor's "Inventing on Principle" video. Totally awesome. I volunteer you to write an emacs mode for Clojure with the behavior of Bret's JS editor. |
| 22:25 | ibdknox | lol |
| 22:25 | ibdknox | pfft emacs is no fun :p |
| 22:26 | tmciver | Blasphemer! |
| 22:26 | ibdknox | tmciver: and actually I kinda did that already :) |
| 22:26 | scriptor | you're a vim guy? |
| 22:26 | ibdknox | yeah |
| 22:26 | scriptor | hmm, I use it for everything besides clojure |
| 22:26 | ibdknox | tmciver: I have an instant compilation mode for cljs now that will poll for changes and pop them up on the screen immediately. So I could do my game demo from vim now :) |
| 22:26 | tmciver | ibdknox: you did that already? Where is it? I wants it. |
| 22:27 | tmciver | Damn. Just cljs though, huh? |
| 22:27 | ibdknox | http://github.com/ibdknox/noir-cljs |
| 22:27 | ibdknox | yeah |
| 22:27 | ibdknox | though you could implement it trivially in clojure too |
| 22:27 | ibdknox | not sure what context it'd really be that useful in though |
| 22:27 | tmciver | Hmm, sounds like yet another Clojure project that's over my head. I'll do it! |
| 22:28 | ibdknox | haha |
| 22:28 | ibdknox | :) |
| 22:33 | daaku | i implemented some watching & reloading logic for use in the repl (requires java 7): https://github.com/nshah/auto-reload.clj |
| 22:33 | ibdknox | daaku: why does it require 7? |
| 22:33 | daaku | ibdknox: uses the java 7 watching libraries |
| 22:33 | ibdknox | oh |
| 22:33 | daaku | i mean, watching files |
| 22:33 | ibdknox | http://github.com/ibdknox/watchtower makes that simple :) |
| 22:35 | daaku | ibdknox: cool, didn't know about that. would be cool to make watchtower use the the nio watching logic instead of polling if available |
| 22:36 | ibdknox | when 7 gets some marketshare, absolutely |
| 22:41 | technomancy | graceful degradation can't be too hard |
| 22:43 | qbg | Check for the existence of the appropriate classes at compile time and generate the needed code |
| 22:46 | tylergillies | is there a way to call the current anonymous function without 'recur'? |
| 22:47 | qbg | If you use fn you can give it a name |
| 22:47 | technomancy | there's the Y combinator |
| 22:47 | qbg | &((fn foo [] foo)) |
| 22:47 | lazybot | ⇒ #<sandbox6997$eval9948$foo__9949 sandbox6997$eval9948$foo__9949@123bb0> |
| 22:47 | tylergillies | y combinator is intimidating |
| 22:47 | technomancy | that's true. and not terribly useful |
| 22:48 | tylergillies | qbg: thnx |
| 23:06 | tylergillies | any hints on how i can do https://refheap.com/paste/927 without any "catch" 4clojure doesn't like it: http://www.4clojure.com/problem/95 |
| 23:08 | RickInGA | tylergilles: would if-let work for that one? |
| 23:10 | jodaro | aww man, one day tickets for clojure west announced like two days after i register for both days |
| 23:10 | tmciver | tylergillies: perhaps you could utilize the 'not-found' behavior of nth so that it doesn't throw. |
| 23:10 | tmciver | ,(doc nth) |
| 23:10 | clojurebot | "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences." |
| 23:11 | tmciver | jodaro: that's how they get ya. |
| 23:11 | jodaro | i've been got, for sure |
| 23:11 | jodaro | saturday was iffy for me |
| 23:11 | tylergillies | tmciver: ah thnx, lisp reminds me of lojban where you have to memorize all the function names AND what positions they have heh |
| 23:11 | jodaro | i'm going to see if i can switch |
| 23:13 | daaku | i'm trying to speed up some work that involves file io using pmap, which seems to have worked, and along with eliminating some reflection i've gone from 8 to 3 minutes -- now i'm seeing "sun.misc.unsafe.park" taking up roughly as much time as the readBytes on the file and i'm not sure what that is (thread dump here: https://gist.github.com/7e1b19809fc020b6ed18) |
| 23:13 | tmciver | tylergillies: huh, I'd never heard of lojban before. Interesting. |
| 23:14 | daaku | is this indicative of pmap's threads being expensive, and indicating that i should chunk + map + pmap to reduce that cost? |
| 23:41 | tylergillies | any hints on how i can refactor this? https://refheap.com/paste/928 |
| 23:54 | tylergillies | everytime i see the bot say 'recently...' i think of a tv show. "Previously on clojure: 'omg jenny you're such a lazy list'" |