2012-09-01
| 00:02 | john2x | why do I get "Unable to find state with key: :tile-count-y" with this? http://pastie.org/4643791(line 15, i'm using Quil) |
| 00:02 | john2x | http://pastie.org/4643791 |
| 00:08 | S11001001 | john2x: set-state! is not cumulative; it replaces *all* the state |
| 00:09 | technomancy | jkkramer: was it a conscious decision to not treat the pom metadata as canonical? |
| 00:09 | technomancy | nesting :description, :url, etc under the :clojars sub-map? |
| 00:09 | john2x | S11001001: oooh right.. didn't understand the doc very well.. thanks! |
| 00:11 | S11001001 | john2x: reading source is your friend; docs will always let you down in the end |
| 00:11 | jkkramer | technomancy: in the final graph format? |
| 00:12 | technomancy | just tackling read-all-pom-projects for now |
| 00:12 | muhoo | is there some way to get nrepl.el to send forms to some ns other than user? |
| 00:13 | technomancy | jkkramer: oh, I see where you make a best guess at the top-level description |
| 00:13 | jkkramer | technomancy: reconstructing my own thought process here, too. I believe that part merely adds a :clojars key to the project map extracted from the pom |
| 00:13 | muhoo | i found nrepl-buffer-ns, but can't figure out how to set it |
| 00:13 | technomancy | in build-best-info |
| 00:13 | technomancy | muhoo: the current buffer ns tracking stuff in nrepl.el is a bit wonky |
| 00:13 | technomancy | I tried to get him to read it from the file every time, but that didn't fly =\ |
| 00:13 | john2x | S11001001: hehe yeah.. just starting out with clojure.. trying to port all Generative Design code samples to clojure as an exercise.. reading the source a bit too intimidating I guess.. I'll keep in mind though. :) |
| 00:14 | muhoo | technomancy: is there some hack i could use to get around the wonky? |
| 00:14 | technomancy | C-c M-n maybe? |
| 00:15 | muhoo | M-n is bound by my wm |
| 00:15 | muhoo | what is the emacs function usually bound to it? |
| 00:15 | technomancy | ESC-n is another way to do M-n |
| 00:15 | muhoo | M-n is undefined |
| 00:16 | muhoo | ah, i see nrepl-set-ns |
| 00:16 | technomancy | right; you have to do C-c first |
| 00:17 | muhoo | i found it in nrepl-interaction-mode map. |
| 00:32 | muhoo | nope, nrepl-buffer-ns is not getting sent, anything getting nrepl-intearative-eval'ed is going to #user/ . oh well. thanks anyway. |
| 00:37 | john2x | can I use an atom in a let() and change it's value within the let()? |
| 00:39 | arohner_ | why is there keep-indexed, but not filter-indexed? |
| 00:40 | arohner | also strange that keep-indexed returns the result of (f index item), rather than item |
| 00:58 | arohner | stupid question. Why are keywords not sugar for strings? |
| 00:59 | ivan | because keywords are optionally-namespaced symbolic identifiers that implement IFn |
| 00:59 | Raynes | (defn filter-indexed [f coll] (keep-indexed #(when (f % %2) %2) coll)) |
| 01:00 | amalloy | (filter-indexed (fn [i x] (even? i)) (repeat 10 nil)) ;; Raynes |
| 01:00 | Raynes | Congratulations. |
| 01:00 | ivan | a string is some unicode and is not a symbolic identifier |
| 01:01 | arohner | ,(keyword "Π") |
| 01:01 | clojurebot | :?? |
| 01:01 | lazybot | clojurebot: Uh, no. Why would you even ask? |
| 01:01 | clojurebot | Huh? |
| 01:02 | arohner | works on my machine |
| 01:02 | Raynes | Namespaced keywords aren't particularly special. They just have names prefixed with whatever namespace. |
| 01:02 | Raynes | So strings could do the same thing. But strings aren't functions. |
| 01:02 | arohner | I like the IFn answer, but that's a limitation of java. if you were writing your own lisp, why care about string vs. keyword? |
| 01:03 | Raynes | What does it matter if a keyword is a specialized symbol or a specialized string? |
| 01:03 | arohner | I'm trying to understand why you would create the concept, if it didn't exist |
| 01:04 | amalloy | keywords guarantee that = provides the same results as identical? |
| 01:04 | amalloy | is one reason they're useful |
| 01:04 | arohner | I appreciate the sugar, but making it a different type seems like a mistake Rich doesn't make lightly |
| 01:04 | Raynes | A mistake? :\ |
| 01:05 | arohner | I'm not sure it is a mistake. as I said, I'm trying to understand why you would create the concept if it didn't exist |
| 01:35 | muhoo | https://github.com/kingtim/nrepl.el/pull/60 <== already fixed by someone, yay |
| 02:13 | muhoo | trying to run nrepl on a 256MB embeded board is just... not a very practical idea. |
| 02:14 | muhoo | old lein1 with the telnet repl worked fine. new lein2 with nrepl does not. |
| 02:15 | guns | muhoo: Running clojure on Raspberry pi? |
| 02:19 | muhoo | guns: beagleboard |
| 02:19 | guns | muhoo: Ah. And how is that working. Very curious |
| 02:20 | muhoo | it worked great with lein1. with lein2, not so much. |
| 02:20 | guns | hm. But clojure programs themselves run acceptably? |
| 02:21 | muhoo | i suppose i should try aot'ing the app and running it that way. would probably be more successful. |
| 02:21 | guns | It seems like such an excessive luxury on an embedded plaform. |
| 02:21 | guns | OF course I'm gonna try it when I get my hands on one |
| 02:21 | clojurebot | RickInGA: of course :-) *everything* is in Clojure |
| 02:22 | guns | I guess 256M RAM stretches the boundaries of "embedded" |
| 02:22 | amalloy | surprisingly relevant, clojurebot. well done |
| 02:22 | muhoo | i got addicted to being able to do things interactively on it. |
| 02:23 | guns | That sounds fantastic; compile-restart doesn't take that long, but commanding the board from the editor sounds like a great time |
| 03:47 | john2x | how do I include a jar file I downloaded from the internet in my leiningen 2 project? (where do I place it?) |
| 04:09 | tomoj | shouldn't there be a way to fold a vector in reverse? |
| 04:12 | tomoj | should there be a ReduceReversible protocol? |
| 04:21 | Raynes | tomoj: (reverse (reduce …)) :P |
| 04:21 | Raynes | Er, backwards. |
| 04:22 | Raynes | Don't mind me, just being an ass. |
| 04:24 | amalloy | tomoj: that seems like a nice property, and possible, but i'm not sure how you would fit it into the existing reducers lib |
| 04:25 | amalloy | you basically want rseq as a reducer traansformer |
| 04:36 | tomoj | amalloy: yeah |
| 04:36 | tomoj | but |
| 04:36 | tomoj | not exactly |
| 04:36 | tomoj | I mean it can't work on any reducer |
| 04:41 | amalloy | right, it has to be a separate protocol |
| 04:49 | tomoj | is that different than foldr? |
| 05:03 | tomoj | seems the same on vectors |
| 05:03 | tomoj | but maybe the protocol should be for foldr, like IRightReduce |
| 05:04 | tomoj | then a tree type can get both foldl and foldr even though rseq doesn't make sense |
| 05:25 | n00b6502 | does clojure have 'tree-like fold' .. its more parallelizable .. (f (f a b)(f c d)) vs (f a (f b ( f c d)))) |
| 05:26 | tomoj | yes, it's called 'fold' |
| 05:26 | tomoj | new in 1.5.0 (which is still alpha) |
| 05:27 | tomoj | clojure.core.reducers/fold to be specific |
| 05:44 | n00b6502 | ah so the named default is tree like. neat. |
| 05:52 | tomoj | well the normal folding function is `reduce`, `fold` is the parallel version and only works on a subset of the things `reduce` works on |
| 06:56 | abp | weavejester: are you around? |
| 07:00 | abp | weavejester: I got some crazy ideas about reverse routing in compojure floating in my mind and want to let them wander through yours, to validate. :) |
| 07:00 | lytton | any problems with executing Clojure, compojure and cucumber with lein2? When I add cucumber to plugins it fail (user.clj:14) |
| 07:10 | weavejester_ | abp: I'm around now |
| 07:11 | abp | weavejester_: So as a disclaimer: I've not thought this. weavejester: Basically it's just about acquiring a {:name route} map during route-definition via metadata on handlers until a handler is invoked, when it should be assoced back into the request to (reverse request :route params) in handlers. |
| 07:13 | weavejester | Okay. Such routing maps would not work in all cases, but might be able to cover the majority. |
| 07:14 | abp | weavejester: Which cases would not work? I haven't looked into context by now. |
| 07:15 | weavejester | Routes can be chosen according to arbitrary criteria. |
| 07:15 | weavejester | For example |
| 07:15 | weavejester | (if (= :heads (coin-toss)) routes-a routes-b) |
| 07:16 | abp | weavejester: Ah okay. |
| 07:17 | weavejester | That's partially why I've not added any form of reverse routing, because it seems a little iffy - it's not a guaranteed thing. |
| 07:18 | abp | weavejester: Yes, that's really inconvenient, but working without reverse-routing is too. |
| 07:19 | weavejester | My thought is that if reverse routing is wanted, then we'd need something on top of Compojure |
| 07:19 | weavejester | e.g. if you create routes with library X, you can reverse route. |
| 07:20 | weavejester | Maybe by defining a resource or something. |
| 07:21 | tomoj | what is reverse routing? |
| 07:21 | weavejester | Given a var, what URL is it bound to |
| 07:21 | abp | weavejester: Hm, probably, but light-weight, stateless reverse-routing would fit compojure, I think. Everything else would have that "bolted on" feel, because it is. :) |
| 07:21 | weavejester | Instead of normal routing, which is, given a URL, which var should I use as a handler |
| 07:22 | weavejester | abp: It wouldn't be bolted on. It would be a new layer |
| 07:22 | weavejester | The problem with reverse routing at the Compojure level is that Compojure allows you to write routes that are impossible to reverse. |
| 07:23 | weavejester | And I don't like the idea of a fuzzy reverse route |
| 07:23 | weavejester | But if there was a library on top of Compojure that constrained which routes were allowed, you could get more information. |
| 07:26 | weavejester | Maybe a library that used a data structure of routes |
| 07:28 | abp | weavejester: Yeah, I will think a little more this. |
| 07:29 | abp | *about this. |
| 07:30 | weavejester | Good luck :) |
| 07:33 | abp | weavejester: Thanks. :) I recently watched the recording of your neat introductory talk about ring and compojure from functional web architecture. How are your "next steps" (content negotiation and the like) going? :) |
| 07:34 | pyykkis | weavejester: just out of curiosity, did you end up with capitalized http verbs based on the http protocol or what? Seemed a little odd first given the clojure naming conventions and sinatra api from ruby world. |
| 07:34 | pyykkis | ..how did you end up.. |
| 07:35 | weavejester | abp: Currently stalled, I'm afraid. I'm currently working on migrations (via ragtime) and thinking about distributed computing |
| 07:36 | weavejester | pyykkis: HTTP verbs are usually capitalized, and it seemed like a good way of distinguishing them from a normal Clojure function. This was 4 years ago, however, and if I were going to do it again, I might rethink things. |
| 07:37 | weavejester | pyykkis: That said… (GET "/foo/:id" [id] …) is perhaps more obvious as to its function than (r/get "/foo/:id [id] …) |
| 07:38 | abp | weavejester: Ok, doesn't sound bad either. |
| 07:39 | weavejester | pyykkis: At least it is to me. I've been conditioned to see GET and POST and PUT etc. as HTTP verbs if they're capitalized |
| 07:40 | casion | especially since get is already used in core |
| 07:42 | weavejester | Yeah, though it could have been (route/get "/" [] ...) |
| 07:42 | weavejester | But to me that stands out less. |
| 07:43 | pyykkis | weavejester: ok, thanks for the answer. I guess I'm conditioned for the Sinatras lowercases :) Anyways, both compojure and ring get my smiling for happiness every time. Just the right level of abstraction without loads accidential complexity. |
| 07:44 | pyykkis | quite refreshing after rails & co |
| 07:44 | pyykkis | casion: ah, that's a good point |
| 07:45 | weavejester | Yeah, we couldn't ever have (get "/foo" [] …) like in sinatra |
| 07:45 | weavejester | Well… not without a (:refer-clojure :exclude (get)) :) |
| 07:45 | weavejester | pyykkis: It's good to hear you're enjoying it. |
| 07:45 | @rhickey | lein q: can :pom-addition be used to bring in e.g. the clojure-maven-plugin into the generated pom? It needs to merge into the build branch |
| 07:46 | @rhickey | I've tried but it seems to be a no-op |
| 07:46 | pyykkis | haha, requiring people to exclude get woud've surely be confusing :) |
| 07:46 | @rhickey | :pom-addition [:build [:plugins [:plugin ... |
| 07:49 | xeqi | rhickey: no, adding maven plugins doesn't work |
| 07:58 | @rhickey | xeqi: thanks |
| 08:05 | xeqi | rhickey: actually, reading it again I would expect it to work with -preview8 or later; though if there multiple src directories it would end up with 2 <build>s :\ |
| 08:16 | samrat | i'm trying to use clj-oauth with Instapaper's xauth API, but its a bit confusing because "there is no request-token/authorize workflow" |
| 08:22 | pyykkis | hm..is there a way reload nrepl session started with nrepl-jackin? |
| 09:03 | weavejester | Hm, that's annoying. Clojure 1.5.0-alpha4 is compiled against 1.6. |
| 09:28 | voland62_2 | What's the difference between -> and ->> macroses? |
| 09:38 | xeqi | &(-> 1 (- 3)) |
| 09:38 | lazybot | ⇒ -2 |
| 09:38 | xeqi | &(->> 1 (- 3)) |
| 09:38 | lazybot | ⇒ 2 |
| 09:39 | xeqi | -> inserts the first argument, ->> uses inserts the last arguments |
| 09:41 | casion | I'm working on java interop learning, and I'm a bit lost with how one would work with InputStream.read(byte[] b). How do I pass and 'get' the byte-array to it? |
| 09:42 | casion | passing the correct arg is no problem, but getting the filled array is beyond me atm |
| 09:45 | xeqi | (doc into-array) |
| 09:45 | clojurebot | "([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE." |
| 09:46 | RonnieDk | , (re-find #"<span id=\"yfs_184_carl-b.co" |
| 09:46 | RonnieDk | "<span id=\"yfs_l84_carl-b.co") |
| 09:46 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 09:47 | casion | xeqi: I'm not sure how to apply that info.. if read() returned the array then I get it, but it returns the bytes read |
| 09:48 | RonnieDk | is there a way to repeat the last expression entered nrepl? Without copy/paste |
| 09:50 | jkkramer | casion: the byte array is mutable, so bind it with let, then just refer to the same binding after the read call |
| 09:51 | casion | jkkramer: that's what I thought, but it's not working… so I assume I"m doing something else wrong |
| 09:51 | casion | I will work under that assumption then, thank you |
| 09:51 | xeqi | casion: yeah.. I think you just want to do something like (let [b (byte-array array-size)] (.read inputstream b) ..) |
| 09:51 | xeqi | then you could (slurp b) to get a string, but I'm sure theres something different you want to do to it |
| 09:52 | casion | it's telling me that it's read the whole stream, then the byte-array is still empty |
| 09:52 | casion | I'll work through it, at least I have the concept correct :) |
| 09:52 | casion | thanks again |
| 09:54 | xeqi | casion: how are you trying to get data out? (aget b 0), (seq b), etc |
| 09:54 | casion | I'm just checking with alength atm |
| 09:54 | casion | which it would seem to mean that the array isn't getting set to the right size to begin with |
| 09:55 | casion | ahhhh |
| 09:56 | casion | InputStream.available() was returning 0, and that's what I was using to create the byte-array |
| 09:57 | casion | read wasn't throwing an exception when passing a 0 length array though :\ |
| 09:59 | casion | and everything works now :) |
| 10:14 | @rhickey | Is there a way to get lein to use a local jar not in any repo (as a dep)? |
| 10:19 | xeqi | rhickey: you could use https://github.com/kumarshantanu/lein-localrepo to inject the jar into your local maven cache |
| 10:20 | xeqi | but lein tries to encourage repeatability, so doesn't have a mechanism for jars outside repos |
| 10:20 | xeqi | ~repeatability |
| 10:20 | clojurebot | repeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability |
| 10:21 | @rhickey | repeatability should not get in the way of experimentation when things are new, as all of this artifact-based stuff does |
| 10:21 | tmciver | xeqi: I know you could (in lein 1.x) run 'lein install' in a local project to install a jar in the local maven repo. |
| 10:21 | @rhickey | I don't want in in a repo, I know how to do that |
| 10:22 | Sgeo | Would bundling a jar with your code prevent repeatability somehow? |
| 10:23 | @rhickey | xeqi: thanks for the info |
| 10:24 | jonasen | I'm using lein install with lein2 and it works for me |
| 10:25 | xeqi | Sgeo: it could work, but then your sticking jars in the version control system |
| 10:25 | xeqi | lein accepts file:// repos, so it can be done, just ugly to get it all setup in the format maven likes |
| 10:31 | samrat | i'm using clj-oauth, which uses clj-http 0.2.7 but I need to use clj-http 0.5.3(latest), what do I do? |
| 10:32 | samrat | if I do add [clj-http "0.5.3"] as a dependency I start getting errors |
| 10:39 | xeqi | samrat: I think your choices are fork clj-oauth and fix the errors, and make a pull request upstream; or use a different oauth lib |
| 10:39 | xeqi | https://github.com/r0man/oauth-clj looks like it uses the clj-http mentioned |
| 10:45 | ssideris | hello. if bytes in java go from -128 to 127, shouldn't this code return "ff"? |
| 10:45 | ssideris | (format "%02x" (byte 127)) |
| 10:46 | ssideris | &(format "%02x" (byte 127)) |
| 10:46 | lazybot | ⇒ "7f" |
| 10:46 | samrat | xeqi: will try that. how do i add my own fork to a project? do I have to upload it to clojars? |
| 10:46 | ssideris | (which as you can see it doesn't) |
| 10:47 | xeqi | &(format "%02x" (byte 255)) |
| 10:47 | lazybot | java.lang.IllegalArgumentException: Value out of range for byte: 255 |
| 10:47 | ssideris | samrat: there is also this: https://github.com/tobyhede/lein-git-deps |
| 10:47 | zilti | ssideris: The hex system doesn't get changed just because Java only supports "byte" up to 127. 7f means 127 |
| 10:48 | zilti | * means byte-value 127 |
| 10:49 | samrat | ssideris: yeah, but I mean during developing locally? |
| 10:49 | xeqi | samrat: change the group name to something like org.clojars.samrat; lein install in your fork will make it work locally |
| 10:50 | ssideris | zilti: ok, but the puzzling thing is that if I map a jpeg file to a MappedByteBuffer, then do (format "%02x" (.get data 0)) I get "ff" |
| 10:50 | xeqi | uploading to clojars is prolly the easiest to make it work on multiple machines |
| 10:50 | tmciver | ssideris: if you don |
| 10:50 | ssideris | when (class (.get data 0)) is also a jaba byte |
| 10:50 | ssideris | java |
| 10:51 | tmciver | if you don't cast to byte, it works ##(format "%02x" 255) |
| 10:51 | lazybot | ⇒ "ff" |
| 10:52 | dhofstet | how does one submit typo fixes for the API docs? Creating a pull request on Github? |
| 10:53 | samrat | xeqi: did lein install, but how do I specify in project.clj that I want the local repo and not from clojars? |
| 10:54 | ssideris | samrat: there is also the option of having a checkouts dir in your project |
| 10:54 | zilti | I'm looking for a way to "move" inside a nested map which has potentially indefinitely many levels. I need to be able to somehow "jump" to a position and I need to be able to move "upwards". What do I best use for this and is there a good example/tutorial? |
| 10:55 | ssideris | zilti: look into zippers |
| 10:57 | samrat | mattrepl: hi, any plans on upgrading clj-oauth? i was having some troubles |
| 10:59 | xeqi | samrat: if you changed the group name in the fork, then change the group name in the :dependencies. make sure the versions line up too; if you didn't change the group name, then just make sure the versions match |
| 11:00 | xeqi | dhofstet: for clojure or a contrib library? |
| 11:00 | dhofstet | xeqi: clojure |
| 11:01 | mattrepl | samrat: yeah, had you messaged me on github about that? there's an outstanding request I haven't made time for (brb, toggling between afk) |
| 11:04 | zilti | hmm could it be nrepl.el is broken? Does it live-compile? because each time I try to type I get the message "Unable to resolve symbol: if-let in this context" even though I don't use it |
| 11:04 | xeqi | dhofstet: I think you have to sign a CA and make a ticket in jira, clojure uses github as more of a mirror |
| 11:04 | xeqi | zilti: https://github.com/kingtim/nrepl.el/issues/86 ; it works sometimes |
| 11:10 | dhofstet | xeqi: hm, seems a bit overkill for such a trivial fix |
| 11:11 | seancorfield | the CA etc provides legal protection for the Clojure project which is important if the language is to gain wider acceptance in industry |
| 11:11 | seancorfield | nearly all open source language projects require a CA these days for licensing reasons |
| 11:12 | seancorfield | see http://clojure.org/contributing for more details |
| 11:12 | zilti | ok so nREPL is totally broken at the moment... too bad |
| 11:13 | seancorfield | (sorry if this seems like a hot button for me but i've been doing open source software development for twenty years and i'm always surprised when people object to signing an IP agreement) |
| 11:13 | cshell_ | Yeah, Sun was doing it with all of their os projects - doesn't seem that out of line |
| 11:14 | dhofstet | seancorfield: I understand that, but for removing three spaces from the docs it is just not worth going through this process |
| 11:15 | seancorfield | dhofstet: agreed for that - you could just open a ticket in jira about it i believe without needing any paperwork |
| 11:15 | seancorfield | someone with a CA on file will be happy to make that change i expect :) |
| 11:15 | dhofstet | seancorfield: ok, will do |
| 11:16 | xeqi | seancorfield: ah, I wasn't sure if you needed a CA to open a ticket |
| 11:17 | seancorfield | only for submitting a patch - but you probably need to create a jira account to open a ticket |
| 11:18 | seancorfield | basically clojure & contribs cannot accept any code from someone without a CA on file - and won't accept pull requests because of the (potential) issues tracking down all contributors to a repo and all the CAs for them |
| 11:18 | seancorfield | so patches only, from folks with CAs |
| 11:20 | wmealing_ | i dont understand why a CA for a language would be different than requiring a CA for a program |
| 11:20 | wmealing_ | not my pony though. |
| 11:20 | wmealing_ | it cant be any more GPL, and by working on a project, its not up to a project to be complicit with licencing |
| 11:20 | wmealing_ | its up to the contributor to understand |
| 11:21 | seancorfield | wmealing_: not saying there's a difference between language project and program project... |
| 11:23 | wmealing_ | other software has got along fine for the longest time |
| 11:23 | wmealing_ | imagine gcc. |
| 11:25 | wmealing_ | so, if i wanted to add properties like value="n" to a drop-down in hiccup, is that possible ? |
| 11:26 | wmealing_ | http://weavejester.github.com/hiccup/hiccup.form.html#var-drop-down <-- for the docs.. if anyone thinks i'm going mad. |
| 11:28 | xeqi | I thought gcc wanted copyright assignement too http://gcc.gnu.org/contribute.html |
| 11:28 | xeqi | *the fsf |
| 11:29 | wmealing_ | i commited, never had any kind of CA.. |
| 11:29 | wmealing_ | maybe someone fudged it. |
| 11:29 | wmealing_ | ah.. employee disclaimer |
| 11:29 | wmealing_ | employer rather |
| 11:29 | wmealing_ | thats why |
| 11:30 | wmealing_ | and perhaps "Small changes can be accepted without a copyright disclaimer or a copyright assignment on file" |
| 11:30 | seancorfield | CAs weren't as common back in the day, before the US became so darned litigation-happy :( |
| 11:31 | seancorfield | having been thru a corporate audit of open source software licenses (at adobe), i know how paranoid many large companies can be |
| 11:32 | pyykkis | Even though I understand the reasoning, CA and Jira are the worst of clojure world, i must say :/ |
| 11:33 | wmealing_ | we tolerate evil and pay the consequences of doing so. |
| 11:33 | wmealing_ | instead of solving the problem and revolting on it, we turn a blind eye to the larger cancer. |
| 11:34 | seancorfield | larger cancer = corporate litigation, i assume? (and i agree, fwiw) |
| 11:34 | wmealing_ | yes. |
| 11:35 | wmealing_ | i'm not smart enough to solve it, but i know the collective we.. is. |
| 11:35 | pyykkis | as I'm playing around with node.js and ruby quite a bit, MIT licences and dead simple pull request policies seems to be quite a factor for building a community |
| 11:35 | bosie | pyykkis: CA? |
| 11:35 | seancorfield | pyykkis: yes, CA / JIRA are the worst of the Clojure world, and if that's the worst, then we're in pretty good shape :) |
| 11:36 | seancorfield | node.js has a CA: http://nodejs.org/cla.html |
| 11:36 | bosie | ok |
| 11:37 | pyykkis | seancorfield: oh, lol :D I didn't even be aware of that |
| 11:38 | pyykkis | seancorfield: and yeah, that's true. If that's the worst, everything is quite ok :] Most of the people contribute to the specific projects anyways and not to the language core itself. And most of the projects are anyways with open licences in github |
| 11:39 | seancorfield | ruby is GPL yes? not surprised that a GPL project doesn't require a CA... bunch of tree-hugging hippies :) |
| 11:40 | seancorfield | a lot of large corporates won't use GPL unless they can buy a closed source commercial edition (which ruby / rails offers i believe?) |
| 11:41 | seancorfield | when i was at adobe, we had to ask a project to change from LGPL to some other license due to a legal concern with the reach of LGPL and how the project generated code that code intermingle with our own... (some) companies take this very seriously, for good or bad |
| 11:41 | bosie | seancorfield: are you using clojure exlusively these days at work? |
| 11:42 | seancorfield | bosie: for the back end, almost exclusively yes |
| 11:42 | wmealing_ | one has to take it seriously |
| 11:42 | wmealing_ | its what licences are |
| 11:42 | seancorfield | for the front end, railo - a jboss community project - that provides a fast, free implementation of cfml |
| 11:43 | seancorfield | bosie: my blog talks about the cfml / clojure integration we do - http://corfield.org |
| 11:44 | seancorfield | i think we got distracted wmealing_ |
| 11:45 | seancorfield | i haven't used that part of hiccup so i can't answer, i'm afraid |
| 11:46 | wmealing_ | maybe enlive might be more useful |
| 11:46 | seancorfield | is the q that you want to add a new option after the select has been generated? |
| 11:47 | technomancy | ruby has a custom license |
| 11:47 | technomancy | they don't need a CA to make contributing a huge PITA; the language barrier is enough |
| 11:47 | wmealing_ | nah, i can't generate the additional key=value sub options of the drop-down box |
| 11:48 | wmealing_ | i'd like <select> <option name="test">testing 123</a> |
| 11:48 | wmealing_ | oops, bad closing tag.. sorry its late here |
| 11:49 | wmealing_ | the name=test part, i can't seem to do easily. |
| 11:49 | jkkramer | wmealing_: I think you can pass a vector for each option… [["testing 123" "test"] ["foobar" "foo"], ...] |
| 11:50 | pandeiro | wmealing_: jkkramer: [:select (for [opt options] [:option {:name (:name opt)} (:title opt)])] |
| 11:51 | jkkramer | pandeiro: that gets tedious if you have to check for the selected value |
| 11:52 | jkkramer | on the other hand, writing your own helper function is pretty easy if drop-down isn't cutting it |
| 11:53 | samrat | mattrepl: just bumping up clj-http's version seems to solve my problem for the time being, but I'm not really sure I know what I'm doing |
| 11:53 | jkkramer | technomancy: FYI, I ran the clojuresphere fetcher last night and it took way longer than it used to - apparently there's way, way more projects now. I screwed up my jvm before it finished, though, so fetching again... |
| 11:53 | wmealing_ | both work.. thanks.. |
| 11:53 | ssideris | is anyone else getting ^M at the end of lines in the swank repl in emacs in windows? |
| 11:54 | seancorfield | (drop-down :foo [[:test "testing 123"]]) works wmealing_ |
| 11:54 | seancorfield | i had to update my version of hiccup to test that... didn't realize i was on such an old version :( |
| 11:55 | jkkramer | seancorfield: saw your work on jsql. I have a project that may interest you… https://github.com/jkk/honeysql |
| 11:56 | jkkramer | seancorfield: I'm using that as the basis for a higher-level lib that handles relational abstractions. but honeysql does purely clojure data -> sql, no abstraction or jdbc stuff |
| 12:02 | seancorfield | jkkramer: nice... looks like it would combine well with java.jdbc for more complex sql expressions |
| 12:07 | jkkramer | seancorfield: yeah. and it really comes in handy when progressively composing/adjusting queries |
| 12:10 | seancorfield | jkkramer: yeah, the jsql stuff is just meant to provide some basics that make java.jdbc easier to use - and will be folded into java.jdbc soon - but because the DB operations just take SQL, it would be easy to use any other sql-generator library with it |
| 12:15 | jkkramer | seancorfield: cool, that's what I've been doing, and am pretty happy with. If there's anything in honeysql you'd like to pilfer for jsql, feel free - it's a solo project, and I've signed a CA. if not, no biggie, just thought i'd bring it to your attention |
| 12:15 | zilti | There seems to be something wrong in the way I'm using the ns macro: https://gist.github.com/3578863 The Stacktrace is from loading the file in the slime-repl. |
| 12:18 | nbeloglazov | zilti: do you need :use or :require? |
| 12:18 | zilti | nbeloglazov: What's the alternative? |
| 12:19 | zilti | writing the full path? |
| 12:20 | nbeloglazov | zilti: check this article: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html |
| 12:21 | nbeloglazov | zilti: it seems that you really need :require because you specified aliases via :as for namespaces |
| 12:21 | zilti | nbeloglazov: Which gives me a "next already refers to: #'clojure.zip/next in namespace: orgparser.core" error |
| 12:27 | zilti | Hmm ok a restart fixes this |
| 12:27 | pandeiro | there's no autocomplete functionality in source code buffers with nrepl.el + ac-nrepl.el ? |
| 12:27 | pandeiro | only in the nREPL buffer? |
| 12:29 | pandeiro | i enabled auto-complete-mode but it doesn't complete fns from clojure.core |
| 12:33 | Frozenlo` | "Phil Hagelberg has some thought-provoking advice on this matter." What's this usage of real name? Tssss... |
| 13:53 | RonnieDk | A bit of regex trouble. How come (re-find #"yfs_184" "yfs_l84") return nil? |
| 13:55 | nbeloglazov | &(re-find #"yfs_184" "yfs_184") |
| 13:55 | lazybot | ⇒ "yfs_184" |
| 13:55 | RonnieDk | not in my nrepl |
| 13:55 | nbeloglazov | RonnieDk: your strings have differences |
| 13:56 | nbeloglazov | RonnieDk: 1 in the pattern and l in the string |
| 13:57 | RonnieDk | nbeloglazov: but how there be a difference? It's two simple strings |
| 13:57 | nbeloglazov | &(= "yfs_184" "yfs_l184") |
| 13:57 | lazybot | ⇒ false |
| 13:57 | nbeloglazov | &(= "yfs_184" "yfs_l84") |
| 13:57 | lazybot | ⇒ false |
| 14:01 | samflores | which is that character after the underline in the second string? |
| 14:02 | RonnieDk | samflores: Damn ... you're right. |
| 14:02 | samflores | :p |
| 14:02 | nbeloglazov | :( |
| 14:05 | Frozenlock | In Domina, is there a way to change the 'hover' css? For normal css: (domina/set-styles! {:position "fixed".... but what if I want to change what would usually be in 'div-id:hover'? |
| 14:48 | borkdude | has anyone used https://github.com/adamwynne/twitter-api/? I'm trying (profile-image-for-user :params {:screen_name "Borkdude"}) but... |
| 14:48 | borkdude | I get this nasty msg: JSON error (unexpected character): < |
| 14:48 | borkdude | [Thrown class java.lang.Exception] |
| 14:53 | borkdude | maybe it expects the body to be encoded? |
| 14:53 | samrat | what does this error mean https://www.refheap.com/paste/4793 ? |
| 14:54 | gfredericks | samrat: what's your ns form look like? |
| 14:55 | zilti | I'm trying to get zippers working, but that doesn't work: https://gist.github.com/3583132, why? |
| 14:57 | samrat | gfredericks: https://www.refheap.com/paste/4794 |
| 14:59 | gfredericks | samrat: the quote on line 2 could be messing it up |
| 15:00 | gfredericks | yeah that seems to be the case |
| 15:00 | samrat | gfredericks: thanks |
| 15:00 | michaelr` | hello |
| 15:05 | borkdude | how can you reset an alias in a namespace? |
| 15:07 | borkdude | found i |
| 15:07 | borkdude | t |
| 15:08 | zilti | All I get is a NullPointerException without a message, so I have no idea what's wrong |
| 15:28 | borkdude | is there a "switch repl to namespace visited in this file" in emacs (swank-clojure) like "Switch REPL to files namespace" in Counterclockwise? |
| 15:29 | zilti | borkdude: C-x M-p |
| 15:30 | borkdude | zilti undefined |
| 15:32 | borkdude | zilti C-c M-p, tnx |
| 15:32 | zilti | borkdude: Oh, yes. Sorry |
| 15:44 | pandeiro | inside of a typical nested src directory structure, what is the default filepath? |
| 15:44 | pandeiro | in the past i thought doing (read-file "project.clj") worked from anywhere inside the src/... structure |
| 15:53 | SegFaultAX | Is there a range-like that can produce an infinite sequence starting from a number other than 0? |
| 15:54 | zilti | I'm trying to get zippers working, but that doesn't work: https://gist.github.com/3583132, why? All I get is a NullPointerException without a message, so I have no idea what's wrong |
| 15:54 | SegFaultAX | ,((fn range-from [n] (cons n (lazy-seq (range-from (inc n))))) 10) |
| 15:54 | clojurebot | (10 11 12 13 14 ...) |
| 15:54 | SegFaultAX | ,(take 10 ((fn range-from [n] (cons n (lazy-seq (range-from (inc n))))) 10)) |
| 15:54 | clojurebot | (10 11 12 13 14 ...) |
| 15:55 | xeqi | #(doc range) |
| 15:56 | xeqi | (doc range) |
| 15:56 | clojurebot | "([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity." |
| 15:56 | xeqi | hmm, I guess it only takes an end |
| 15:56 | arrdem | ,(inc xeqi) |
| 15:56 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: xeqi in this context, compiling:(NO_SOURCE_PATH:0)> |
| 15:56 | arrdem | (inc xeqi) |
| 15:56 | lazybot | ⇒ 3 |
| 15:56 | SegFaultAX | But I don't want to give an end, just a start. |
| 15:56 | xeqi | ,(map #(+ 10 %) (range)) |
| 15:56 | clojurebot | (10 11 12 13 14 ...) |
| 15:56 | SegFaultAX | And obviously ##(range 3) aint it. |
| 15:56 | lazybot | ⇒ (0 1 2) |
| 15:57 | alpheus | I have a function that locates a file and returns a java.io.FileInputStream for the file. I want to test the contents of the FileInputStream against my expected value (possibly arbitrary binary data). How can I do this? |
| 15:57 | SegFaultAX | xeqi: So the answer is no, then? Such a thing doesn't already exist? |
| 15:58 | xeqi | SegFaultAX: nothing built in that I'm aware of |
| 15:58 | SegFaultAX | xeqi: Cool, thanks mate. |
| 15:59 | xeqi | SegFaultAX: ##(iterate inc 10) |
| 15:59 | lazybot | Execution Timed Out! |
| 15:59 | xeqi | ,(iterate inc 10) |
| 15:59 | clojurebot | (10 11 12 13 14 ...) |
| 15:59 | xeqi | forgot about iterate for a moment |
| 16:00 | xeqi | alpheus: I assume `slurp`-ing the inputstream won't work? |
| 16:01 | alpheus | xeqi: no, slurp corrupts binary data. spit, too. |
| 16:01 | arrdem | (doc slurp) |
| 16:01 | clojurebot | "([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments." |
| 16:02 | alpheus | I've been using clojure.java.io/copy to copy to a file and then using Unix cmp (for my tests) |
| 16:02 | arrdem | yeah that'll break binary data... |
| 16:02 | alpheus | Also, I can't figure out what "opts" is for slurp. |
| 16:03 | arrdem | alpheus: if you go on clojuredocs or clojure.org and look at the source the opts are passed to the java.io.reader creation call |
| 16:04 | xeqi | perhaps something like (let [x (bytearray (.available inputstream))] (.read inputstream x) (is (= (seq x) expected))) ? |
| 16:05 | xeqi | * byte-array |
| 16:10 | alpheus | xeqi: thanks |
| 16:14 | Frozenlock | Is it possible to have multiple browser windows in the same 'environment' |
| 16:15 | Frozenlock | For example, if I declare a variable from the REPL, I would like all of them to have it. |
| 16:16 | goodieboy | i'd like to build a ring application, and provide a way for people to add plugins for certain features. Any ideas for dealing with "plugins" within clojure and ring? |
| 16:17 | dnolen | Frozenlock: I think Brenton Ashworth was working on that, but I don't know if there's been much progress recently. |
| 16:17 | weavejester | You'd need to decide what the plugin would do - whether it's just a page, or if it has any interactions with your APIs. |
| 16:18 | goodieboy | weavejester: yeah, i think i know what would be needed in terms of an interface, but just don't know how you'd plugin, the plugins :) |
| 16:18 | pandeiro | weavejester: could you show me how i would rig a compojure route to modify a ring session map? |
| 16:19 | Frozenlock | dnolen: I don't see anything on his github. I suppose it's really still an experiment. |
| 16:20 | weavejester | goodieboy: They could upload a jar that you could dynamically load in. Isn't there a library around for dynamic classpath managing? I think Lein2 uses it? |
| 16:20 | goodieboy | weavejester: oh is that the bultitude thing? |
| 16:20 | goodieboy | https://github.com/Raynes/bultitude/ ? |
| 16:20 | weavejester | pandeiro: (-> (response "whatever") (assoc-in [:session :your-key] "some-value")) |
| 16:20 | xeqi | https://github.com/cemerick/pomegranate |
| 16:20 | goodieboy | weavejester: wait, you can dynamically load a jar? |
| 16:20 | dnolen | Frozenlock: it's a ClojureScript branch on the main repo |
| 16:21 | xeqi | goodieboy ^ |
| 16:21 | weavejester | goodieboy: Yeah, you can create a new classloader with a new classpath to execute your jar in |
| 16:21 | goodieboy | xeqi: ahh ok, i've heard of that. i'll have a look thanks! |
| 16:22 | goodieboy | weavejester: i didn't know you could do that, nice |
| 16:22 | weavejester | goodieboy: It's kinda tricky to do it with Java, though. I believe it's pomegranate that is a library for loading deps on the fly.... |
| 16:23 | goodieboy | it does sound tricky |
| 16:23 | xeqi | https://github.com/cemerick/pomegranate/blob/master/src/main/clojure/cemerick/pomegranate.clj#L72 for random jars; there's an equivalent for getting hten from mavne repos as well |
| 16:23 | pandeiro | is there a way to reload all buffers with nrepl.el? |
| 16:24 | goodieboy | xeqi: very cool |
| 16:26 | weavejester | goodieboy: Actually, you probably want this: https://github.com/flatland/classlojure |
| 16:27 | weavejester | Get someone to upload an uberjar of the plugin (i.e. a jar with all deps included) |
| 16:27 | xeqi | (inc weavejester) |
| 16:27 | lazybot | ⇒ 4 |
| 16:27 | weavejester | Then use classojure to call API methods |
| 16:27 | xeqi | that would be a better way |
| 16:28 | xeqi | then you don't have to worry about dependencies on different versions of the same library |
| 16:29 | goodieboy | nice, i'll have a play with that as well |
| 16:29 | weavejester | Although... |
| 16:29 | weavejester | If you have a web app |
| 16:30 | weavejester | Then plugins are usually done through a web API |
| 16:30 | weavejester | i.e. plugin developer hosts a web app |
| 16:30 | weavejester | registers it with your system |
| 16:30 | weavejester | and then your system calls specific URIs on the plugin app |
| 16:32 | goodieboy | hmm, would need to think about that. it is a webapp, but my plan was to open source the app, and make it easy/safe for developers to create their own plugins, but upgrading the core would be painless, and not mess with customizations done via plugins |
| 16:32 | weavejester | If it's an open source app then I guess jars might work best |
| 16:33 | goodieboy | basically, a way to hook into the app without modifying the source |
| 16:41 | pandeiro | muhoo: are you using couch-session still? |
| 16:49 | bloudermilk | Are records less efficient than maps with regard to persistence/structural sharing? |
| 17:00 | Frozenlock | I suspect lein to be using another version than the one I asked for in my project.clj. How can I check which one is used? |
| 17:02 | weavejester | Frozenlock: lein deps :tree should show you everything |
| 17:03 | goodieboy | weavejester: hey i'm thinking about using dynamodb for a project and ran across rotary. Does it support the async client? |
| 17:03 | Frozenlock | weavejester: Thank you. |
| 17:04 | Frozenlock | I'm starting to think it's a soft/hard dependency issue https://github.com/technomancy/leiningen/blob/master/doc/FAQ.md |
| 17:04 | weavejester | goodieboy: No, but the library is in an early state. |
| 17:04 | goodieboy | weavejester: ok just checking. Love the name btw. |
| 17:04 | weavejester | goodieboy: Thanks |
| 17:05 | weavejester | goodieboy: Also, is there a point to use the async client in Clojure? |
| 17:05 | dnolen | getting warmer https://github.com/clojure/clojurescript/commit/48bb400838a7e45daa776a8afb817910c54d3a8c |
| 17:06 | goodieboy | weavejester: you mean, because we have agents etc.? |
| 17:06 | Frozenlock | dnolen: May I ask to what? :) |
| 17:06 | weavejester | goodieboy: The async client returns futures… I guess it's not using them with threads, but with nio or something |
| 17:07 | goodieboy | weavejester: yeah that's what i thought too |
| 17:08 | weavejester | goodieboy: It might be worth in a future version to switch to the async client if it's using nio |
| 17:08 | weavejester | goodieboy: Have it return something deref-able. |
| 17:08 | goodieboy | weavejester: yeah exactly |
| 17:08 | goodieboy | i'm looking for the docs now |
| 17:10 | emezeske | Frozenlock: I think cljs is getting closer to having source map support, so you can debug it in a browser much more easily |
| 17:18 | Frozenlock | I need to look at this REPL thingy more closely. I could not live without it, yet I have no clue to what's happening under the hood :( |
| 17:21 | casion | is there any short way to convert a java byte-array to a seq (other recursion + conj) |
| 17:21 | casion | other than* |
| 17:22 | aperiodic | you can just call seq on it |
| 17:22 | aperiodic | ,(seq (byte-array 1 (byte 42))) |
| 17:22 | clojurebot | (42) |
| 17:24 | samflores | '(doc seq) |
| 17:24 | samflores | ,(doc seq) |
| 17:24 | clojurebot | "([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable." |
| 17:24 | casion | thanks aperiodic |
| 17:31 | xeqi | Frozenlock: if you suspect a hard vs soft deps problem, you might try https://github.com/xeqi/lein-pedantic and see what it tells you |
| 17:33 | Frozenlock | xeqi: looks really neat! Thanks! |
| 17:49 | aperiodic | emezeske: so, i symlinked a cljs file as .clj in my source directory (in order to please pygments), and lein-cljsbuild choked so badly when trying to compile the symlink that i had to kill it and rerun cljsbuild auto |
| 17:49 | aperiodic | emezeske: should i open an issue, or just refrain from doing such uncouth things? |
| 17:50 | emezeske | aperiodic: What is pygments? |
| 17:51 | emezeske | aperiodic: And was the link "x.cljs -> x.clj" or "x.clj -> x.cljs" ? |
| 17:51 | aperiodic | emezeske: pygments is a syntax highlighting tool, and the link was x.clj -> x.cljs |
| 17:53 | emezeske | Well, cljsbuild is just going to interpret that as a clojure file that has the exact same contents of a clojurescript file. I guess it doesn't seem weird to me that that would cause problems |
| 17:54 | emezeske | Although without :require-macros I don't know why it would even look at that file |
| 17:54 | emezeske | Refheap of the choking stack trace? |
| 17:54 | emezeske | Maybe it broke when trying to get the mtime of a symlink |
| 17:58 | aperiodic | emezeske: sure, it just seems suboptimal to me that doing this crashes cljsbuild auto. it looks like it crashed when trying to call use-macros, actually: https://www.refheap.com/paste/4796 |
| 17:59 | aperiodic | i'd expect the build to just fail |
| 17:59 | emezeske | Well, that's the compiler crashing, which cljsbuild doesn't try to catch |
| 17:59 | emezeske | cljsbuild just catches builds that fail |
| 18:01 | aperiodic | are you opposed to catching compiler crashes? |
| 18:02 | emezeske | I guess I just don't see it being very important. In your case, even if cljsbuild did catch that error, it's not like the build is going to work |
| 18:03 | aperiodic | then only reason to do it would be to save the user having to notice the crash and then manually kill & restart cljsbuild auto (it doesn't actually kill cljsbuild auto, just makes it stop building) |
| 18:03 | emezeske | Actually, that's not even the compiler crashing |
| 18:03 | emezeske | That's the clojure compiler crashing |
| 18:04 | emezeske | You do make a fine point |
| 18:05 | emezeske | Open an issue and link that stack trace, I think it would be easy to just wrap the clojure reloader in a try |
| 18:05 | aperiodic | sounds good! |
| 18:06 | emezeske | Now that I think about it, that really should be caught. I'll stop being stubborn now. :) |
| 18:12 | aperiodic | issue opened |
| 18:12 | aperiodic | thanks for being convinced :) |
| 18:12 | emezeske | Good job convincing me! |
| 18:12 | emezeske | :) |
| 18:24 | n00b6502 | i like the way clojure makes maps,vectors callable functions to lookup their contents.. is this unique to clojure?? |
| 18:24 | lazybot | n00b6502: Definitely not. |
| 18:24 | n00b6502 | is that automated |
| 18:25 | emezeske | n00b6502: Definitely not. |
| 18:26 | emezeske | Haha, lazybot is such a jerk :) |
| 18:26 | emezeske | I don't know the answer to your question. |
| 18:27 | SegFaultAX | What's the easiest way to insert something into the middle of a list? |
| 18:28 | SegFaultAX | Like if I want to insert :foo into [:a :b] to yield [:a :foo :b] |
| 18:28 | SegFaultAX | ,(assoc [:a :b] 1 :foo) |
| 18:28 | clojurebot | [:a :foo] |
| 18:28 | emezeske | SegFaultAX: You can (concat [first part of list] [element] [last part of list]) |
| 18:29 | SegFaultAX | That's the easiest way? |
| 18:29 | emezeske | ,(let [x [1 2 4 5]] (concat (take 2 x) [3] (drop 2 x))) |
| 18:29 | clojurebot | (1 2 3 4 5) |
| 18:30 | emezeske | I make no claims about it being the easiest way. |
| 18:30 | hughfdjackson | this is a .. language design question more than anything |
| 18:30 | hughfdjackson | it strikes me as risky that dividing by 0 throws an exception |
| 18:30 | hughfdjackson | since you may derive the from user input, and therefore have to always put extra gaurds in place |
| 18:31 | hughfdjackson | :p A) do people concur, B) why does clojure make the exception choice? |
| 18:31 | emezeske | hughfdjackson: Definitely do not concur. |
| 18:31 | emezeske | hughfdjackson: It would be risky *not* to throw an exception when dividing by zero |
| 18:32 | emezeske | hughfdjackson: Much better to find out about a problem in the input than to silently produce corrupt results |
| 18:32 | xeqi | a) no. b) host environment made the choice |
| 18:32 | hughfdjackson | :D fair enough |
| 18:33 | emezeske | hughfdjackson: If your program takes user input, you have to validate it, plain and simple |
| 18:33 | arrdem | emezeske beat me to it |
| 18:33 | emezeske | :P |
| 18:33 | hughfdjackson | i could be wrong in imagining that it could be more handily solved by an 'infinity' value for which *, +, -, / all return the value supplied |
| 18:34 | hughfdjackson | :D but if it doesn't strike others as strange, maybe i'm the strange one on this |
| 18:34 | emezeske | x/0 != infinity |
| 18:34 | clojurebot | is too infinity +1! |
| 18:34 | emezeske | x/0 = NaN if anything |
| 18:34 | arrdem | yeah... |
| 18:34 | emezeske | Anything divided by zero is not defined, it is definitely not infinity. |
| 18:34 | gfredericks | &(/ 7.3 0) |
| 18:34 | lazybot | ⇒ Infinity |
| 18:34 | emezeske | gfredericks: Why!!! |
| 18:34 | arrdem | emezeske: because floating point |
| 18:35 | emezeske | &(/ 7.3 0.0) |
| 18:35 | lazybot | ⇒ Infinity |
| 18:35 | arrdem | &(/ 7 0) |
| 18:35 | lazybot | java.lang.ArithmeticException: Divide by zero |
| 18:35 | arrdem | see? it's just a Floating Point POS |
| 18:35 | gfredericks | rationals ftw |
| 18:35 | emezeske | ,(/ 7.3F 0.0F) |
| 18:35 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NumberFormatException: Invalid number: 7.3F> |
| 18:35 | hughfdjackson | :p well, that underminds some of my basic assumptions |
| 18:35 | emezeske | gfredericks: But.. but! |
| 18:36 | arrdem | hughfdjackson: Okay. floating point... has all kinds of weirdness in the spec where floating point was involved. I spent an un-fun week last semester learning that crap. |
| 18:36 | gfredericks | emezeske: no exceptions |
| 18:36 | emezeske | gfredericks: Rationals, you say. I'm sure there's a reason for it, but that answer is plain wrong |
| 18:36 | gfredericks | emezeske: cuz of perf? |
| 18:36 | emezeske | gfredericks: That's usually the answer |
| 18:37 | hughfdjackson | hehe, turns out haskell returns infinity for 1/0 |
| 18:37 | hughfdjackson | there's a turn up for the books |
| 18:37 | gfredericks | well you're the one who said i was wrong |
| 18:37 | emezeske | gfredericks: No, I didn't mean *you* were wrong |
| 18:37 | WuHoUnited | Does anybody know how RT.loadResourceScript behave if it is called from different threads in the same application? |
| 18:37 | emezeske | gfredericks: I meant that the answer returned by / was wrong |
| 18:37 | gfredericks | ooh |
| 18:37 | emezeske | lol :) |
| 18:38 | gfredericks | emezeske: I was recommending using rationals instead of floating point |
| 18:38 | WuHoUnited | ie: is it as if each of the threads loaded the script independently? |
| 18:38 | emezeske | gfredericks: Ooooh, gotcha! |
| 18:40 | tomoj | I can't seem to find any reasons for the ieee float spec to include infinity |
| 18:40 | amalloy | emezeske: (/ 1.0 0.0) as infinity makes some sense because floating point is just an approximation: ie, you probably got zero by a rounding error, and not an actual exact zero, so it's really more like an infinitesimal |
| 18:40 | emezeske | tomoj: Infinity is handy for certain algorithms |
| 18:41 | gfredericks | (inc amalloy) |
| 18:41 | lazybot | ⇒ 29 |
| 18:41 | emezeske | tomoj: Like implementing max(), you can set the current max to negative infinity and then compare successive values to that |
| 18:41 | arrdem | (inc amallot) |
| 18:41 | lazybot | ⇒ 1 |
| 18:41 | arrdem | (inc amalloy) |
| 18:41 | lazybot | ⇒ 30 |
| 18:41 | arrdem | (dec amallot) ; NO FREE KARMA HERE |
| 18:41 | lazybot | ⇒ 0 |
| 18:42 | gfredericks | amallot: yeah, earn it the hard way like the rest of us |
| 18:42 | emezeske | amalloy: That's reasonable I guess. It's not like when one is using floats that one can even believe in a zero value anyway |
| 18:42 | arrdem | amallot: damnit man... |
| 18:42 | emezeske | amallot: Or, rather believe in any exact value |
| 18:42 | amallot | i hereby claim all future karma proceeds on this account |
| 18:42 | gfredericks | emezeske: I believe in zero no matter what those biased biologists say |
| 18:42 | emezeske | gfredericks: lol |
| 18:42 | arrdem | (inc amallot) ; for making my day |
| 18:42 | lazybot | ⇒ 1 |
| 18:43 | gfredericks | (inc amallot-of-fun) |
| 18:43 | lazybot | ⇒ 1 |
| 18:43 | emezeske | (inc amallard) |
| 18:43 | lazybot | ⇒ 1 |
| 18:43 | amalloy | what have i done! |
| 18:43 | arrdem | gfredericks: what you did there... I see it. |
| 18:43 | emezeske | You've unleashed the floodgates of useless karma |
| 18:44 | gfredericks | I was about to say something about not knowing how the name "amalloy" is really pronounced before remembering it wasn't a name |
| 18:55 | yankov | is there a built-in function to take a sublist from the list. say I need only elements from 10 to 17. |
| 18:55 | yankov | like ruby's array[10..17] |
| 18:55 | WuHoUnited | subvec would work for vectors |
| 18:55 | WuHoUnited | might work for seqs also |
| 18:55 | gfredericks | it oughtn't |
| 18:55 | arrdem | ,(drop 10 (take 17 (range 100)) |
| 18:55 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 18:55 | Raynes | &(take 7 (drop 10 (range 20)) |
| 18:55 | lazybot | java.lang.RuntimeException: EOF while reading, starting at line 1 |
| 18:55 | Raynes | &(take 7 (drop 10 (range 20))) |
| 18:55 | lazybot | ⇒ (10 11 12 13 14 15 16) |
| 18:55 | arrdem | ,(drop 10 (take 17 (range 100))) |
| 18:55 | clojurebot | (10 11 12 13 14 ...) |
| 18:56 | Raynes | take 17? |
| 18:56 | Raynes | :p |
| 18:56 | arrdem | Raynes: I derped |
| 18:56 | arrdem | IT GETS THE SAME PLACE |
| 18:56 | Raynes | So did I. |
| 18:56 | Raynes | Anyways, he sees the point, I'm sure. |
| 18:56 | Raynes | <3 |
| 18:58 | yankov | thanks guys |
| 18:58 | arrdem | no problem |
| 19:00 | arrdem | ,(println "foo") |
| 19:00 | clojurebot | foo |
| 19:00 | arrdem | ,(println "/nick silly-bot") |
| 19:00 | clojurebot | /nick silly-bot |
| 19:00 | arrdem | dang. |
| 19:01 | gfredericks | that bot is so clever |
| 19:02 | ohok | thanks bot. thot. |
| 19:03 | gfredericks | (inc ohok) |
| 19:03 | lazybot | ⇒ 1 |
| 19:04 | antifuchs | ,(println (format "%cACTION%c slaps around antifuchs with a large trout" (char 1) (char 1)) |
| 19:04 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading> |
| 19:04 | antifuchs | awww |
| 19:05 | arrdem | you dropped an rparen |
| 19:05 | antifuchs | (forgive me, but I have to try again) |
| 19:05 | antifuchs | ,(println (format "%cACTION%c slaps around antifuchs with a large trout" (char 1) (char 1))) |
| 19:05 | antifuchs | this wasn't very effective ): |
| 19:06 | antifuchs | must have forgotten my CTCP syntax. oh well (: |
| 19:11 | metellus | ,(println (str (char 1) "ACTION" (char 1) "attempts an action")) |
| 19:17 | tomoj | &(#(vector %1.999999999999999 %1.9999999999999999) 3 4) |
| 19:17 | lazybot | ⇒ [3 4] |
| 19:18 | nbeloglazov | tomoj: how does it work? |
| 19:19 | tomoj | &(= 1.9999999999999999 2.0) |
| 19:19 | lazybot | ⇒ true |
| 19:19 | nbeloglazov | &(1.999999999999999 1.0) |
| 19:19 | lazybot | java.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn |
| 19:20 | amalloy | more like ##(read-string "1.999999999999999"), i think |
| 19:20 | lazybot | ⇒ 1.999999999999999 |
| 19:20 | amalloy | hm. guessed that would return 2.0 |
| 19:20 | tomoj | &(read-string "1.9999999999999999") |
| 19:20 | lazybot | ⇒ 2.0 |
| 19:20 | tomoj | I see |
| 19:20 | tomoj | the weird thing is really that %args can be floats |
| 19:22 | tomoj | a vec's rseq isn't chunked :( |
| 19:23 | amalloy | tomoj: it's parsed with read, then cast to Number, then intValue is called |
| 19:37 | yankov | is this a stupid way to _append_ to a list? (flatten (list '(1 2 3 4) 5)) |
| 19:38 | arrdem | yankov: ... yes. you should (conj) if that's what you want |
| 19:38 | xeqi | &(conj '(1 2 3 4) 5) |
| 19:38 | lazybot | ⇒ (5 1 2 3 4) |
| 19:38 | arrdem | herum |
| 19:38 | arrdem | (doc append) |
| 19:38 | amalloy | &(doc concat) |
| 19:38 | lazybot | ⇒ "([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls." |
| 19:38 | clojurebot | No entiendo |
| 19:38 | yankov | yes, but that will prepend |
| 19:38 | xeqi | &(concat '(1 2 3 4) '(5)) |
| 19:39 | lazybot | ⇒ (1 2 3 4 5) |
| 19:39 | yankov | og |
| 19:39 | yankov | nice |
| 19:39 | amalloy | but, in general, don't append to lists |
| 19:39 | yankov | better use vectors for that? |
| 19:39 | xeqi | (conj [1 2 3 4] 5) |
| 19:39 | xeqi | &(conj [1 2 3 4] 5) |
| 19:39 | lazybot | ⇒ [1 2 3 4 5] |
| 19:39 | Frozenlo` | How does one can check if a dom element exists? When I check the value of a variable bound to a DIV that I've just erased, I get: #<[object HTMLDivElement]>. I was expecting nil :( |
| 19:40 | arrdem | xeqi: thanks I knew I wasn't totally off-base |
| 19:40 | hughfdjackson | Frozenlo`: re-query the DOM |
| 19:40 | hughfdjackson | whoops |
| 19:40 | hughfdjackson | thought we were in ##javascript |
| 19:41 | arrdem | hughfdjackson: (eq? #javascript ##javacript) |
| 19:46 | Frozenlo` | Is there a cljs equivalent to re-querying the DOM? |
| 19:48 | xeqi | wonder if goog.dom/getParentElement could work |
| 19:55 | Frozenlock | Trying now... getting a bunch of errors |
| 19:55 | Frozenlock | Must be a requiring issue. |
| 20:16 | Frozenlock | (goog.dom/getElement my-var) returns the same #<[object HTMLDivElement]> as before :( |
| 20:17 | Frozenlock | And goog.dom/getParentElement is not a valid method for the object. |
| 20:17 | xeqi | yeah, the api says it returns the dom node if passed one |
| 20:17 | Frozenlock | o_O |
| 20:18 | xeqi | try (.parent dom-node) ? |
| 20:18 | xeqi | oh (.-parent dom-node) |
| 20:18 | xeqi | blah |
| 20:18 | xeqi | (.-parentNode dom-node) |
| 20:19 | Frozenlock | Oh wait I don't get an error on this one |
| 20:19 | Frozenlock | It works! |
| 20:20 | xeqi | &"hurray!" |
| 20:20 | lazybot | ⇒ "hurray!" |
| 20:20 | Frozenlock | I owe you a drink :) |
| 20:26 | Frozenlock | I wonder if this should be in domina. |
| 20:33 | mpan | Is there an equivalent to use/require for static Java methods? |
| 20:34 | mpan | e.g. I want to write parseInt and have it be Integer/parseInt |
| 20:34 | mpan | or am I just supposed to (def parseInt Integer/parseInt) |
| 20:35 | mpan | (whoops, just tried that and it doesn't work like I think) |
| 20:36 | gfredericks | &(doc memfn) |
| 20:36 | lazybot | ⇒ "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." |
| 20:36 | gfredericks | oh wait static |
| 20:37 | gfredericks | no I don't think there's any sugar for static methods |
| 20:37 | mpan | currently I've got... (def parseInt #(Integer/parseInt %)) |
| 20:37 | mpan | it feels a bit strange to be honest |
| 20:37 | mpan | all right, thanks |
| 20:37 | gfredericks | I think most people just keep the Integer/parseInt inline |
| 20:40 | arrdem | brb nesting in tmux |
| 20:42 | mpan | &"test" |
| 20:42 | lazybot | ⇒ "test" |
| 20:42 | mpan | yay |
| 20:42 | mpan | &(println "test") |
| 20:42 | lazybot | ⇒ test nil |
| 21:24 | zilti | With Clojure.zip what's the best way to move directly to a newly appended child? |
| 21:27 | tomoj | (comp rightmost down)? |
| 21:28 | tomoj | well (comp rightmost down #(append-child % foo)) |
| 21:29 | zilti | hmm okay |
| 21:30 | tomoj | the only other way I can think of is (comp right #(insert-right % foo) rightmost down) |
| 21:30 | zilti | I thought there's maybe a special function for that |
| 21:31 | zilti | But looking at the docs, it says the child is always added as the rightmost, so (-> zip (append-child child) down rightmost) is it |
| 21:32 | bbloom | i always forget clojure.zip exists. super cool little lib |
| 21:51 | tomoj | is it possible to have a persistent/transient pair of deftypes in the same file? |
| 21:51 | tomoj | where asTransient and persistent use the other constructors |
| 21:53 | tomoj | you can forward-declare a function that calls the latter constructor :/ |
| 21:58 | bbloom | tomoj: you mean with the same name? |
| 21:58 | tomoj | no, different names |
| 21:58 | S11001001 | n00b6502: the answer to your question is "definitely not" |
| 21:58 | bbloom | i don't understand. why wouldn't that be possible? |
| 21:58 | bbloom | you could use extend-protocol |
| 21:59 | tomoj | because the constructor for the latter deftype will not be defined yet when the former is evaluated |
| 21:59 | n00b6502 | defintely not - no other lisp allows a collection to be "called" for acess ? |
| 21:59 | bbloom | rather than the forward declaration |
| 21:59 | n00b6502 | i need to make my own lisp dialect with every feature i like cherrypicked hehe |
| 21:59 | tomoj | well, I{Transient,Editable}Collection aren't protocols on the jvm |
| 21:59 | S11001001 | n00b6502: I think you said language, but even among lisps the feature is not unique (Arc also does it) |
| 21:59 | tomoj | that would work on cljs though? |
| 21:59 | bbloom | ah yes, i forgot. *shrug* go with the forward declaration. that's what they are there for! |
| 22:00 | S11001001 | s,said,implied, |
| 22:00 | n00b6502 | oh sorry "not unique" not "not elseqhere"... i forgot how i worded it |
| 22:00 | tomoj | just sort of wish I could forward-declare a constructor |
| 22:00 | tomoj | though I have no good reason to want that |
| 22:00 | S11001001 | n00b6502: "is this unique to clojure??" |
| 22:00 | n00b6502 | ok not unique .. great. |
| 22:01 | n00b6502 | over on #lisp they think its dysfunctional |
| 22:01 | n00b6502 | misfeature |
| 22:01 | S11001001 | among JVM-intended languages, Scala also has sequences, sets, and maps as function subtypes |
| 22:02 | amalloy | tomoj: https://github.com/flatland/ordered/blob/develop/src/ordered/map.clj is basically the best you can do |
| 22:02 | bbloom | n00b6502: why do they think it is a misfeature? |
| 22:03 | n00b6502 | i mean pure and simple moving from C like languages, I can handle prefix maths just fine but its object-acessor where the prefix syntax begins to grate. (object member) instead of (slot-value object member) helps a lot :) |
| 22:03 | bbloom | n00b6502: learn to love the -> macro |
| 22:04 | n00b6502 | i got more responses of "thats a dumb idea" on #lisp for various reasons i couldn't be bothered to remember |
| 22:04 | S11001001 | n00b6502: keep at it and you'll switch to (member object) |
| 22:04 | n00b6502 | bbloom: my first question on #lisp was how to make a macro for passing a value along... i called it "pipe" .. they said "its a dumb idea". but i gather clojure actually has it ? |
| 22:04 | bbloom | ,(doc ->) |
| 22:04 | clojurebot | "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc." |
| 22:04 | bbloom | ,(doc ->>) |
| 22:04 | clojurebot | "([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc." |
| 22:05 | n00b6502 | yeah. i wrote that and called it "pipe". they told me "ner ner ner thats not idiomatic lisp ner ner ner" |
| 22:05 | bbloom | *shrug* it's idiomatic clojure. |
| 22:05 | mpan | the way most java libraries are set up, you'd want that for convenience for interop if nothing else? |
| 22:05 | n00b6502 | cool :) |
| 22:06 | bbloom | consider deeply nested associative structures: |
| 22:06 | bbloom | ,(-> {:x {:y {:z [1 2 3]}}} :x :y :z) |
| 22:06 | clojurebot | [1 2 3] |
| 22:06 | n00b6502 | saves th last line of your function being )))))))))))))))))))))))) |
| 22:06 | bbloom | super useful. |
| 22:06 | mpan | also feels nicer to read them in the order you think about them |
| 22:07 | gfredericks | interesting constrained form of clojure: every function must end in exactly 24 close-parens |
| 22:07 | gfredericks | I guess that's pretty trivial with a macro |
| 22:07 | mpan | you could cheat by defining a pass-through macro, and that would be the only real constrained writing? |
| 22:08 | gfredericks | jinx |
| 22:08 | mpan | =p |
| 22:08 | mpan | idk what to think of this, it just feels so different from other languages I've used |
| 22:08 | amalloy | bbloom: that's a terrible example of -> -- it's exactly what you should use get-in for |
| 22:08 | bbloom | that's a good thing! |
| 22:08 | bbloom | amalloy: d'oh, you're right. i just needed an example |
| 22:09 | mpan | OH! |
| 22:09 | n00b6502 | (defmacro pipe (&rest args) (reduce (lambda (a b) (append b (list a))) args)) |
| 22:09 | n00b6502 | |
| 22:09 | mpan | that's actually really useful for what I was going to do |
| 22:09 | casion | finally have a basic DSP setup working in clojure |
| 22:09 | mpan | get-in would save me a lot of the stuff I was going to type |
| 22:10 | casion | javax.sound.sampled is just retardedly complicated :| |
| 22:10 | bbloom | ,(-> [:a :b :c] second name string/upper-case) |
| 22:10 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: string, compiling:(NO_SOURCE_PATH:0)> |
| 22:11 | bbloom | ,(-> [:a :b :c] second name clojure.string/upper-case) |
| 22:11 | clojurebot | "B" |
| 22:11 | bbloom | amalloy: n00b6502: there you go |
| 22:11 | bbloom | a decent example of -> :-) |
| 22:12 | tomoj | casion: do you have it working? |
| 22:12 | casion | tomoj: yes |
| 22:13 | casion | right now I can get a seq of floats/ints/doubles as appropriate from any audio file supported |
| 22:13 | casion | and from there most dsp is trivial |
| 22:14 | n00b6502 | ah -> and ->> 'thread' the results as first or last argument |
| 22:14 | mpan | I keep getting confused which is which |
| 22:14 | n00b6502 | ->> is my 'pipe' |
| 22:16 | n00b6502 | so that kind of reads like "[:a,:b,:c].second().name().upper-case()" |
| 22:16 | tomoj | casion: cool |
| 22:16 | tomoj | the seq isn't lazy, is it? |
| 22:17 | casion | tomoj: not yet… I'm getting heap overflows with lazy-seqs atm |
| 22:17 | casion | I think it's because of how I'm sizing the buffer for the read |
| 22:17 | tomoj | I have some code sitting around that takes a filename and a function and calls the function with each frame |
| 22:17 | tomoj | looking at it now, it seems like that should be a reducer |
| 22:18 | mpan | :/ the doc examples showcase where -> and ->> are interchangeable |
| 22:18 | casion | converting the frame->sample conversion to a reducer is my next step |
| 22:19 | casion | right now it's just a list comprehension that grabs (/ frameLength channels) and bit twiddles that into a proper value |
| 22:21 | bbloom | mpan: which docs? |
| 22:22 | bbloom | http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E |
| 22:22 | bbloom | and http://clojuredocs.org/clojure_core/clojure.core/-%3E |
| 22:22 | bbloom | have good examples |
| 22:22 | mpan | am I mistaken or are the first example on those two pages interchangeable? |
| 22:23 | bbloom | mpan: you're mistaken |
| 22:23 | bbloom | the examples of r->> thread through the LAST argument |
| 22:23 | bbloom | ,(doc map) |
| 22:23 | clojurebot | "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments." |
| 22:23 | bbloom | notice that coll is after f |
| 22:23 | bbloom | ,(macroexpand '(-> x (f y))) |
| 22:23 | clojurebot | (f x y) |
| 22:24 | bbloom | ,(macroexpand '(->> x (f y))) |
| 22:24 | clojurebot | (f y x) |
| 22:24 | mpan | oh! |
| 22:24 | mpan | thank you |
| 22:26 | tomoj | casion: so if you have a seq of samples, you partition by a frame length and send each partition through a R2R fft to get the spectrogram of the audio? |
| 22:26 | casion | partition by framelength, then partition by channels |
| 22:26 | n00b6502 | (defn lerp [lo hi f] (->> (- hi lo)(* f)(+ lo))) (lerp 5 10 0.5) |
| 22:26 | n00b6502 | ,(defn lerp [lo hi f] (->> (- hi lo)(* f)(+ lo))) (lerp 5 10 0.5) |
| 22:26 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 22:27 | bbloom | n00b6502: can't def w/ clojurebot |
| 22:27 | casion | or you can just pull out the channels I guess |
| 22:27 | bbloom | ((fn [lo hi f] (->> (- hi lo)(* f)(+ lo))) 5 10 0.5) |
| 22:27 | bbloom | ,((fn [lo hi f] (->> (- hi lo)(* f)(+ lo))) 5 10 0.5) |
| 22:27 | clojurebot | 7.5 |
| 22:27 | casion | I've been partitioning by framelength, converting to the appropriate type, then partitioning by channels |
| 22:28 | casion | I suspect there's a better way. Most of today has been fighting the awful java docs on this stuff |
| 22:30 | casion | right now, partition doesn't exactly work well with larger files (runs out of heap space, and it's super slow anyway) |
| 22:36 | n00b6502 | is a clojure literal map a mutable colleciton |
| 22:36 | gfredericks | no |
| 22:36 | n00b6502 | so its more like an immutable adhoc object perhaps |
| 22:37 | gfredericks | I'm not sure what you meant by changing "collection" to "object" |
| 22:37 | gfredericks | it's just an immutable map datastructure |
| 22:38 | n00b6502 | for multiple return values do you just use a vector literal |
| 22:38 | gfredericks | sure |
| 22:38 | gfredericks | or a map if you want to give them names |
| 22:39 | n00b6502 | whats the best way to bind elements of a vector to symbols .. (i'm thinking of multiple-value-bind in CL) |
| 22:39 | bbloom | destructuring |
| 22:39 | gfredericks | +1 |
| 22:40 | bbloom | ,(let [[x y & zs] (range 10)] {:foo x :bar y :baz zs}) |
| 22:40 | clojurebot | {:foo 0, :bar 1, :baz (2 3 4 5 6 ...)} |
| 22:41 | bbloom | also works with maps & other fun stuff. see the let for on here: http://clojure.org/special_forms |
| 23:25 | Frozenlock | If nothing refers to an atom anymore, is it discarded? |
| 23:29 | bbloom | Frozenlock: why wouldn't it? |
| 23:31 | Sgeo | bbloom, because in some languages, they... oh, wait, "atom" in Erlang means something else |
| 23:32 | Frozenlock | bbloom: I just don't suppose things anymore. |
| 23:33 | bbloom | heh. yeah. erlang atom is similar to a symbol or keyword. but JVM clojure *does* garbage collect those by leveraging weak references |
| 23:33 | Frozenlock | And cljs? |
| 23:33 | bbloom | cljs (currently) encodes keywords and symbols into strings |
| 23:33 | bbloom | which the underlying javascript engine will certainly garbage collection |
| 23:34 | bbloom | however, javascript doesn't provide weakreferences |
| 23:34 | bbloom | sadly.... |
| 23:34 | mpan | speaking of which, what is the purpose of keywords that symbols don't already fulfill? |
| 23:35 | bbloom | keywords are like symbols that always refer to themselves |
| 23:36 | bbloom | :foo is always :foo. but 'foo could refer to a local, or a function, or something else entirely |
| 23:38 | bbloom | ,`(class :foo) |
| 23:38 | bbloom | hmm... |
| 23:38 | bbloom | ,(identity `(class :foo)) |
| 23:38 | bbloom | where's clojure bot when you need him |
| 23:38 | clojurebot | (clojure.core/class :foo) |
| 23:38 | clojurebot | (clojure.core/class :foo) |
| 23:38 | bbloom | ah there we go |
| 23:38 | bbloom | anyway |
| 23:38 | bbloom | notice how "class", a symbol, was resolved |
| 23:38 | bbloom | but :foo remained unchanged |
| 23:39 | bbloom | there is no lookup process for a keyword. if you have the keyword, you have all that it represents |
| 23:39 | bbloom | if you have a symbol, you need to know how to interpret it, like that syntax quote does, by looking up the function in scope with that symbol for a name |
| 23:42 | bbloom | make sense? |
| 23:42 | mpan | er, but like, what's to stop people from using symbol literals? |
| 23:42 | mpan | like, explicitly quoted symbol literals? |
| 23:42 | bbloom | nothing |
| 23:42 | bbloom | and that's what the common lisp folks do, right? |
| 23:42 | mpan | dunno |
| 23:42 | bbloom | (i'm not a common lisper, i dunno for sure) |
| 23:43 | bbloom | of course you can quote symbols: |
| 23:43 | bbloom | ,`('class :foo) |
| 23:43 | clojurebot | ((quote clojure.core/class) :foo) |
| 23:43 | mpan | oh, wait |
| 23:43 | bbloom | but it still get resolved! |
| 23:43 | mpan | but then it tries to figure out which "class" you mean? |
| 23:43 | bbloom | so you need to do some trickery |
| 23:43 | bbloom | ,`(~'class :foo) |
| 23:43 | clojurebot | (class :foo) |
| 23:44 | bbloom | and, indeed, that's sometimes (although rarely) useful |
| 23:44 | mpan | you're allowed to use that outside macro defs? |
| 23:44 | mpan | oh wow |
| 23:44 | bbloom | haha sure! |
| 23:44 | bbloom | :-) |
| 23:44 | mpan | all right thanks |
| 23:45 | mpan | I guess I'm trying to stay away from the meta bits until I need them |
| 23:45 | bbloom | yeah, i've been contributing to the clojurescript compiler |
| 23:45 | bbloom | where it's not so much meta, as it is … um… something less than meta ;-) |