#clojure logs

2008-07-01

09:40wlrrhickey:apropos your recent identity/entity essay, this may interest you: http://arxiv.org/pdf/0806.4746
09:41Lau_of_DKwlr, where is that essay ?
09:41notyouravgjoelthe jvm supports os level threads, and thus clojure will use all of my cores, correct?
09:45wlrLau_of_DK: http://clojure.org/state
09:47spacebatnotyouravgjoel: yes it can
09:49Lau_of_DKwlr, thanks
10:21Lau_of_DKAnybody here working with Chousers zip-filter-xml lib ?
12:20JamesIryGang, if any of you happen to be in LA, Orange County, or San Diego I've formed a group called Southern California Functional Porgrammers: http://socalfp.org.
13:13rhickeyAnyone ever gotten Shoal or Jxta to work with IKVM? Trying to do some Clojure/.Net interop
13:17kotarakThese numbers in the compiler messages... Are these line numbers? Eg. monad.clj:906, but this file has only 70 lines...
13:18rhickeythere are some instances where you'll get a line number from a macro
13:19rhickeycan you paste a small reproducing case?
13:19cemerickrhickey: No, but what problems are you running into?
13:20rhickeyffailla can provide some details of the problem
13:22kotarakrhickey: the problem is a wrong defmethod call: (defmethod monad/bind [m k] (cond (is-ok? m) (k m) (is-nok? m) m)) It's missing the dispatch value.
13:30rhickeykotarak: when I put these 2 lines in a clj file and load, I get an error on line 2:
13:30rhickey(defmulti bind identity)
13:30rhickey(defmethod bind [m k] (cond (is-ok? m) (k m) (is-nok? m) m))
13:30kotarakI get one on line 906.
13:30kotarakFrom the REPL: clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:906: Unable to resolve symbol: m in this context
13:30rhickeyjust those 2 lines in a file?
13:31rhickeywhat version of Clojure?
13:31kotarakI'll try. Just a second
13:31kotarak20080612 zip
13:33rhickeyrev 909, on 6/17, improved things in this area
13:34ffaillacemerick: I have compiled jxta to IL via IKVM and ported the DiscoveryClient/DiscoveryServer Java tutorial to .NET as a test. It seems that my discovery callback never gets executed that was wired up with DiscoveryService.addDicoveryListener. The client and server apps appear to be running with out error, but the communication between the two does not appear to function. The Java example works fine.
13:35cemerickffailla: What version of ikvm are you using?
13:36kotarakrhickey: ok. Will try the svn version.
13:36Lau_of_DKChouser: You in the house tonight ?
13:37Chouser_Lau_of_DK: I am.
13:41ffaillacemerick: ikvm-0.36.0.11
13:41pjb3In Clojure terminology, is there a difference between a Var and a Symbol?
13:41rhickeypjb3: definitely
13:42rhickeya symbol is just a name
13:42rhickeylike a string except it has 2 parts, ns and name
13:43cemerickffailla: the first thing I'd do is compile the java example to IL, and bootstrap that up to make sure the whole stack works.
13:43ffaillacmerick: will do... i'll let you knwo how it turns out
13:43ffaillathx
13:43rhickeya var is a reference
13:43cemerickno prob
13:44pjb3rhickey, so when you do (def x) you are assigning a Var to the Symbol x?
13:44rhickeythere is no storage in a symbol, it is an immutable value, so no such thing as assigning to it
13:44rhickeywe names vars in our programs using symbols
13:45rhickeyso (def x) says create a var with the name x in the current namespace
13:46rhickeywe could use the same symbol x to refer to something else in a different ns
13:46rhickeysymbols don't have a 1:1 relationship with places
13:47rhickeypjb3: do you know CL?
13:47pjb3rhickey: not really, coming from more of a Java/Ruby background
13:48Chouser_so "symbol" is almost synonymous with "identifier"?
13:49rhickeysymbols can be used as identifiers, and are in program's code-as-data
13:49rhickeywhen you type a symbol into the repl, the evaluator tries to find the var associated with it
13:49pjb3gotta go, be back later
13:49rhickeyok
13:51Chouser_I always flail a bit trying to talk about clojure code. I keep reaching for the word "variable" which is clearly wrong, and am never sure what to say instead.
13:53kotarak"naming" maybe?
13:57cemerickrhickey: (conj (hash-set) 5) => #{5}, but (conj (sorted-set) 5) => IllegalArgumentException
13:57rhickeythere's no substitute for owning up to symbols being first class objects, vs just names in program text...
13:58cemerickThat's in svn r927.
13:59rhickeyclean? what does (sorted-set) return?
14:01Chouser_I just got the same error on r926. ant clean and rebuild fixed it.
14:01rhickeyChouser: I've taken to calling let-bound locals just locals
14:01cemerickYeah, I cleaned, updated, built. (sorted-set) => {}
14:01cemerickI'll try another wash and rinse. :-P
14:01rhickeyuser=> (sorted-set)
14:01rhickey#{}
14:02Chouser_cemerick: specifically it was java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
14:02cemerickChouser_: Yeah, that's what I'm getting too.
14:02Chouser_rhickey: "locals", nice.
14:02rhickeyvars are much trickier, people have such presumptions
14:04Chouser_a global var pretty much is a global variable, isn't it? You can point it at a new value anytime you want, you're just not supposed to.
14:05rhickeyit is until you distinguish def from set! and binding
14:05Chouser_binding them is a bit different, but elisp and perl do that, so there's some reference for it.
14:05rhickeyCL too
14:06Chouser_perl's such an odd beast. it only had globals and dynamically-bound variables for a while, lexicals came later. Also has closures, but no named function arguments.
14:07cemerickwow, that was way harder than it should have been -- I cleaned 3x -- ended up checking out anew, all's well now.
14:07Chouser_rhickey: really? I don't see *too* much code on the groups with misused def
14:08rhickeynot among the more experienced
14:08rhickeybut re-def-ing is many people's first inclination
14:08Chouser_is there some reason you allow def inside functions?
14:09rhickeySure, you might have a program that writes a program
14:09Chouser_surely you could detect it at compile time and error out. ...would stop it quick.
14:09rhickeydynamically
14:09rhickeystop redef? how will we fix bugs?
14:10rhickeyor just non-top redef?
14:11kotarakI have my math point of view: a definition is something special, long lasting. Eg. N is the set of natural numbers. This won't change (in a given context). Namings are local to eg. a proof. Let f_x be the density of x blablabla. The (def) is something important, which won't change. And (let) gives local namings for a limited context.
14:11Chouser_no, I just meant when you see a def that's not at the top level of the expr
14:11Chouser_but your point about building a program dynamically stands.
14:12rhickeykotarak: that was the idea, defs are durable, lets transient, set!s dangerous and not allowed on globals
14:12rhickeybut people see the effect of def and consider it assignment
14:13rhickeyalso, one tends to re-def dummy var names in the repl
14:13Chouser_hm, although allowing it via (eval '(def foo 5)) would still pass the "top-level" test and would be weird enough to perhaps discourage casual use.
14:13rhickeymost code shouldn't ever eval
14:14Chouser_most code should also never call def from inside a function, right? so it lines up?
14:14Chouser_I'm just musing here. Don't let me keep you from something important. ;-)
14:14kotarakOCaml got me cured of re-defing things. However one these it also in introductory code: (define *some-state* ...)
14:14rhickeyno, when I call evel I think "there must be a better way"
14:14rhickeyeval
14:15kotaraks/these/sees/
14:16rhickeyin OCaml are subsequent defines (with the same name) different bindings?
14:17kotarakJust let me check, but if remember correctly, your are not allowed to re-def things. Doing this like let x = f 5 in let x = g x in let x = h x in x are always "new" x's.
14:18kotarakHmm... Ok. you can re-def.
14:19rhickeyright but def x 5, write code using x, def x 6, code using x still sees 5 unless recompiled?
14:20kotarakYes. Eg.: let x = 5;; let f () = x;; let x = 6;; f ();; will give 5.
14:31kotarakHmmm. Is it bad to modify the meta-data of a "foreign" object?
14:32rhickeywhat do you mean by foreign?
14:33kotarakI'm a library and the user passed in
14:33kotarakoops.
14:34kotarakthe user passes in something. Then I will most likely use with-meta, I suppose. Then I get a copy.
14:35rhickeyyou can merge metadata safely using namespace-qualified symbols as keys - `my-key will become 'my-ns/my-key
14:36kotarako.O Uh? Nice.
14:37rhickeyalso note, recently symbols became fns of maps like keywords (`my-key ^blah) works
15:31kotarakhmmm..., x and y not def'd, I expect ^x = nil and ^y = {:Foo :Bar} and x and y = "Hello": (def x "Hello") (def y (with-meta x (assoc ^x :Foo :Bar))), but I get an IncompatibleClassChangeError. Where is my mistake?
15:33StartsWithKi'm trying to clojure applet, so i was reading this http://is.gd/JRW and using gen-and-save-class created my class that extends clojureapplet class http://pastebin.com/d7efff553 but i'm still geting this error http://pastebin.com/d48033846
15:33StartsWithKcan someone tell me what that means
15:33StartsWithK*to make
15:36rhickeykotarak: strings can't have metadata
15:37kotarak-.- Ok.
15:37rhickeyStartsWithK: ClojureApplet is not public
15:42StartsWithKrhickey, tnx that was it :) so just a quick question http://pastebin.com/d66048d8c means that i have to sign my applet?
15:43StartsWithKand clojure.jar hmm..
15:44kotarakdoh, "symbols and collections support metadata". Those who can read shall have a clear advantage.
15:44rhickeyStartsWithK: it may not work even when signed - Clojure needs a classloader which may be disallowed, but that story could be different with the latest plugin stuff
15:45StartsWithKi use JNLPAppletLaucher, and on that thread he used web start too, so i was thinking it sould work as applet if it can be made to work as web start application
15:46StartsWithKhttps://applet-launcher.dev.java.net/
15:46rhickeyforgot he did that, looks promising
15:47blackdogStartsWithK, did you try without creating a main class? I was hoping that it would pick up user.clj auto, but it doesn't seem to want to work
15:48StartsWithKblackdog, i don't know how to make applet run without some class extendind javax.swing.JApplet or java.awt.Applet
15:48blackdogduh, i'm getting mixed up with webstart
15:48StartsWithKi don't think it can be done any other way
15:49blackdogi was trying to run it auto from a jar,
15:49blackdogwithout a main class
15:50StartsWithKi don't think that could work, jnlp needs entrypoint class
15:50blackdogyea i was giving it a stub main,
15:51StartsWithKi'm using this http://pastebin.com/m5e817f05 as applet launcher
15:51blackdogbut user.clj still didn't kickj in
15:51blackdogthanks that's useful
15:51blackdogapparently with the new update n jdk 6, applet and webstart stuff is unified to a degree
15:52blackdogyou can drag an applet of the page and have it run stand alone (apparently)
15:52StartsWithKyes, and my line of thinkis is - if web start can launch clojure then applet should too
15:52StartsWithKill have to run my applet first :)
15:53StartsWithKand i think there is some option for that, i'm not sure, still reading the docs
15:53StartsWithKbut i found you can force it to use separate jvm, maybe that is it
15:53blackdogi thought that was one of the innovations in updaten
15:54blackdogupdateN (or whatever it's called)
15:54StartsWithKi think it was update5 or 10..
15:56blackdogi hope sun don't fu on the new applet stuff it would be nice to write everything in clojure from back to front
15:56StartsWithKyes, i would like to run my jogl apps as applets :)
15:56StartsWithKhttps://jdk6.dev.java.net/plugin2/jnlp/
15:56blackdogi was suprised to see applet usage on facebook, but that's a hopeful sign
15:57StartsWithKi tested it with some demos from jogl and it runs really nice and fast.
16:10StartsWithKok, i certified clojure.jar and my helloworld.jar as show in http://is.gd/JTG
16:11StartsWithKit no longer is bothering me with security, it just asked do i trust this untrusted certificate
16:11blackdognice
16:11StartsWithKnow i have this http://pastebin.com/m5e1ebdeb
16:12StartsWithKbut that looks like i just don't know how to use genclass
16:12Chouser_no, you're doing it right.
16:13Chouser_you have a (refer) inside your genclass namespace, right?
16:13Chouser_You either have to do a bunch of :exclude, :only, or :rename.
16:13StartsWithKyes
16:14Chouser_or skip the refer entirely and use clojure/defn and such everywhere.
16:14StartsWithKok ill try that (this is how it looks at the moment http://pastebin.com/m43685eff)
16:18Chouser_it's pretty annoying, because either way you generally screw up and leave something out of your :exclude or :only list, and just have to try again, note the exception, and add the name to the list.
16:18Chouser_on the other hand, it's hard to think of how it ought to work instead.
16:19rhickeyone possibility is to have all of the 'method' names be munged in some fixed way
16:20Chouser_another would be if you could define names in a namespace without having to be in that namespace. (defn classns/init [this] ...)
16:22rhickeysince most namespaces will be long com.blah.ClassName seems like a -method suffix or m- prefix would be shorter
16:22StartsWithKchanget it to http://pastebin.com/d37cd7943 but now i get "unable to resolve clasname : Graphics"
16:24Chouser_yeah, although with namespace aliasing that problem would go away too.
16:25Chouser_hm, with munging you could have a handy macro to do the right munging for you. (defmethod foo [this]...)
16:25Chouser_well, no defmethod, but something. def-genclass-method. ;-)
16:26rhickeydefhandler?
16:26Chouser_yeah
16:27StartsWithKhow will that help with the need to use clojure/let and others?
16:27Chouser_that way the actual munging could be entirely internal to clojure and not show up in the user's code at all.
16:28rhickeyand with munged names you could (refer 'clojure) without conflicts
16:29Chouser_I suppose the names manually given to genclass would remain unmunged? :factory, :state, etc?
16:30rhickeyright
16:30Chouser_yeah, this would be a lot better than how it is now.
16:32StartsWithKok, i think it will work.. now i get no matching field found: getSize
16:32StartsWithKso applet must be running
16:32Chouser_defhandler could even add the "this" arg for you, like proxy does
16:33Chouser_hm, except some of the unmunged names probably still take "this", which might be confusing
16:33Chouser_ha!
16:38Chouser_so you can define .foo, and you can refer to it, but you can't call it. in the context of a genclass ns, though, I suppose you could do (.foo this ...) and have it refer to the .foo you just def'ed.
17:49StartsWithKit was silly mistake on my part Graphics has no getSize method, JApplet has it.
17:49StartsWithKso (.getSize this) works
17:49StartsWithKand i can say applet works :)
17:50Chouser_very cool! how hard was it to sign the various bits?
17:50Chouser_you should write it up and send it to the google group.
17:50blackdogii'm interested :)
17:50StartsWithKi will do it sometime tomorow, ill try to find ant tasks to automate signing the jars.
17:51StartsWithKso for now i can only say it works on jre 1.6_05 under xp
17:52Chouser_if you've got it up somewhere I can point linux with jre 1.6_06 at it.
17:53StartsWithKfor now i think it should be at http://rekram.homelinux/neman/neman.html
17:53Chouser_is there a .net or .org in there somewhere?
17:54StartsWithKuff sorry, jer org
17:54StartsWithK*yes
17:54Chouser_Publisher: sun microsystems
17:54blackdogi get the blank gray applet box :)
17:55StartsWithKhmm
17:55blackdognot asking me for anything
17:55StartsWithKcan you open java console to see the output?
17:55Chouser_ah, another auth box for published by K-something. ;-)
17:55StartsWithKthats me
17:55Chouser_yeah, I figured. and now a grey box. :-(
17:55StartsWithKit could take some time, i included jogl jars inthere too
17:55blackdogi;m on openjdk ubuntu here
17:56blackdogok maybe it's stilldownloading here
17:56StartsWithKhmm.. i used openjdk on arch (64bit) and it didn't work for jogl textures..
17:56blackdogi'm on 64 too
17:56blackdog:/
17:56blackdogno worries
17:57StartsWithKicedtea6 worked with applets, but didn't display jogl correctly.. ill try it with 1.7
17:58blackdogwhere do i find the java console in ff3
17:58StartsWithKunder xp in control panel there is java icon, i checked java console from there
17:59StartsWithKbut i don't know under linux :/
17:59StartsWithKhttp://www.java.com/en/download/help/5000021200.xml
17:59blackdogmy java is enabled but i'm not seeing any console optipon maybe it's another extension or so
18:00Chouser_did it open a new window?
18:01blackdogno, i'm getting the gray box and nothing else right now, i'll check my install
18:01StartsWithKi can say that it work on another xp box with jre 1.6_06
18:07StartsWithKblackdog, if dcc is working on freenode i can send you the files so you can try localy?
18:07blackdogsure, i'll give it a try, but i think it's my setup
18:08blackdogwoops
18:08blackdogcan you do that again
18:10StartsWithKill send you the sources too, but they are just a mess at the moment, there is a ant task "ant dist-helloworld-applet"
18:11StartsWithKand you should sign helloworld after each modification
18:11blackdogok, no joy locally either
18:12blackdogbut i seems ubuntu is carrying a jdk7 gck web plugin, so i don't think it's entirely standard :)
18:13blackdoggcj
18:13StartsWithKim just happy it works under xp :) it it will not be fun to work with applets if i can't test them on my box
18:13Chouser_Hello World
18:14blackdogfor real,
18:14Chouser_It just worked for me here.
18:14blackdoganything to stop having to write flash :)
18:14StartsWithKChouser_, under linux?
18:14Chouser_linux ubuntu java 6
18:14StartsWithKcool
18:14StartsWithKthats 32bit?
18:15blackdogi'm 64bit
18:15Chouser_something about it doesn't like my window manager -- I think that's why I was getting a new window popping up.
18:15Chouser_but in a "normal" window manager, it worked just fine.
18:15StartsWithK:)
18:16Chouser_yes, I believe I'm all 32 bit here (although probably on a 64 bit cpu)
18:17blackdogyea, i was a bit hasty with my install :/ should have kept it standard,
18:17blackdogthe worst thing i found was that the mem consumption of java is even worse than usual
18:18StartsWithKblackdog, i think standard jdk6 under 64bit linux can't display applets at all
18:18StartsWithKicedtea6 can
18:18blackdogso for my dev i use the 32 bit updateN under my login which works fine
18:19blackdogah, wonder if appletviewer works
18:19blackdogthe update n version
18:23blackdognopes
18:23blackdog ~/usr/jdk1.6.0_10/bin/appletviewer http://www.rekram.homelinux.org/neman/neman.html
18:23blackdogjava.security.AccessControlException: access denied (java.net.SocketPermission download.java.net connect,accept,resolve)
18:23StartsWithKyes i get that one too, but i can't say why
18:23blackdogmaybe appletviewer doesn't deal with the secirty stuff
18:23blackdogno worries
18:24blackdogthanks for the src,
18:24StartsWithKrandom link http://www.innovation.ch/java/security.html
18:25StartsWithKwith something about appletviewer and how to setup security
18:26blackdogk
21:02Chouser(defn f [] (let [x {:a #(...) :b #(...)}] ...))
21:03ChouserIs x built each time I call f?
21:03rhickeyyes, but the fns are not recompiled
21:04ChouserI'm thinking of use x like this instead of a (cond) ... is that bad idea for style or speed reasons?
21:06rhickeywhat that really is is case - value dispatch. The resulting dispatch, especially if there are many cases, will be much faster...
21:06rhickeybut - if you only dispatch once, you will have instantiated all the fns
21:07rhickeya fn compiles into a class that implements IFn
21:07ChouserI have 3 or 4 cases ... right, ok. probably not worth it just for speed.
21:07rhickeycreating an instance is a simple ctor that passes any closed-over values
21:07Chouserah, ok.
21:08Chousermy #() fns all close over args of f, so I can keep old instances. And then f will do a single lookup of x. So this is probably quite inefficient compared to a cond.
21:09Chouser...which is a pity because the hash look implementation is more terse.
21:10Chouserdoes java bytecode have goto?
21:10rhickeyI need to add case just so you don't have to (cond (= x :a) ... (= x :b) ...)
21:11rhickeyrecur is goto
21:11rhickeythere's also a table switch, for numeric cases
21:11Chouserah, yes. I looked that up once.
21:12Chouserhm, hash values are numeric... oh, sequential?
21:12rhickeyyou need to know the values at compile time
21:12Chouserah, never mind. I'm way off in the weeds now. I'll just go write my cond expression. :-)
21:12rhickeysort them
21:13rhickeycase would be (case x :a ... :b ...)
21:14Chouserthat would fully solve my terseness issue. I guess I can write a case macro that produces a cond
21:15Chouserwould you provide an else for case?
21:15rhickey(case x :a ... :b ... x ...)
21:16Chouseroh! nice.
21:16rhickeyCL has ecase where no match throws
21:17rhickeycase with no match should return nil
21:33slavayou can do interesting optimizations with a case macro
21:36Chouserslava: like what?
21:37slavawell, if your keys are integers, you can turn it into a binary search or a table switch, depending on how closely packed they are
21:37slavafor other types you can look at the hashcode, then only compare against the keys having that same hashcode modulo n, where n is the size of a dispatch table
21:39Chouserslava: if you have constant test values.
21:40slavayes
22:10lisppaste8Chouser pasted "naive case macro" at http://paste.lisp.org/display/63135
23:06sterlingmotd