2009-07-13
| 10:11 | Georges` | Hello |
| 10:12 | cgrand | Hi Georges! |
| 10:13 | Georges` | newbie question... |
| 10:14 | Raynes | Hello there. |
| 10:15 | Georges` | how do you fill a map in a map call? |
| 10:15 | Georges` | (let [map {}] |
| 10:16 | Georges` | (map (fn ...) XXX my-list)) |
| 10:16 | Georges` | (let [my-map {}] (map (fn ...) XXX my-list)) |
| 10:16 | kotarak | The function "map" is not a "map". Try: (into {} (map (fn ...) my-list) |
| 10:17 | kotarak | fn should return key value pairs. |
| 10:17 | Chouser | where the (fn ...) returns a vector of [key val] |
| 10:17 | Raynes | map applies a function to every element of a sequence and returns the result. |
| 10:19 | kotarak | ,(into {} (map (fn [k v] (vector k v)) [:a :b :c] (iterate inc 0))) |
| 10:19 | clojurebot | {:c 2, :b 1, :a 0} |
| 10:19 | Georges` | yeah, still haven't adjusted to that functional style |
| 10:20 | Georges` | OK, I'll try. |
| 10:20 | Georges` | Thanks |
| 10:20 | Raynes | There is also the hash-map function. |
| 10:21 | Raynes | ,(apply hash-map [:key "value" :key2 "value2"]) |
| 10:21 | clojurebot | {:key "value", :key2 "value2"} |
| 10:21 | Chouser | and zipmap! |
| 10:21 | Chouser | ,(zipmap [:k1 :k2] [:v1 :v2]) |
| 10:21 | clojurebot | {:k2 :v2, :k1 :v1} |
| 10:22 | Raynes | Chouser: Oh, you're good. |
| 10:24 | Chouser | and merge! |
| 10:24 | Chouser | ,(apply merge {} (map (fn [x] {x (* x 2)}) (range 5))) |
| 10:24 | clojurebot | {4 8, 3 6, 2 4, 1 2, 0 0} |
| 10:25 | Chouser | the only "related functions, change a map' items left are assoc, dissoc, and select-keys |
| 10:25 | Chouser | hmm... |
| 10:25 | Georges` | What if I need to insert two values in the map for each iteration ? |
| 10:26 | Chouser | Georges`: merge can do that |
| 10:26 | kotarak | ,(reduce (fn [m kv] (apply assoc m kv)) {} (partition 2 [:a 1 :b 2 :c 3]) |
| 10:26 | clojurebot | EOF while reading |
| 10:26 | kotarak | ,(reduce (fn [m kv] (apply assoc m kv)) {} (partition 2 [:a 1 :b 2 3])) |
| 10:26 | clojurebot | {:b 2, :a 1} |
| 10:26 | Chouser | there's reduce+assoc |
| 10:26 | kotarak | -.- smiley.... |
| 10:27 | kotarak | ,(assoc {} :a 1 :b 2) |
| 10:27 | yason | Good stuff these zipmap, (into {} ...). I've relied on (apply hash-map ...) before but I absolutely hate to flatten a list of tuples into a list concatenated together |
| 10:27 | clojurebot | {:b 2, :a 1} |
| 10:27 | Chouser | I can't think of how to use dissoc or select-keys to build a map |
| 10:28 | Chouser | I guess that's good. :-) |
| 10:28 | kotarak | Chouser: well, maybe you have a default map and dissoc stuff to get the result? But that would be pretty esoteric, no? |
| 10:29 | Chouser | sure. |
| 10:29 | Chouser | that stretches the definition of "build" sufficiently I think. :-) |
| 10:30 | kotarak | hehe |
| 10:30 | yason | Chouser: Like sculptors work: start with everything and remove what isn't part of the piece :) |
| 10:31 | Georges` | Chouser: merge is nice |
| 10:34 | Chouser | ,(into {} (filter #(some #{\?} (name (% 0))) (ns-publics 'clojure.core))) |
| 10:34 | clojurebot | {keyword? #'clojure.core/keyword?, instance? #'clojure.core/instance?, sequential? #'clojure.core/sequential?, fn? #'clojure.core/fn?, nil? #'clojure.core/nil?, string? #'clojure.core/string?, sorted? #'clojure.core/sorted?, false? #'clojure.core/false?, true? #'clojure.core/true?, odd? #'clojure.core/odd?, symbol? #'clojure.core/symbol?, number? #'clojure.core/number?, integer? #'clojure.core/integer?, reversible? #'cloj |
| 10:34 | Chouser | oh, whoops. still no dissoc |
| 10:34 | Raynes | You're just showing off now. |
| 10:34 | Raynes | :) |
| 10:35 | Chouser | and what's more, failing at it. |
| 11:44 | hiredman | http://twitter.com/ajlopez/status/2598594041 |
| 11:46 | hiredman | http://code.google.com/p/ajlisp/updates/list |
| 11:46 | Chouser | that's number 3, I think. |
| 11:46 | danlarkin | sure, why not another half-complete implementation :) |
| 11:47 | hiredman | and only an interpreter |
| 11:47 | Chouser | 3rd clojure-like in C#, I mean. |
| 11:48 | hiredman | and significantly different, I imagine |
| 11:49 | Chouser | He's got better test coverage (percent-wise) than Clojure. |
| 11:52 | hiredman | :P |
| 11:52 | hiredman | my concern is brand dilution |
| 11:53 | hiredman | what if he does add reader macros |
| 11:54 | Chouser | unless "Clojure" is trademarked (I assume it's not) I don't think there's anything rhickey can do via the law. Though a polite request to change the name might work |
| 11:54 | hiredman | in any case a polite request is the best place to begin |
| 11:54 | Chouser | indeed |
| 11:55 | Chouser | well, evaluation of whether such a request is needed should be first, but I think we've accomplished that. |
| 11:55 | cemerick | this happened once before (coping with the use of the clojure name) |
| 11:55 | Chouser | what he's got there may be clojure-inspired, but that's about it. |
| 11:56 | Chouser | cemerick: did it? there was a non-clojure-named C# thing, but there were potential copyright issues there which don't seem to apply in this case |
| 11:56 | Chouser | cemerick: or are you talking about something else? |
| 11:56 | cemerick | hrm, I thought there was a C# "port" (more like a complete clone of the svn at the time) that had a name that was some derivative of clojure |
| 11:57 | cemerick | I guess the use of the code was more of a concern than the name in that case |
| 12:10 | cemerick | yes? |
| 12:11 | Raynes | I don't need anything. >_> |
| 12:13 | ozzilee | What am I doing wrong? (binding [*out* java.io.FileWriter "foo"] (println "bar")) |
| 12:13 | ozzilee | Does that not work from the Repl? |
| 12:15 | Chouser | (binding [*out* (java.io.FileWriter. "foo")] (println "bar")) |
| 12:15 | Raynes | Doesn't work either. |
| 12:15 | Raynes | Wait, no. Haha. |
| 12:15 | Raynes | I failed. |
| 12:15 | Raynes | I forgot the period on the end of FileWriter. :\ |
| 12:16 | ozzilee | Chouser: I'm sorry, that's what I have. Still doesn't work. Just prints out to the Repl. |
| 12:21 | ozzilee | The file is created, but nothing gets written to it. |
| 12:21 | StartsWithK | ozzilee: works for me |
| 12:22 | StartsWithK | v1.0.0? |
| 12:23 | hiredman | ozzilee: close or flush the file |
| 12:23 | hiredman | (.flush *out*) |
| 12:23 | hiredman | (.close *out*) |
| 12:25 | ozzilee | Must be a bug in the version of clojure I'm using, works with the latest from SVN. |
| 12:27 | ozzilee | How does contrib mesh with clojure releases? Should I just contrib trunk along with clojure 1.0? |
| 12:27 | hiredman | there is a contrib branch for 1.0 compat |
| 12:28 | ozzilee | hiredman: Ah, okay. Thanks. |
| 12:29 | cemerick | (binding [*out* (java.io.FileWriter. "foo")] (println "bar")) works for me on v1.0.0 *shrug* |
| 12:31 | hiredman | and here on 1.1 alpha |
| 12:35 | ozzilee | I probably have an old version with this project. No big deal. |
| 12:36 | cemerick | ozzilee: what is the value of *clojure-version*? |
| 12:37 | ozzilee | Hrm, it's 1.1.0 alpha. |
| 12:38 | cemerick | that's interesting. |
| 12:40 | ozzilee | The clojure .zip file is a bastard, btw. Unzips all over the working directory. |
| 12:40 | technomancy | ozzilee: still? that was like my first bug report for Clojure back in November. =( |
| 12:42 | Raynes | My first bug report was the read-line bug. :D It was fixed long ago. |
| 12:43 | technomancy | well unfortunately the zip file isn't generated by code afaict, so I couldn't submit a patch. =\ |
| 12:47 | technomancy | ,(stream? (java.io.FileInputStream. "/etc/hosts")) |
| 12:47 | clojurebot | java.security.AccessControlException: access denied (java.io.FilePermission /etc/hosts read) |
| 12:47 | technomancy | bugger that |
| 12:47 | technomancy | anyway, that returns false for me |
| 12:47 | technomancy | I take it the stream? function doesn't do what it sounds like it does? |
| 12:48 | Chousuke | Stream is a clojure class. |
| 12:48 | technomancy | oh, I thought that was from a branch that never got merged in |
| 12:48 | Chousuke | There is some stream stuff in the source. |
| 12:48 | Chousuke | I don't know what it's for. |
| 12:48 | Chousuke | :P |
| 12:48 | technomancy | gotcha. good to know. |
| 12:49 | technomancy | what's a good superclass to check for when I'm looking for Java streams? |
| 12:49 | Chousuke | I don't think there is any :/ |
| 12:50 | Chousuke | at least in java.io |
| 12:50 | Chousuke | dunno about .nio |
| 12:50 | technomancy | I guess I'm specifically looking for an java.io.InputStream here |
| 12:52 | technomancy | ,(.getSuperClass java.io.InputStream) |
| 12:52 | clojurebot | java.lang.IllegalArgumentException: No matching field found: getSuperClass for class java.lang.Class |
| 12:53 | Georges` | symbol -> keyword = (keyword (name 'symbol)) ? Or is there simpler ? |
| 12:54 | Chousuke | that might lose the namespace |
| 12:54 | Chousuke | though that may be what you want :) |
| 12:54 | ozzilee | Okay, binding *out* works for me on git head. Must have been a bug or something in the revision I was using. |
| 12:54 | Georges` | oh right, maybe I'll just directly use keywords... |
| 12:55 | Chousuke | or (keyword (namespace sym) (name sym)) |
| 12:55 | hiredman | (ancestors java.io.InputStream) |
| 12:55 | hiredman | ,(ancestors java.io.InputStream) |
| 12:55 | clojurebot | #{java.io.Closeable java.lang.Object} |
| 12:56 | hiredman | heh |
| 12:56 | hiredman | Closeable |
| 12:58 | technomancy | hiredman: aha; thanks. |
| 13:07 | hiredman | ,(map #(.getName %) (.getMethods java.io.Closeable)) |
| 13:07 | clojurebot | ("close") |
| 13:09 | Chousuke | Oniichar: heh |
| 13:09 | Chousuke | oops. |
| 13:10 | Pip | Cool, so many folks : ) |
| 13:10 | Chousuke | that still works, minus the nickname :) |
| 13:12 | Georges` | Do you often use keywords instead of symbols in your data ? |
| 13:13 | Chousuke | more often than symbols I think :/ |
| 13:14 | Pip | So basically, Clojure is lisp + java ? |
| 13:14 | Chousuke | I think that's an oversimplification. :) |
| 13:14 | Georges` | Chousuke: it's true that this (:keyword map) is quite practical. |
| 13:14 | Chousuke | Georges`: (map 'symbol) works too though. :) |
| 13:14 | technomancy | Georges`: symbols are used more for writing macros than anything else. if you just need a name, use a keyword |
| 13:16 | Chousuke | Pip: Clojure is a lisp dialect, but it's quite different from both CL and Scheme. |
| 13:16 | Pip | Why ? |
| 13:17 | Georges` | technomancy: OK |
| 13:17 | Pip | Why do we need it since there are so many lisp dialects ? |
| 13:18 | cemerick | Pip: http://clojure.org/rationale |
| 13:20 | hiredman | clojurebot: why? |
| 13:20 | clojurebot | why not? |
| 13:20 | Pip | How to pronounce the name ? |
| 13:20 | hiredman | clojurebot: literal [?] why |
| 13:20 | clojurebot | 1 |
| 13:20 | Pip | clojurebot, Hi |
| 13:21 | Hun | Pip: there are about O(n) lisp dialects, for n being the number of all lispers who ever lived |
| 13:21 | hiredman | clojurebot: why is <reply>http://clojure.org/rationale |
| 13:21 | clojurebot | Ack. Ack. |
| 13:21 | cemerick | Pip: just like "closure". The 'j' doesn't affect the pronunciation. |
| 13:21 | Georges` | (class [x]) |
| 13:21 | clojurebot | x is w |
| 13:22 | Pip | the j means .... jvm ? |
| 13:23 | cemerick | rhickey: watchers are nifty; what would your opinion be of a variety that were executed within the scope of the transaction setting the ref in question, though? (e.g. on every LT.doSet) |
| 13:24 | cemerick | Pip: I presume so, although I honestly don't remember reading that stated definitively. |
| 13:25 | Pip | thanks, must be easy to learn right ? |
| 13:25 | hiredman | I dunno abouhttp://clojure.org/rationale |
| 13:25 | hiredman | er |
| 13:25 | hiredman | I dunno about easy, seems on par with everything else |
| 13:26 | hiredman | just depends on who is learning |
| 13:26 | rhickey | cemerick: sounds like in-transaction side effects |
| 13:28 | cemerick | rhickey: on the contrary, none of the watchers I'm contemplating (or watcher-like things we already use) are side-effecting. It's just that there are watchers whose application should be included within the transaction that touches particular refs, which isn't possible given core's current watcher impl. |
| 13:29 | rhickey | cemerick: what do they do? |
| 13:36 | cemerick | rhickey: various things, but the fundamental mechanism is a cells impl where validation constraints can trigger (directed) backtracking. (Maybe) obviously, you want all of the propagated transformations to take place in a single transaction. |
| 13:36 | rhickey | so the watch triggers other ref mods? |
| 13:36 | Chouser | "I already have a bunch of |
| 13:36 | Chouser | files containing data structures written with *print-dup*" |
| 13:36 | Chouser | ouch |
| 13:37 | cemerick | rhickey: yes |
| 13:38 | cemerick | Chouser: heh, we're heading down that road as I type |
| 13:38 | rhickey | cemerick: seems easy to misuse |
| 13:38 | rhickey | cemerick: I understand the use case though |
| 13:39 | cemerick | rhickey: with great power, and all that. My fallback (if you aren't swayed in this case) is to have parallel ref-set, commute, and alter fns that synchronously trigger updates via 'neighbor' refs held in the just-altered ref's metadata. |
| 13:39 | rhickey | would synced watches as a property of the ref suffice? |
| 13:40 | rhickey | vs a second variety of watches |
| 13:40 | rhickey | would preclude in-and-outside of transaction watches on same ref |
| 13:41 | cemerick | rhickey: not entirely sure I follow -- do you mean the watches would only be settable at ref-creation-time? |
| 13:41 | rhickey | cemerick: no, that calling them in-transaction would be a ref property |
| 13:42 | cemerick | oh, I see. |
| 13:42 | rhickey | (def r (ref 42 :sync-watches true)) |
| 13:43 | drewr | Chouser: I've been ambivalent myself about storing data that way. :-/ |
| 13:43 | rhickey | I guess it could be a property of add-watch, for refs |
| 13:43 | cemerick | Seems fine to me, esp. since one could just as easily send off to an agent if you really wanted to break out of a transaction to get hybrid behaviour (not sure why one would want to do that, but...) |
| 13:45 | cemerick | rhickey: yeah, I'd prefer it to be a property of add-watch, just to ensure maximum flexibility. |
| 13:46 | cemerick | or, it could be part of the metadata of the fn provided to add-watch. Lots of options. |
| 13:46 | cemerick | Or, a configuration property of sync (which would just rope in a subclass of LT with an override of doSet that calls super.doSet(), and then fires off the notifications). |
| 13:46 | rhickey | definitely not property of sync |
| 13:47 | cemerick | aagh, that "transaction-flags => TBD" line in the doc of sync is like a blank piece of paper for me ;-) |
| 13:48 | rhickey | cemerick: blank paper, but not for scribbling :) |
| 13:48 | cemerick | (sync {:do-what-I-want true} ...) |
| 13:48 | rhickey | timeouts, retry limits, other true properties of the transaction |
| 13:48 | rhickey | conflict resolution policy |
| 13:49 | Chouser | (sync {:i-win-conflicts true} ...) |
| 13:49 | Chouser | cemerick: you're right, this is fun |
| 13:51 | rhickey | I'd look at a rev for (add-watch aref k f :sync true), but it means a second watch list, and more complexity in Ref... |
| 13:51 | technomancy | the girl next to me at the coffee shop has Eclipse open and is learning about for loops for a CS course. |
| 13:52 | cemerick | rhickey: you mean ARef? |
| 13:52 | technomancy | I feel like I should do something... save her from a life of pain. |
| 13:52 | rhickey | Chouser: :i-win-conflicts true is not far-fetched |
| 13:52 | rhickey | cemerick: well, it doesn't make sense for the other refs, so would have to move down into Ref |
| 13:54 | Chouser | sending to an agent from a synchronous ref watcher wouldn't actually break out of the transaction, right? the send would be help until commit. |
| 13:54 | cemerick | right, that makes sense |
| 13:54 | rhickey | Chouser: right |
| 13:55 | rhickey | true sync sends are not possible |
| 13:55 | rhickey | similarly makes so sense to do sync watch in Atom on failed CAS |
| 13:55 | Chouser | so a sync watcher is not a more general case, it's just alternate case |
| 13:56 | Chouser | bleh. :-( |
| 13:56 | hiredman | technomancy: "you should use a while loop and trampolined Callables for that" |
| 13:56 | Chouser | oh... |
| 13:56 | technomancy | hiredman: I'll tell her to talk to you. |
| 13:56 | Chouser | these sync ref watchers might retry. hadn't thought of that. |
| 13:57 | slurms | I was noticing that, I don't think watchers are covered in Stu's book |
| 13:57 | rhickey | Chouser: yeah, it's really only a Ref thing, and then only for use as directed - to update other refs in same transaction. Will likely be used to create all kinds of bugs, side effects, linked DB transactions etc. cemerick has volunteered to support :) |
| 13:57 | Chouser | hehe |
| 13:57 | hiredman | I've been trying to get people in #java asking homework questions to use some kind of trampolined callable thing as a solution |
| 13:58 | Chouser | slurms: they're all still marked "experimental" |
| 13:58 | cemerick | rhickey: I promise to instigate at least half of those bugs, side effects, and linked DB transactions! :-P |
| 13:59 | technomancy | hiredman: sounds like fun. |
| 13:59 | rhickey | we should be saying watches here, not watchers |
| 13:59 | slurms | Chouser: k. I'm a novice, but I can already see where they'd come in useful in things I make. Is there any documentation on them out there? |
| 13:59 | rhickey | ,(doc add-watch) |
| 13:59 | clojurebot | "([reference key fn]); Experimental. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. Note tha |
| 13:59 | hiredman | you'd think, but no takers so far |
| 14:00 | cemerick | rhickey: is 'watchers' a loaded term otherwise? You seem to have been very careful to say 'watches' in the doc. |
| 14:00 | slurms | true |
| 14:00 | rhickey | cemerick: there are still agent-based watchers, built on watches |
| 14:00 | rhickey | ,(doc add-watcher) |
| 14:00 | clojurebot | "([reference send-type watcher-agent action-fn]); Experimental. Adds a watcher to an agent/atom/var/ref reference. The watcher must be an Agent, and the action a function of the agent's state and one additional arg, the reference. Whenever the reference's state changes, any registered watchers will have their actions sent. send-type must be one of :send or :send-off. The actions will be sent after the reference's state is |
| 14:01 | cemerick | ah-ha |
| 14:08 | Chouser | so I mentioned low-hanging fruit on the clojure-in-clojure effort and have been completely overwhelmed by the flood of offers to help that haven't come rolling in. :-P |
| 14:09 | Chousuke | :) |
| 14:10 | hiredman | eh? |
| 14:10 | drewr | Chouser: so far all I've contributed to the effort is posting your article on Hacker News :-) |
| 14:10 | drewr | it's a start |
| 14:11 | hiredman | looking at the article, I did not see any low hanging fruit mentioned, just "we need new-new" |
| 14:11 | technomancy | Chouser: you mean porting the reader? |
| 14:13 | Chouser | technomancy: yeah |
| 14:13 | clojurebot | technomancy is to blame for all failures |
| 14:13 | Chousuke | :P |
| 14:13 | Chouser | drewr: yeah, it got up to #1 for a few minutes. That was fun. :-) |
| 14:13 | Chouser | drewr: thanks! |
| 14:14 | technomancy | Chouser: any low-hanging fruit that doesn't involve reading Java code? =) |
| 14:14 | Chouser | heh |
| 14:15 | Chouser | technomancy: maybe you can recreate it from the docs, unit tests, and your own knowledge of how it works. |
| 14:15 | Chouser | might end up with a better design than reading the Java code anyway, who knows? |
| 14:16 | technomancy | Chouser: if you saw the scheme parser I wrote you wouldn't say that. =) |
| 15:59 | hiredman | clojurebot has 1337 bookmarks on delicious |
| 16:19 | technomancy | OK, so I've got a macro that needs to refer to a static field inside a class I've imported. |
| 16:20 | technomancy | it looks like if I use the macro in a namespace in which that class isn't imported, it blows up |
| 16:21 | technomancy | I guess I can def the field to a var in the macro's class |
| 16:21 | Chouser | I don't think you should have to do that |
| 16:22 | Chouser | hm. |
| 16:23 | Chouser | try the old syntax (. ClassName staticName) |
| 16:23 | technomancy | Chouser: thanks! that did the trick. |
| 16:23 | technomancy | is that a bug or something? |
| 16:23 | Chouser | not sure yet |
| 16:24 | Chouser | feels that way though, doesn't it. |
| 16:24 | technomancy | the / syntax is preferable because it doesn't push me over 80 columns. =) |
| 16:24 | Chouser | yes. and for other reasons as well. :-) |
| 16:24 | technomancy | but . works for now. |
| 16:25 | Chouser | ,(macroexpand `(Integer/x)) |
| 16:25 | clojurebot | (. Integer x) |
| 16:25 | Chouser | ,(macroexpand `(. Integer x)) |
| 16:25 | clojurebot | (. java.lang.Integer sandbox/x) |
| 16:26 | technomancy | well then. |
| 16:40 | Chouser | I don't see how that can be desired, nor any obvious reason why it would be impossible to treat those the same. |
| 16:57 | Chouser | hm, the class name in (. Integer x) is expanded at syntax-quote time |
| 16:57 | Chouser | as it is for (Integer.) as well |
| 16:58 | Chouser | ,`(Integer.) |
| 16:58 | clojurebot | (java.lang.Integer.) |
| 16:59 | Chouser | but not so for (Integer/x) since it might name a namespace, I suppose, and not a class |
| 17:00 | technomancy | that makes sense; there's some ambiguity there. |
| 17:04 | rzoom | looking at add-watcher it says that it is "Experimental", does that label mean? |
| 17:04 | rzoom | it may fail? syntax may change? |
| 17:04 | Chouser | rzoom: that mostly has to do with the API going forward, I think. |
| 17:05 | rhickey | rzoom: add-watcher might go away, as it is no longer primary, being built on add-watch. add-watch is not really experimental anymore. Both work just fine. |
| 17:05 | rzoom | so, if add-watcher goes away, I should try to refactor a bit to use add-watch? |
| 17:06 | rhickey | rzoom: if add-watcher goes away you can copy its current implementation into your app. |
| 17:06 | rhickey | its just a watch fn that sends to an agent |
| 17:11 | rzoom | so, (add-watcher A :send B f) is roughly: (add-watch A :my_key (send B f)) |
| 17:11 | rzoom | though the f's have to take different args |
| 17:12 | rzoom | A is the watched agent and B is the watching agent |
| 17:14 | rhickey | rzoom: sort of - #(send B f A) |
| 17:15 | rhickey | plus some 'did something change?' logic - see core.clj |
| 17:16 | rzoom | of course, forgot the # there for the send. thanks. |
| 17:20 | Chouser | rhickey: so would it be acceptible for Integer/x to become java.lang.Integer/x at syntaxQuote time |
| 17:21 | Chouser | ? |
| 17:22 | rhickey | Chouser: yes, I thought we did that already? |
| 17:22 | Chouser | nope -- the other modern forms do, but not static fields or static methods |
| 17:22 | Chouser | ,`(Integer/x) |
| 17:22 | clojurebot | (Integer/x) |
| 17:22 | Chouser | ,`(Integer.) |
| 17:22 | clojurebot | (java.lang.Integer.) |
| 17:23 | Chouser | hm. I guess that's it. |
| 17:23 | rhickey | I guess the reason why not is it is not clear that Foo in Foo/x is supposed to be a class or a ns name |
| 17:23 | Chouser | right |
| 17:24 | Chouser | but an exploratory resolveSymbol should give good results I think |
| 17:24 | rhickey | still, if Foo resolves to com.bar.Foo class then that is what syntax quote should do |
| 17:25 | rhickey | but must have no exception catching otherwise |
| 17:26 | Chouser | as in Foo/x is perfectly legal and read as just Foo/x when Foo is not a class? |
| 17:26 | Chouser | or do you mean something more than that? |
| 17:27 | rhickey | just that we can't go through a path that calls forName. Should just qualify whatever is there, expanding classes and aliases |
| 17:28 | rhickey | aliases already work I think |
| 17:29 | Chouser | yeah |
| 17:33 | Chouser | so Compiler.resolveSymbol should be right -- uses ns mappings, not Class.forName |
| 17:38 | rhickey | Chouser: that's what's being called now |
| 17:38 | Chouser | resolveSymbol on just the classname, though |
| 17:38 | Chouser | I think I have a patch that should do. |
| 17:39 | rhickey | ah, be careful as resolveSymbol interns |
| 17:39 | rhickey | maybeResolveIn |
| 17:40 | rhickey | better |
| 17:42 | Chouser | sometimes calls RT.classForName |
| 17:42 | rhickey | only when it definitely must be a classname |
| 17:43 | rhickey | so, should have uncaught exception if not one |
| 17:43 | rhickey | maybeResolveIn is whar resolve uses |
| 17:43 | rhickey | what |
| 17:45 | Chouser | you want an exception coming out of syntaxQuote!? |
| 17:46 | rhickey | will be so only if some.bogus.classname |
| 17:47 | Chouser | but that could be some.valid.namespace/foo |
| 17:47 | Chouser | why not just namespace.getMapping(Classname)? |
| 17:48 | rhickey | ns is checked first |
| 17:48 | Chouser | if nil, leave it unresolved at syntax-quote time. if non-nil, expand it. |
| 17:48 | Chouser | ah |
| 17:48 | Chouser | indeed |
| 17:48 | Chouser | ok, so maybeResolveIn is what you want. |
| 17:49 | Chouser | no way to make a symbol without interning |
| 17:49 | Chouser | is that a problem? |
| 17:50 | rhickey | I meant interning in a ns |
| 17:50 | Chouser | ah. oh! yeah, that would be bad |
| 17:50 | rhickey | that's what resolveSymbol does |
| 17:50 | Chouser | ok |
| 17:51 | rhickey | we need to move syntax-quote out of the reader in cinc |
| 17:51 | Chouser | ok |
| 17:52 | Chouser | `(foo) becomes (syntax-quote (foo)) ? |
| 17:52 | rhickey | right |
| 17:55 | Chouser | maybeResolveIn checks if sym.ns is a namespace, but here sym.ns will always be null. if sym.name is valid.namespace it throws |
| 17:58 | rhickey | doesn't it just call getMapping? |
| 17:58 | Chouser | no, if sym.ns is null and sym.name has a dot, it calls RT.classForName |
| 17:59 | rhickey | yup |
| 17:59 | Chouser | but I don't need to resolve namespaces here, just classnames |
| 17:59 | Chouser | so I can call getMapping |
| 18:00 | Chouser | if that fails, fall back to current behavior (resolveSymbol) which must be getting the namespace resolved |
| 18:03 | Chouser | no exception for invalid.classname/foo which is unchanged |
| 18:03 | clojurebot | for is a loop...in Java |
| 18:06 | rhickey | Chouser: ok |
| 18:06 | clojurebot | Why are you asking *him* |
| 18:06 | Chousuke | Has clojurebot become chattier lately? :P |
| 18:16 | hiredman | Chousuke: still 1 in 100 chance, maybe just more lines? |
| 20:04 | arohner | stupid java question: duck-streams/reader provides read(char[]) |
| 20:04 | arohner | java.security.MessageDigest wants a byte[]. How do I convert between the two? |
| 20:06 | Chousuke | hm. |
| 20:07 | Chousuke | I think duck-streams should provide a byte[] reader too, if it doesn't. :/ |
| 20:07 | arohner | more specifically, duck-streams/reader returns a java.io.BufferedReader, which has read(char[]) |
| 20:08 | Chousuke | doesn't it have readBytes or something as well? |
| 20:09 | Chousuke | hm, apparently not. interesting. |
| 20:12 | Chousuke | arohner: looks like you want a bare BufferedInputStream instead of a Reader |
| 20:16 | arohner | oh, it looks like duck-streams/to-byte-array does what I want |
| 20:29 | bruceq | Hi, I am new to Clojure and am really excited about it. -- Does anyone have experience with Enclojure on Netbeans? I am trying it but no joy. |
| 20:43 | arohner | bruceq: I don't use enclojure or netbeans, but you might get a better response if you can describe how it doesn't work |
| 20:43 | arohner | it might also be worth asking on the google group |
| 20:44 | bruceq | What do you folks use? |
| 20:44 | bruceq | as and IDE? |
| 20:45 | arohner | I use emacs. people use a wide variety of IDEs. some emacs, some vi, some netbeans and a few others |
| 20:46 | arohner | a few of the other java IDEs have clojure plugins in various states of completion, but I don't remember which |
| 20:47 | bruceq | The problem in Netbeans is I am getting a NullPointerException in the Enclosure add-on when I try most of the commands. I can Make a REPL oane, but most of the commands like expression evaluation in the source window just throw exceptions. |
| 20:49 | bruceq | I looked at AquaMacs on the Mac, but wan't able to find docs on how to set of a Clojure envirmonment. I did find some references to SLIME but all of that stuff seems impenetrable. |
| 20:53 | arohner | did you see this for setting up emacs? |
| 20:53 | arohner | http://bc.tech.coop/blog/081023.html |
| 20:53 | arohner | it's somewhat out of date, but it'll give you a few hints |
| 20:55 | bruceq | Thanks. I may try to get that to work with AquaMacs. I noticed in the videos the Rich Hickey is using Aquamacs for his demos. |
| 21:01 | arohner | IMO, emacs + slime is the best environment, if you're already familiar with emacs |
| 21:01 | bruceq | I am not an emacs user, but I can tolerate Aquamacs. |
| 21:09 | arohner | can you use binding to override a defmethod call? |
| 22:35 | yangsx | What is the way to go if I want to use Java.io.FileFilter in my Clojure code, which is a Java interface class? |
| 22:36 | yangsx | Is proxy is right one? |
| 22:38 | Chouser | probably |
| 22:59 | lisppaste8 | yangsx pasted "how to use FileFilter?" at http://paste.lisp.org/display/83556 |
| 23:27 | durka42 | yangsx: it works for me -- define "it fails"? |
| 23:27 | durka42 | oh, i see |
| 23:27 | durka42 | yangsx: accept is supposed to return true or false |
| 23:28 | durka42 | try wrapping re-matches in (not (nil? _)) |