#clojure logs

2008-06-21

06:34Lau_of_DKHey guys
10:04Lau_of_DKAnybody here familiar with a good Java FTP lib ?
10:13Lau_of_DKI'm going with sun.net.ftp.FtpClient - If anybody is aware of a better alternative for simple up/downloads, then let me know
12:38blackdogrhickey, something that may interest you http://www.malhar.net/sriram/kilim/
13:32Lau_of_DKblackdog, that looks pretty sweet - its supposed to outperform Javas native threading?
13:35blackdogdidn't really look into it , but i listened to rhickey concurrency video recently where he was asked about such things
13:39Lau_of_DKOne thing that I was a little onsure of, is that are we supposed to used threading via send-off and such, or is it nessacary to get comfortable with Java Thread. lib ?
13:39rhickeyblackdog: saw that, thanks
13:59Lau_of_DKIO Writers seem to default to writing in the home directory on Linux - Is there a global I can use to redirect to the folder the .clj file is executed from that will work on mac/win/nix ?
14:01blackdog(defn getCwd
14:01blackdog "get current working directory"
14:01blackdog [] (. System getProperty "user.dir"))
14:01blackdogthat's where the program is started in
14:02blackdogi move myself into my app dir first before firing up java
14:03blackdogor you could do an explicit (. System getenv key)) and get a working dir from an environement variable
14:03blackdogthere may be other ways
14:04Lau_of_DKThanks blackdog, good tips :)
14:05blackdogyw
15:04Lau_of_DKrhickey: Generally for starting single worker threads, it send-off the best way to go about it ?
15:05rhickeyif the threads don't block, send is better than send-off
15:05Lau_of_DKok - They dont. So there's really no reason to start using all of Javas .Thread functions for this type of job?
15:06rhickeyno, agents wrap all of that
15:06Lau_of_DKsweet - Thanks
15:21Lau_of_DKI've got a question about the primitive support
15:22Lau_of_DKbyte[] a = new byte[1024]
15:22Lau_of_DK(make-array byte 10240)
15:22Lau_of_DKThats how I would have imagined the port, but it throws a class erorr
15:22Lau_of_DKerror
15:22Lau_of_DKwhy ?
15:24rhickeythe class corresponding to byte is Byte.TYPE
15:25Lau_of_DKOk thats works. If I didnt have you to ask - Where would I find this info? I read through the Java-Interop section of Clojure.com
15:49Lau_of_DKrhickey: Ok thats works. If I didnt have you to ask - Where would I find this info? I read through the Java-Interop section of Clojure.com
16:49lisppaste8Lau_of_DK pasted "FtpUpload Corruption" at http://paste.lisp.org/display/62622
16:50Lau_of_DKGents - This function (upload-file) sorta works. It tries to upload the file, it uploads the correct amount of bytes, but the data is throughly corrupted. Any input is very welcomed! :)
16:51Chouser_are you uploading a binary file? you might trying using binary mode.
16:53Lau_of_DKhehe
16:53Lau_of_DKgimme 1 sec
16:58Lau_of_DKChouser: Im sure you're right, it has to do with switching to binary, unfortunately this old sun lib is causing alot of trouble, so now Im getting array out of bounds error, will take some time to sort out
16:58Lau_of_DKbut thanks for lending me your sharp eyes
17:07Chouser_so if I were, hypothetically, compiling Clojure to JavaScript, what would a quoted symbol look like? Would I need a new class Symbol?
17:07lisppaste8Lau_of_DK annotated #62622 with "Clojure bug?" at http://paste.lisp.org/display/62622#1
17:08Lau_of_DKOk, I'd say that the upload procedure is pretty textbook, switching to binary throws index out of bounds exception - is this a clojure bug?
17:08Lau_of_DK(def bytes (. in read buffer)) & (. out write buffer 0 bytes), shouldnt produce this error unless either read or write was failing ?
17:12Chouser_when will that loop terminate?
17:12Lau_of_DKthe the reader returns a negative value
17:12Lau_of_DKEOF = -1
17:12Chouser_which you then add to counter, right?
17:13Lau_of_DK1 sec
17:13Lau_of_DKit was supposed to say "bytes"
17:14Lau_of_DKok, except for a picture quality issue, the upload is working now
17:14Lau_of_DKSorry about the level of stupidity introduced here tonight :)
17:15Chouser_no need to be ashamed of bugs in your code. We all write bugs.
17:15Chouser_In any given example, though, the chances of the bug being in clojure are pretty low.
17:15Lau_of_DKWhy ?
17:16Chouser_because there are lots of people beating on clojure from lots of different angles, compared to how many people have been beating on any one example any of us may come up with.
17:17Lau_of_DKSure - I looked through the Googlegroups and I wondered how the guys who posted Clojure bugs (that Rich ended up fixing) could be so confident that it was bugs, so I figured - I'll act confident :)
17:17Chouser_heh. well, that's one approach...
17:18Lau_of_DKwhich I'll change, but anyway, I've actually made a small image manipulation program now, that uploads the resulting files on an ftp server, thats progress
17:22Chouser_cool!
17:24Chouser_If you think you've found a bug in Clojure, but you want to be sure, just try to isolate it yourself -- try to track down the simplest thing that will trigger the bug. You'll either produce a nice compact bug report for Rich to look at, or find the bug in your own code.
17:24Chouser_I generally end up with the latter result. :-)
17:24Lau_of_DKThats definately the way to go - And I need some practice on isolating stuff
22:02jcriteshey
22:03jcriteshow do I call a static function?
22:03jcritesI tried...
22:03jcrites(. java.net.InetAddress getAllByName "localhost")
22:03jcritesoh!
22:03jcritesI got it.
22:03jcrites(. java.net.InetAddress (getAllByName "localhost"))
22:07dudleyfjcrites: or
22:07dudleyf(.getAllByName java.net.InetAdress "localhost")
22:07jcriteshow can I print out the type contained in some Var?
22:08jcritesI'm trying to figure out how to process the result of that function call but don't know quite what type it is ;-)
22:09dudleyf(.getClass varname)
22:09dudleyfBut, that call returns a Java array
22:10jcriteswell an array has a class doesn't it ? :-(
22:10jcriteshmmm
22:10jcritessomething isn't working right ?
22:11jcritesI did this:
22:11jcrites(def a (. java.net.InetAddress (getAllByName "localhost")) )
22:11jcritesnow I'm trying:
22:11jcrites(. a toString) or (.toString a)
22:11jcritesI don't expect it to return a useful value, but I'm getting an error saying:
22:11jcritesUnable to resolve symbol toString in this context
22:12jcriteshmmm, maybe Java arrays actually aren't Object....
22:12dudleyfI get "[Ljava.net.InetAddress;@1bbbafc"
22:12dudleyfWhich is what I would expect
22:13dudleyfYou can use (vec a) to get a Clojure vector from that array
22:13jcritesuser=> (def a (. java.net.InetAddress (getAllByName "localhost")) ) #<Var: user/a>
22:13jcritesuser=> (.toString a) java.lang.Exception: Unable to resolve symbol: .toString in this context clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:13: Unable to resolve symbol: .toString in this context
22:13jcritesam I doing something wrong?
22:13jcritesohhh
22:13jcritesvec is definitely in a later version than I am using
22:14jcritesmaybe I just need to upgrade?
22:14dudleyfDefinitely
22:15dudleyfYou may have a version before the (.javaMethod) syntax was legal
22:16jcritesbut (. a toString) should still work?
22:16jcritesno matching field found: toString
22:16jcritesI will just upgrade; no use spending time debugging this before doing that
22:16dudleyfAbsolutely right.
22:21jcritesinteresting
22:21jcritesdoes def do something different in the new version?
22:21jcritesnow it says #'user/a rather than something about var
22:21jcriteshey, is there a page describing Clojure shorthand syntax?
22:21jcritesI remember someone showing me a shortcut fn syntax
22:24dudleyfjcrites: http://clojure.org/reader
22:25dudleyfAnd I think Vars just print differently
22:25jcritesah ok :-) thanks for your help!
22:26dudleyfjcrites: anytime
22:28jcrites(#(+ %1 %2) 1 2)
22:28jcrites3
22:28jcritesI love Clojure :D
22:28jcritessuch short nice syntax, such library elegance