2010-09-04
| 04:34 | Raynes | chouser: Whenever you hop back on: I replied to the group post with some snapshots. <3 |
| 05:04 | triyo | .quit |
| 05:05 | triyo | oops |
| 06:19 | ryoko-sha | I'm trying to construct a loop in which an index integer variable is parsed from a string via (java.lang.Integer/parseInt "1'), but am getting an exception java.lang.RuntimeException: java.lang.IllegalArgumentException: recur arg for primitive local: i must be matching primitive (test.clj:10) |
| 06:19 | ryoko-sha | ...mystified |
| 06:21 | ryoko-sha | since (type 1) => java.lang.Integer and also (type (java.lang.Integer/parseInt "1")) => java.lang.Integer |
| 06:21 | mrBliss | try wrapping it in (int ..) |
| 06:21 | mrBliss | Integer != int |
| 06:22 | ryoko-sha | yep same deal ! |
| 06:23 | mrBliss | what are the other arguments to the recur call? |
| 06:24 | ryoko-sha | (recur (+ i 1))... |
| 06:24 | ryoko-sha | couldn't be simpler! |
| 06:24 | LaPingvino | (unchecked-add i 1) ? |
| 06:24 | mrBliss | try wrapping that in (int ..) or replace it by (inc ..) (I'm also guessing a bit ;-) |
| 06:25 | LaPingvino | + is not simple :P |
| 06:25 | LaPingvino | + is a function on (add) |
| 06:28 | ryoko-sha | [LaPingvino] - bingo! thanks (unchecked-add) |
| 06:28 | ryoko-sha | is (unchecked-add) very naughty in some way? |
| 06:28 | LaPingvino | (+) does the boxing |
| 06:29 | LaPingvino | which destroys the primitives |
| 06:29 | LaPingvino | basically :) |
| 06:29 | ryoko-sha | thanks - its all al learning experience! |
| 06:29 | LaPingvino | ryoko-sha: unchecked-add can cause overflows |
| 06:29 | LaPingvino | because you use primitives |
| 06:29 | mrBliss | it's in the name: |
| 06:30 | mrBliss | ,(unchecked-add Integer/MAX_VALUE 1) |
| 06:30 | clojurebot | -2147483648 |
| 06:30 | LaPingvino | and it will not automatically change the type to a higher capacity |
| 06:30 | LaPingvino | there you go :) |
| 06:30 | ryoko-sha | super |
| 07:26 | raek | ,(doc num) |
| 07:26 | clojurebot | "([x]); Coerce to Number" |
| 07:26 | raek | http://gist.github.com/442269 <-- primitives and recur, with comment from rhickey |
| 07:27 | raek | (the bug that the example illustrated has been fixed) |
| 07:30 | raek | ryoko-sha: I had to insert a call to num in the loop form: (defn fact [n] (loop [n n, (num 1)] (if (zero? n) acc (recur (dec n) (* acc n))))) |
| 07:30 | raek | *sigh* the loop binding vector should of course have been [n n, acc (num 1)] |
| 07:32 | raek | I don't think you should have to resort to unchecked-add |
| 07:48 | ryoko-sha | raek: yep - that worked for me - thanks |
| 07:49 | raek | I think that will throw an exception on overflow, rather than silently wrap around |
| 07:50 | ryoko-sha | better - although my values for i are very small - defensive programming etc... |
| 08:11 | fliebel | *puzzled* what is the long way to make a map/dict/whatever? {:i "mean" :those "things"} |
| 08:12 | mrBliss | ,(hash-map :a 1 :b 2) |
| 08:12 | clojurebot | {:a 1, :b 2} |
| 08:12 | fliebel | ah… I was thinking in the map direction, but map is something else :P |
| 08:12 | mrBliss | ,(zipmap [:a :b] [1 2]) |
| 08:12 | clojurebot | {:b 2, :a 1} |
| 08:13 | mrBliss | looks more like the other map :-) |
| 08:13 | raek | ,(into {} [[:a 1] [:b 2]]) |
| 08:13 | clojurebot | {:a 1, :b 2} |
| 08:24 | fliebel | Can anyone give em an example of max-key? the docs are chinese to me, but the fn name sounds like what I need. I want to get the key from a map whose number is the heigest. |
| 08:25 | raek | http://clojuredocs.org/v/1506 |
| 08:25 | raek | the key function should return a number |
| 08:26 | fliebel | ah... |
| 08:26 | raek | the element in the sequence for which the key function returns the highest number is the one returned by max-key |
| 08:27 | fliebel | raek: so Can I apply that to a map? |
| 08:28 | fliebel | ,(apply max-key {:a 1 :b 3}) |
| 08:28 | clojurebot | [:b 3] |
| 08:28 | fliebel | yay! |
| 08:29 | fliebel | uuhm, nope |
| 08:33 | fliebel | okay, this seems to work :) |
| 08:33 | fliebel | ,(apply (partial max-key last) {:a 1 :b 3 :c 2}) |
| 08:33 | clojurebot | [:b 3] |
| 08:38 | raek | (apply max-key key {1 :a, 10 :b, 100 :c}) |
| 08:38 | raek | ,(apply max-key key {1 :a, 10 :b, 100 :c}) |
| 08:38 | clojurebot | [100 :c] |
| 08:39 | fliebel | ty |
| 08:39 | raek | the "key" function that the docs refer to could be called the "scale" function |
| 08:39 | raek | as in "pick the element that has the highest value on this scale" |
| 08:40 | raek | ,(apply max-key val {:a 1, :b 10, :c 100}) |
| 08:40 | clojurebot | [:c 100] |
| 09:07 | fliebel | What is the proper way to do this? |
| 09:07 | fliebel | ,(map reverse {:a 1 :b 2}) |
| 09:07 | clojurebot | ((1 :a) (2 :b)) |
| 09:08 | mfex | hey fliebel, the proper way to do that is to do it that way :) |
| 09:08 | fliebel | mfex: I mean, I want a map witht he keys and values switched |
| 09:09 | Raynes | -> (into {} (map reverse {:a 1 :b 2})) |
| 09:09 | sexpbot | java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map$Entry |
| 09:09 | Raynes | wut |
| 09:09 | fliebel | yea... |
| 09:09 | Raynes | -> (apply hash-map (map reverse {:a 1 :b 2})) |
| 09:09 | sexpbot | => {(2 :b) (1 :a)} |
| 09:09 | fliebel | tried all of that... |
| 09:10 | _mst | ,(let [m {:a 1 :b 2 :c 3}] (zipmap (vals m) (keys m))) |
| 09:10 | clojurebot | {3 :c, 2 :b, 1 :a} |
| 09:11 | _mst | (it always takes me about three minutes to remember that it's called "zipmap" :) |
| 09:11 | fliebel | _mst: Yea, I never get there at all, I end up browsing the sipper package. |
| 09:11 | fliebel | *zipper |
| 09:13 | mfex | ,(into {} (map (juxt val key) {:a 1 :b 2})) |
| 09:13 | clojurebot | {1 :a, 2 :b} |
| 09:13 | Raynes | ->(into {} (map (comp vec reverse) {:a 1 :b 2})) |
| 09:13 | sexpbot | => {2 :b, 1 :a} |
| 09:14 | Raynes | I like mine better. |
| 09:14 | Raynes | :D |
| 09:14 | hoeck | ,(clojure.set/map-invert {:a 1 :b 2 :c 3}) |
| 09:14 | clojurebot | {3 :c, 2 :b, 1 :a} |
| 09:14 | Raynes | I like his the best. |
| 09:15 | Raynes | >_> |
| 09:15 | fliebel | hoeck: Yea, that's the better way to do things :) |
| 09:15 | Raynes | Why are there map functions in the set namespace...? |
| 09:15 | Raynes | They trick me out. |
| 09:16 | hoeck | maybe because of their relational nature |
| 09:17 | ssideris | what's wrong with (apply hash-map (map reverse {:a 1 :b 2})) |
| 09:17 | ssideris | it looks like the easiest to read |
| 09:17 | ssideris | apart from the map-invert of course |
| 09:17 | hoeck | core.set has also rename-keys, index and join functions |
| 09:17 | fliebel | ssideris: Try it... |
| 09:17 | Raynes | ssideris: The fact that it doesn't work is a pretty bad deal breaker. |
| 09:18 | ssideris | oops, yeah sorry |
| 09:18 | Raynes | :) |
| 09:18 | ssideris | but the zipmap solution is ok, right? |
| 09:19 | fliebel | This is how map-invert does it: (reduce (fn [m [k v]] (assoc m v k)) {} m)) |
| 09:21 | jcromartie | I'm playing with designing a system that uses the SICP notion of "streams" for representing the state of an object |
| 09:21 | jcromartie | bec |
| 09:22 | Raynes | ssideris: I think any of the examples above are reasonable. |
| 09:22 | jcromartie | because the sequence of states of certain things over time is really important for the type of system I'm building |
| 09:22 | jcromartie | but I've hit a couple of spots where I'm not really sure how to represent things |
| 09:23 | fliebel | Is there any difference between using a map as a function with a key as argument, or the reverse? Both seem to work. |
| 09:23 | jcromartie | mostly because you can't serialize functions |
| 09:23 | jcromartie | fliebel: only one works when the map is nil |
| 09:25 | jcromartie | (and that's the keyword-as-fn) |
| 09:28 | mfex | fliebel: :keyword as the function works when the map is nil and with records as well, but for maps with keys that are not lookup functions there is no choice |
| 09:44 | fliebel | Is there something like rand-nth that lets you define the odds of getting certain items? The easy way out is letting certain items occur more often in the seq, but that seems stupid. |
| 09:48 | raek | fliebel: look at the "wrand" function in rhickey's ant.clj example |
| 09:48 | raek | http://raek.se/ants.clj |
| 09:50 | fliebel | raek: That looks like what I need : |
| 09:50 | fliebel | :) |
| 10:24 | Bahman | Hi all! |
| 10:25 | ssideris | fliebel: what you want to do is called "roulette selection" |
| 10:26 | ssideris | it's used in genetic programming among other things |
| 11:02 | fliebel | Aaah, the dreaded "Can only recur from tail position"… what is considered the tail position? I'm sure this has been asked before, I'm even sure *I* asked it before. I'm recurring from the if clause of an if-let, with and else clause following. |
| 11:04 | fullets | ,((fn [x] (if-let [_ (pos? x)] (recur (dec x)) :done)) 3) |
| 11:04 | clojurebot | :done |
| 11:05 | fullets | Could you pastebin your code? |
| 11:06 | fliebel | fullets: http://gist.github.com/564552 |
| 11:06 | fliebel | (near the end) |
| 11:06 | fliebel | line 43 |
| 11:09 | fullets | That let is the final statement in the if |
| 11:09 | fullets | That is, there is no else clause as written |
| 11:10 | fliebel | you're right, I think I got my parens mixed up… |
| 11:13 | fliebel | yea, works :) |
| 11:14 | fliebel | See here, my new and improved rock-paper-scissors bot: http://gist.github.com/564552 |
| 11:18 | fliebel | It has zero randomness and will hopefully improve over time. By knowing how it works, you can win. |
| 11:19 | lpetit | hello |
| 11:19 | fliebel | lpetit: hey |
| 11:21 | lpetit | do some people have feedback on ccw version 62 to give ? I'm considering releasing a corrective version, so if more must be included ... |
| 11:21 | lpetit | ... now's the time for it :) |
| 11:44 | kumarshantanu | lpetit: I have a small correction request for CCW |
| 11:45 | kumarshantanu | lpetit: when one wants to create a clojure file with dash in the file name, it should say "Consider using underscore instead of dash" |
| 11:46 | kumarshantanu | lpetit: instead of simply saying "invalid filename" |
| 12:03 | zmyrgel | hi, how can I cast java class in clojure? |
| 12:08 | zmyrgel | for example, findComponentAt returns Component which I want to cast to JLabel |
| 12:41 | kumarshantanu | zmyrgel: casting is not required in clojure |
| 12:42 | kumarshantanu | zmyrgel: because clojure is a dynamically types language |
| 12:46 | zmyrgel | kumarshantanu: so in the above scenario it automatically finds the that the Component is actually JPanel and I can call JPanels method for it? |
| 12:47 | kumarshantanu | zmyrgel: yes, it depends on the object type, not on the reference type (because there is no reference type in clojure) |
| 12:52 | zmyrgel | kumarshantanu: ok, thanks |
| 13:03 | ApeShot | So I've compiled the latest clojure.jar and clojure-contrib.jar, and put them in the lib folder of my clojure project, and started up (successfully) slime from within emacs, but I can't (use 'clojure.contrib.string) or (use 'clojure-contrib.string), even though there does seem to be such a lib in the clojure-contrib source I compiled from. Any idea what gives? |
| 13:16 | ApeShot | I have been away from clojure for a few months, at least - has something changed in the way that libraries work? |
| 13:16 | ApeShot | I can (use 'clojure.contrib.str-utils) but, though it executes without error, this does not seem to actually import any of the functions in that library |
| 14:01 | fliebel | What functions are there to return a lazy cumulative map/seq? So that every item is itself plus every previous item. [1 2 3] -> [1 3 6] and then with a hash-map. *browsing the core docs* |
| 14:03 | somnium | ,(take 5 (reductions + (iterate inc 0))) |
| 14:03 | clojurebot | (0 1 3 6 10) |
| 14:03 | fliebel | somnium: Nice :) thank you |
| 14:04 | somnium | oh, I guess we can do (range) nowadays instead (iterate ...) |
| 14:04 | somnium | np |
| 14:04 | arohner | map entries can't hold metadata? |
| 14:04 | fliebel | somnium: With the slight difference that I'm not doing a list of 1 2 3, but rather 1 5 8, and then want to have 1 6 something |
| 14:05 | arohner | I wish everything, including ints and strings, could hold metatdata |
| 14:05 | fliebel | arohner: Anything that's java can't |
| 14:05 | arohner | fliebel: I know. It's just getting annoying |
| 14:07 | kumarshantanu | what's the best way to transform [:a 10 :b 20 :c 30] --> {:a 10 :b 20 :c 30} ? the two ways I know are (reduce #(assoc %1 (first %2) (last %2)) {} (partition 2 [:a 10 :b 20 :c 30])) and (apply assoc {} [:a 10 :b 20 :c 30]) |
| 14:08 | tomoj | arohner: how would you get a map entry with some metadata into a map? |
| 14:08 | arohner | tomoj: using into |
| 14:08 | arohner | (into {} seq-of-map-entries |
| 14:09 | chouser | ,(apply array-map [:a 10 :b 20 :c 30]) |
| 14:09 | clojurebot | {:a 10, :b 20, :c 30} |
| 14:10 | tomoj | ,(let [x (first {:a 2})] (identical? x (first (into {} [x])))) |
| 14:10 | clojurebot | false |
| 14:10 | kumarshantanu | arohner: (with-meta {:a 10 :b 20} {:motd "Hello World"}) |
| 14:10 | tomoj | I suppose it would copy the metadata in if it were there |
| 14:13 | somnium | has anyone done an ADT library with deftype/defrecord? |
| 14:16 | somnium | integers aren't valid names for fields, right? |
| 14:16 | arohner | somnium: right |
| 14:17 | somnium | but something like {:ADT_TAG t, T0 a ... TN z}, and then a pattern matching macro could add the right field names |
| 14:17 | somnium | then you could use ADT pattern matching internally, but still plug the class into protocols |
| 14:17 | kumarshantanu | chouser: thanks, that's the first kind of use of array-map I noticed now |
| 14:18 | somnium | hmm, maybe I'll give it a go |
| 14:18 | kumarshantanu | added an example @ array-map on clojuredocs.org too |
| 14:19 | somnium | this red-black-tree implementation convinced me of their potential utility: http://gist.github.com/561648 |
| 14:20 | tomoj | somnium: https://gist.github.com/cf84a59543e31f42d2a2 |
| 14:20 | tomoj | re ints as field names |
| 14:20 | tomoj | not that that's a good thing to do! |
| 14:21 | somnium | tomoj: yeah, just some ordered naming convention for (TAG a ... n) matching like haskell |
| 14:21 | tomoj | ,(class (symbol "1")) |
| 14:21 | clojurebot | clojure.lang.Symbol |
| 14:22 | somnium | ? |
| 14:23 | tomoj | my point was that while (defrecord Foo [1 2 3]) fails, with a macro we can do it |
| 14:23 | somnium | right |
| 15:02 | fliebel | I give up… How can I get a map sorted by its values? There are all sorts of ways to do it, but none actually works for me :( |
| 15:04 | tomoj | you can't, really |
| 15:05 | arohner | clojure's sorted maps are sorted by key |
| 15:05 | tomoj | ,(sort-by val {:a 3 :b 2 :c 1}) |
| 15:05 | clojurebot | ([:c 1] [:b 2] [:a 3]) |
| 15:05 | tomoj | but once you've done that you don't have a map anymore |
| 15:05 | arohner | if your map is 1:1, you can swap the keys and values |
| 15:08 | fliebel | I can live with tomoj's thing… I'm just doing ugly things I guess |
| 15:09 | fliebel | arohner: That could also work |
| 15:11 | LauJensen | Map lookups are usually by keys tomoj, so sort-by val makes a lot of sense to me |
| 15:12 | n2n3 | , |
| 15:12 | clojurebot | EOF while reading |
| 15:12 | n2n3 | ,(System/exit 0) |
| 15:12 | clojurebot | java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0) |
| 15:13 | n2n3 | ,{} |
| 15:13 | clojurebot | {} |
| 15:31 | jkkramer | fliebel: clojure.contrib.priority-map was recently added -- http://github.com/clojure/clojure-contrib/blob/master/modules/priority-map/src/main/clojure/clojure/contrib/priority_map.clj |
| 15:31 | jkkramer | it sorts by value |
| 15:32 | fliebel | jkkramer: Nice, but it's solved already. Good for next time :) |
| 15:33 | LauJensen | jkkramer: Whats the use case for something like that? |
| 15:33 | jkkramer | LauJensen: priority queue, for one |
| 15:33 | jkkramer | LauJensen: http://clj-me.cgrand.net/2010/09/04/a-in-clojure/ |
| 15:35 | LauJensen | ok, will take some time to grok |
| 15:36 | LauJensen | hmm, no I think I get it |
| 15:37 | jkkramer | i found out about this right after jerry-rigging a sorted-set priority queue for dijkstra's algorithm |
| 15:48 | LauJensen | jkkramer: for fun or work ? |
| 15:49 | jkkramer | LauJensen: currently for fun. writing a general-purpose graph lib |
| 15:49 | LauJensen | cool |
| 15:51 | jkkramer | planning to make a mailing list post about it to get some feedback |
| 15:51 | jkkramer | seems there's no fleshed-out graph lib for clojure yet |
| 15:57 | cmihai | What was that tool that gave command history to any repl called? |
| 15:57 | fliebel | jline? |
| 15:57 | fliebel | rlwrap? |
| 15:57 | cmihai | That was the one, thanks :-) |
| 15:58 | LauJensen | cmihai: slime |
| 15:59 | cmihai | Nah, I wanted it for db2 :P |
| 15:59 | emh | jkkramer: cool. I'm also working on a graph library. more special purpose than general though. for my master thesis, due in 1 week |
| 15:59 | cmihai | I remembered using it in conjunction with clojure, just forgot the name |
| 15:59 | LauJensen | emh: ouch, work fast :) |
| 16:00 | emh | yeah :) |
| 16:02 | jkkramer | emh: awesome. i'm trying to write a protocol- & record-based API that would be easy for anyone to write algorithms for |
| 16:04 | jkkramer | emh: are you doing anything fancy like multigraphs? or just simple/weighted/directed graphs? |
| 16:05 | emh | jkkramer: I'm also using protocols heavily. if you want to peek at my very work-in-progress-thesis, look here: http://rasmus.uib.no/~ehv022/thesis.pdf |
| 16:05 | emh | jkkramer: just simple undirected graphs for now. will probably extend it later |
| 16:05 | emh | after thesis |
| 16:06 | emh | depends on if I get a ph.d. after |
| 16:07 | emh | jkkramer: since I'm pressed for time I can't make it as elegant as I would wish. just have to crank out code as fast as possible |
| 16:09 | jkkramer | emh: very interesting! |
| 16:10 | jkkramer | emh: the concept of neighborhoods is new to me |
| 16:10 | emh | jkkramer: thx. we had all of it implemented in Java, but it's a huge ugly mess. I figured I'd have to rewrite in pseudo-code for presentation in my thesis, but clojure is sufficiently close to pseudocode so.. |
| 16:11 | emh | jkkramer: neighborhoods are very important in the decompositions, so I devote more data structures and protocols to them than would be normal in a general graph lib |
| 16:12 | jkkramer | emh: http://gist.github.com/565453 is the basic graph API so far. there are also some basic algorithms to go with it |
| 16:13 | jkkramer | emh: would be cool to be able to mix in capabilities with protocols. e.g., labeled graphs, neighborhoods |
| 16:14 | emh | jkkramer: yeah |
| 16:14 | emh | jkkramer: looks pretty good |
| 16:14 | emh | jkkramer: one thing I've thought about is whether it's worth distinguishing between read / write interfaces for graphs |
| 16:15 | emh | jkkramer: since read-only graphs might be implemented more efficiently |
| 16:16 | jkkramer | emh: interesting. with protocols you could define ReadonlyGraph record(s), and it could still work with all the polymorphic methods, and be able to convert easily to a writeable graph |
| 16:17 | emh | hmm, yeah, true, easy to do conversions |
| 16:19 | emh | I need to get some nice infrastructure for mixins and defaults later. I looked at the methods a la carte lib, looks like a nice start at least |
| 16:21 | emh | http://onclojure.com/2010/08/26/reusable-method-implementations-for-deftypes/ |
| 16:23 | emh | I'm using some quick hacks right now, sometimes implementing protocols on top of the Java interfaces for other protocols. for example implementing tex serialization protocol on top of interfaces for Graph protocol etc |
| 16:26 | jkkramer | seems there's still a lot of sussing out to be done when it comes to best practices for protocols, types, and records |
| 16:26 | emh | agreed |
| 16:59 | LauJensen | Does anyone have some pointers on how to make a design resizeable (grow/shrink) using contrib.miglayout |
| 16:59 | LauJensen | ? |
| 16:59 | pdk | my favorite thing about freenode's ircd is that it makes you leave half the channels you're on just to change your name if you dc |
| 17:07 | LauJensen | bozhidar: ^^ |
| 17:07 | bozhidar | LauJensen: hi |
| 17:07 | LauJensen | bozhidar: hi - got a clue about my q above? |
| 17:09 | bozhidar | LauJensen: I haven't gotten to using contrib.miglayout yet, but miglayout supports this on two levels |
| 17:09 | bozhidar | first you can declare growing columns/rows |
| 17:09 | bozhidar | and min/preferred/max sizes |
| 17:09 | bozhidar | and then you can use the same technique on the components themselves |
| 17:10 | bozhidar | when you add them to a container using miglayout |
| 17:10 | LauJensen | I might be in trouble with the wrapper then, I think it only supports components restraints. My setup is jframe -> jpanel -< jsplitpane -> 2 components. Where in that do you see the columns? |
| 17:11 | bozhidar | in the MigLayout object constructor |
| 17:11 | bozhidar | it takes a string representation |
| 17:11 | bozhidar | of the layout |
| 17:11 | bozhidar | with settings for every row and column |
| 17:11 | bozhidar | actually two strings |
| 17:11 | LauJensen | oh |
| 17:11 | bozhidar | one for the rows |
| 17:12 | bozhidar | and one for the columns |
| 17:12 | bozhidar | new MigLayout("wrap 1", "[grow]", "[grow]") - layout with one row and one column that grow |
| 17:13 | bozhidar | you should add additional [] for every other row/column you have |
| 17:14 | LauJensen | I don't think the wrapper lib supports constructor args, can they be passed in after construction ? |
| 17:14 | LauJensen | hmm, no actually it might |
| 17:14 | LauJensen | bozhidar: Thanks for the tips, I'll fiddle |
| 17:15 | bozhidar | there are setters for them |
| 17:15 | bozhidar | but oddly they take different arguments |
| 17:15 | LauJensen | oddly? |
| 17:15 | bozhidar | I personally always use the constructors |
| 17:15 | LauJensen | I have Java so bad - We mock PHP for being inconsistent, but Java is right up there with PHP |
| 17:15 | LauJensen | s/have/hate |
| 17:16 | bozhidar | hmm |
| 17:16 | bozhidar | I looked at the sources |
| 17:16 | bozhidar | even though the setters take Object |
| 17:16 | LauJensen | I iterate through some components, calling setBackground on them. Then I notice 2 of them arent affected. Google the first one and the answer comes up that under certain LookAndFeels its not guaranteed the calls to setBackground would be respected..?! |
| 17:16 | bozhidar | instead of String |
| 17:16 | bozhidar | they are internally cast to String |
| 17:16 | bozhidar | and parsed the same way |
| 17:17 | bozhidar | but this way you can pass something of type AC(which I've never seen so far) |
| 17:18 | bozhidar | this seems like a rather poor design decision - an overloaded method would have been easier to grasp |
| 17:19 | bozhidar | well, Swing is a pretty nasty story |
| 17:19 | LauJensen | bozhidar: And when the entire panel doesn't react to resizes at all, thats miglayout I have to blame? |
| 17:19 | bozhidar | there is simply no way to do everything the same way on totally different platforms |
| 17:19 | bozhidar | I don't if you're aware of the performance issues when you're using GTK+ L&F |
| 17:20 | bozhidar | when you start resizing the frame long enough |
| 17:20 | bozhidar | the JVM dies |
| 17:21 | bozhidar | if the panel is in another container - you'll have to configure it's layout manager as well |
| 17:21 | LauJensen | the panel is just in a jframe |
| 17:21 | bozhidar | if it's a top level panel(one contained directly in a JFrame) only setResizable(false) on the frame |
| 17:21 | bozhidar | might be causing something like that |
| 17:22 | jkkramer | is there a way to use 1.3 contrib complete with lein? [org.clojure.contrib/complete "1.3.0-SNAPSHOT"] doesn't seem to work |
| 17:22 | jkkramer | individual modules work |
| 17:25 | bozhidar | LauJensen: I think that JFrame used by default BoxLayout which would make the panel grow/shrink, but you can explicitly set some layout just to be on the safe side |
| 17:25 | bozhidar | I personally don't set manually the layout for my frames |
| 17:25 | LauJensen | yea, I'll have to import miglayout myself it seems |
| 17:25 | bozhidar | I just add one panel to each frame and set the panel as the frame's content pane |
| 17:26 | LauJensen | so you dont add it ? |
| 17:27 | bozhidar | I use code like this setContentPane(topPanel); |
| 17:27 | LauJensen | yea me too, no change |
| 17:28 | bozhidar | maybe you've set some size restrictions on the frame? |
| 17:28 | LauJensen | Not that I know |
| 17:30 | LauJensen | of |
| 17:31 | bozhidar | hmm, I can't think of anything else |
| 17:31 | bozhidar | maybe something is wrong with the wrapper |
| 17:32 | LauJensen | Either Im not getting it, or its half baked |
| 17:39 | LauJensen | bozhidar: both the panel and JFrame have (.setLayout "fill" "[grow]" "[grow]") and still do not react to resizes |
| 17:40 | LauJensen | (and the jtabbedpane) |
| 17:41 | bozhidar | LauJensen: AFAIK JFrame's setLayout method expects a layout object |
| 17:41 | LauJensen | I get no errors |
| 17:43 | bozhidar | it should be (doto (JFrame.) (.setLayout (MigLayout. "wrap 1" "[grow]" "[grow]"))) |
| 17:43 | LauJensen | why? |
| 17:43 | clojurebot | http://clojure.org/rationale |
| 17:43 | LauJensen | hehe |
| 17:44 | bozhidar | because according to the JFrame javadoc the method's signature is public void setLayout(LayoutManager manager) |
| 17:45 | bozhidar | it puzzles me that your invocation is not causing an error |
| 17:45 | LauJensen | (MigLayout. "wrap 1" ...) returns a manager right? |
| 17:46 | LauJensen | oh |
| 17:46 | bozhidar | yes |
| 17:46 | LauJensen | I wrote it wrong here |
| 17:46 | LauJensen | sorry |
| 17:46 | LauJensen | (.setLayout (MigLayout. "wrap 1" "[grow]" "[grow]")) |
| 17:46 | LauJensen | I wonder if constructing a JPanel with a Layout as its argument is similar to setting the layout later |
| 17:47 | bozhidar | it's the same |
| 17:47 | bozhidar | just a matter of taste most of the time |
| 17:47 | LauJensen | it is - but I cant be sure with all of these other inconsistencies |
| 18:16 | Raynes | chouser: Pingzors. |
| 21:03 | danlarkin | interesting tidbit, which I suppose makes sense when you take the time to think about it: the datastructure returned by (promise) mutates when delivered upon |
| 21:03 | danlarkin | so putting it inside a reference type is meaningless |
| 21:04 | hiredman | how so? |
| 21:04 | hiredman | a promise is a promise delivered or not, dereferencing blocks until it has been delivered to |
| 21:04 | danlarkin | ,(let [a (ref {:foo (promise)})] (deliver (:foo @a) :ok) a) |
| 21:04 | clojurebot | #<Ref@1ffa176: {:foo #<core$promise$reify__5534@1805bdb: :ok>}> |
| 21:05 | danlarkin | yeah I don't mean derefing the promise, but that it gets mutated inside a reference type |
| 21:05 | danlarkin | see I don't have a dosync there |
| 21:06 | hiredman | mutated how? if you ever look inside the promise you will always find the same value |
| 21:07 | danlarkin | it's mutated in the sense that first it was outstanding and then it was delivered |
| 21:08 | danlarkin | and since it's contained inside a ref in my example, it just exhibits different behavior than when persistent datastructures are in a ref |
| 21:08 | danlarkin | its behavior is obviously correct, it just tripped me up for a minute |
| 21:08 | hiredman | if from an observer's perspective something cannot be observered to changed, is mutable? |
| 21:09 | danlarkin | I don't get what you're driving at |
| 21:09 | hiredman | danlarkin: you wouldn't happen to know how to write applescript that takes input from quicksilver would you? |
| 21:10 | danlarkin | I do not. I tried to write a QS plugin once and found it much easier to just make it a shell script |
| 21:11 | hiredman | ok |
| 21:14 | danlarkin | so as a corollary to my discovery, I have a question. Is there a way, other than promise/deliver, to block on some arbitrary, programmer defined thing (ie not I/O) |
| 21:14 | danlarkin | (while @foo) or something is not true blocking, since it will just poll it every nanosecond or something |
| 21:20 | hiredman | there are a few blocking queues in j.u.concurrent |
| 21:20 | hiredman | and there are always Locks |
| 21:23 | danlarkin | locks to the rescue! who'd've thought |
| 21:24 | ataggart | does awaiting on an agent qualify? |
| 21:25 | danlarkin | interesting thought, but await only blocks on actions sent from the thread on which you await |
| 21:25 | ataggart | ah right |
| 21:30 | ataggart | can anyone think of an environmental issue that would cause a binding to not be applied? There are 3 tests in contrib which are failing, but only do so on the build machine. |