#clojure log - Aug 08 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

4:41 Chouser: Huh. My clojure entry made it to trial 6 of the lighting round: http://icfpcontest.org/results/lightning/results-by-score-Lightning-6.html

4:42 It was completely blind. :-/

4:42 rhickey: Chouser: neat! I didn't know if anyone found time to compete

4:43 Chouser: Yeah, I barely did. Lotsa chores to do that weekend too, so I never got to the obstacle avoidance stuff.

4:44 rhickey: yeah - competing means a lost weekend...

4:44 Chouser: and I submitted what may be the ugliest clojure code ever.

4:44 rhickey: ah

5:45 hoeck: wow, reflection + macros + clojure proxy rocks!

5:46 just implemented a macro that implements to an interface using an existing object, this way i can implement a PersistentVector on-the-fly and change eg. its equal semanitcs

5:47 semantics

5:49 rhickey: hoeck: hmm... the interface is one already supported by the object?

5:50 hoeck: yes, well, I'd like to overwrite a vectors equal method

5:51 rhickey: hoeck: to do what instead?

5:53 hoeck: to be able to define 'tuples' where, for example, only the first item is responsible for equality to other tuples

6:44 mattrepl: what's an efficient way to construct a 2d Java primitive array? specifically, I'm trying to construct Jama.Matrix objects from float[][] types

6:45 blackdog: to-array-2d ?

6:46 actually make-array takes dimensions

6:47 rhickey: (make-array Float/TYPE 200 200)

6:48 Chouser: So for what it's worth, here's the code I submitted: http://n01se.net/paste/j4Cb

6:48 Nobody should use any of that as an example of how to write Clojure!

6:48 Specifically, I think I'm doing Bad Things with flying reads and dosync.

6:48 mattrepl: I was hoping for something closer to a literal, though I know that's explicitly not supported. to-array-2d only gives Objects, into-array-2d doesn't do primitives. ok, make-array and iterative fill it is

6:50 what I really could use is make-array to support primitives or float-array to support higher dimensions

6:50 rhickey: mattrepl: define (init-array [type init-fn & dims] ...) where init-fn is a function of the number of dims, should be pretty useful

6:51 mattrepl: that make-array call makes a primitive float[][] array

6:53 mattrepl: oh, good. sorry, I missed the last sentence of the description

7:16 lisppaste8: rhickey pasted "init-array macro" at http://paste.lisp.org/display/65023

7:44 rhickey: mattrepl: you missed: "init-array macro" at http://paste.lisp.org/display/65023

7:44 mattrepl: rhickey: thanks

9:26 cemerick: uytrewsfgtyrew2eryp[]iuytdfgp;['[hj]\\][]\\]['

9:26 \\

10:04 rhickey: any reason why there's no ArraySeq_byte?

11:21 Chouser: rhickey: "Out of the Tar Pit" is very interesting.

11:21 drewr: I've been reading it too.

11:22 rhickey: Chouser: I thought so - it inspired me to 'go all the way' with FP in Clojure

11:22 Chouser: I'm curious about Clojure's "let" in light of "Complexity caused by Control"

11:22 rhickey: I took a different route with state, but share the philosophy of minimizing it

11:23 Chouser: let being a multi-expression block?

11:23 Chouser: If let bound in parallel, there would be no implicity ordering.

11:24 loop/recur are parallel

11:24 rhickey: Chouser: you'd just nest lets, then reinvent let*

11:25 Chouser: yes, but you'd only nest lets when you needed to (since it's annoying and a pain), which would be a hint to the (human) reader that there is actually a dependent expression.

11:26 rhickey: If you don't reuse names it's equally clear

11:27 Chouser: to use the paper's example, (let [a (+ b 3) c (+ d 2) e (* 4 f)]) currently implies an order, and you have to look carefully to see that e is arbitrarily at the end instead of somewhere else.

11:28 however if let bound in parallel, e *couldn't* depend on a or c, and the order would be guaranteed arbitrary.

11:28 A nested let would be a clue that there really is a dependency and that the order of the nesting matters.

11:29 rhickey: I don't think it's a big deal - the real deal is having some sort of declarative programming option, like an embedded prolog

11:30 Chouser: ok, fair enough. I'll be curious to see what you come up with there. :-)

11:30 rhickey: no one will tolerate nested lets when they need them, so you'll have to have let*, and then most people will use that by default

11:30 kotarak: to be honest: I also like more the compiler to figure out, whether something depends on something else or not. Like CPUs do with their pipelines.

11:31 Chouser: rhickey: yeah, you're probably right. let is very convenient as it is.

11:32 rhickey: It was more important to me to have only one let

11:32 Chouser: I'm not at all deeply invested in a parallel let, just thought I'd make an argument from the paper. Thanks for engaging me. :-)

11:34 rhickey: np, I think the paper is really good provocation, though I don't think they have all the answers

11:42 fanda_: hello all!

11:42 rhickey: hi

11:43 fanda_: could you please help me? I am trying to add metadata to some object

11:43 what's the syntax for it?

11:43 can I do: (def x 5)

11:43 and then add any metadata to 'x'?

11:43 Chouser: maybe a keyword to separate a single let into batches: (let [a 1 b 2 --batch-- c (+ a b)] ...)

11:44 haha. nevermind. ;-)

11:44 kotarak: fanda_: you can do: (def #^{:some :metadata} x 5)

11:45 fanda_: and how do I get this metadata back?

11:45 - meaning read it from 'x'?

11:45 Chouser: that's metadata on the symbol x by the way, not on the value 5

11:45 ^#'x

11:45 fanda_: i see!

11:46 Chouser: which is short for (meta (var x))

11:46 fanda_: thanks! there was my error

11:59 i saw a note about prolog implementation

11:59 for inspiration, try:

12:00 http://en.wikipedia.org/wiki/Unification

12:00 and example:

12:00 http://www.newlisp.org/downloads/newlisp_manual.html#unify

12:00 :-)

12:30 kotarak: is there a vim user around, who volunteer as a beta tester? I currently work on "Chimp", (Clojure with Limp, but Cimp looked strange..) and I'd like to hear a second opinion before releasing it.

12:31 Chouser: I vim.

12:31 kotarak: you vim? :) Would you be interested?

12:31 Chouser: I dunno what Limp is, but I'll try whatever you've got.

12:32 kotarak: Put the cursor in a sexp in vim, \es et voila. sexp evaluated in Clojure running in a screen.

12:33 Chouser: sounds good to me.

12:34 kotarak: Ok. I'll put it together. Please let me know your impressions.

12:35 Chouser: I guess I do that now, but I use the mouse to grab and drop the expression into a rlwrap-ed repl.

12:35 so a key sequence would be nice. :-)

12:36 kotarak: Up to now there are actually three: evalblock, eval-inner-sexp, eval-top-sexp

12:37 The namespaces are automatically changed based on (in-ns) in the file.

12:37 Chouser: hm! interesting.

12:37 kotarak: Heuristic: in-ns there, use that one, no in-ns, use 'user

12:37 So will be probably overrideable

12:37 Chouser: you built the whole thing, or are you using some existing framework?

12:38 kotarak: I used ideas from VILisp and Limp: run a screen and put some glue around it. It is basically independent from Clojure. It would equally work well with Python or Ruby....

12:39 VILisp uses some Perl magic, I like the screen solution more, and Limp is too complicated for my taste, too much mentions of SBCL

12:41 Chouser: screen means this probably won't work out of the box on Windows, right?

12:42 kotarak: oerks. Yeah. One would need Cygwin. I have no idea how to do this natively on Windows. Sorry.

12:42 Chouser: no worries, I don't use Windows. Just pondering aloud.

12:43 kotarak: I used it today at work. So with Cygwin it works. But a native version would be better.

12:44 And it's one-way. No feedback to Vim.

12:45 Chouser: hm. well, sounds better than what I'm doing now, anyway.

12:46 you launch screen from vim, or vice-versa? Or set up the communication some other way?

12:46 sorry, if you're writing all this up somewhere I'll leave you alone and read it when you're done.

12:47 kotarak: Start vim and screen separately. Screen tells you the id. On first evaluation request you have to supply the id. This then saved for further calls.

12:47 Communication works via temporary file.

12:47 What you start in the screen is up to you: Clojure, Python, Ruby, whatever.

12:47 Chouser: sounds interesting.

12:48 kotarak: ftplugin in Vim can be adapted to different languages, eg. recognizing Sexp for Clojure etc.

12:48 Chouser: sure.

12:49 kotarak: And manual use in the screen is also possible in parallel. An advantage over pipe solutions

12:49 Chouser: I had thought about trying to do something like having vim post code via http to a tcp-port repl running in clojure which could run it and spit back the results.

12:51 kotarak: The problems I had with something like that is: a) the response you have to handle, b) you probably need Perled or Pythoned vim (is this possible with VimL)

12:51 Chouser: that, and I'm too lazy to try. ;-)

12:52 kotarak: :)

12:52 Chouser: I keep hoping to make the jump to netbeans + enclojure + jvi, but it just hasn't happened yet.

12:52 I'd miss vim, but not viml.

12:52 kotarak: I already came back again. Netbeans and Eclipse and all these programs are the huuuge. :|

12:53 I'd like to have a mixture between Emacs and Vim: Vim with emacs-style (but Scheme (or Clojure ;)) programming

12:53 Chouser: yes they are, but vim feels like such a hack.

12:54 blackdog: if anyone's interested i have done a little work on jedit to integrate clojure

12:54 Chouser: yes! that's what I want too.

12:54 blackdog: jedit runs at about 63mb for me, not too big

12:54 Chouser: you don't think enclojure + jvi == emacs + clojure?

12:55 blackdog: any vi keybindings? :-)

12:55 blackdog: oh :/

12:56 Chouser: sorry, that sounded more snarky than I meant it to be.

12:56 blackdog: no i didn't take it snarkylike :)

12:56 Chouser: I don't know anything about jedit. Can I customize key bindings easily?

12:56 blackdog: yes, it's a very full featured editor,

12:57 kotarak: Chouser: I don't know, I have some Vim specific stuff floating around. It's sooo hard to leave that behind. (I tried emacs again, this week, but emacs + viper just doesn't catch it)

12:58 blackdog: i have mostly got a repl running but it's buggy, and syntax hightlighting and i ripped out the browser from enclojure

12:58 but it's only a partially done been meaning to get back to it

13:00 the problem i have with netbeans is the enforced project structures, i like jedit cos it's an editor first, with plugins, but it doesn't dictate

13:00 Chouser: kotarak: last time I tried emacs (my 2nd or 3rd attempt) I nearly made it -- I had email set up, basic navigation learned, etc, but ended up defeated by emacs/xemacs incompatibilities and lack of support for a code search tool that was pretty much a requirement.

13:01 blackdog: hm...

13:03 kotarak: chouser: the time I last used it (1998), it took hours to start-up. For programming that's not a problem. But I started to work as a sysadmin to finance my studies and had to edit little files all the day. emacs... baah. So I used vi. And shortly thereafter I always got confused <Esc> in emacs, <C-x><C-s> in vi.... So I totally switched to vim. And now, after 10years of hardwiring my finger nerves, it's hard to switch.....

13:05 Chouser: well, we could always write a new editor in clojure that feels like vim.

13:06 kotarak: o.O That's looooot of work. ... Ok. One could restrict the work to the 3% of Vim one actually uses...

13:06 Chouser: yeah, you're supposed to be laughing by now.

13:07 kotarak: hahahahahhahahahaha

13:07 Chouser: that's better, thanks.

13:08 http://activestate.com/Products/komodo_ide/feature_showcase.mhtml

13:08 *sigh*

13:09 how can there be so many editors and yet none just right?

13:09 arj: ehm emacs is not right? :)

13:09 Chouser: I guess that's pretty much how I feel about languages too, although Clojure has improved my mood a bit.

13:09 arj: elisp. enough said. ;-)

13:11 kotarak: That's what I don't like with such project like Eclipse or Netbeans: (from the above link) "interfaces with Perforce, SVN and something else", but eg. not hg. So to write a plugin you first have to grok a 100-pages manual, understand 65 classes and ... latest at that point I loose interest....

13:12 Chouser: yeah. :-/ I was hoping that being able to write my editor extensions in Clojure (for NetBeans) would help reduce that pain.

13:32 kotarak: Chouser: ok. Email is out. I'd like to hear your feedback. But now I go to bed. It's approaching midnight.

13:32 Chouser: kotarak: thanks. sleep well!

13:32 kotarak: Chouser: thanks, bye

14:27 drewr: Dang, someone 1-starred my message today on the clojure group.

14:28 I was hoping for some kind of discussion.

14:32 (Hoping for list discussion, not IRC. :-))

14:36 Chouser: I'm already implementing it for my files (that I've changed).

14:36 But I feel I have that freedom because nobody's using my contrib contributions.

14:36 drewr: Do you think my message made sense?

14:37 Chouser: yep, although "lock step" isn't a real possibility.

14:37 drewr: Sure it is.

14:38 Chouser: not for both HEADs.

14:38 drewr: Maybe not with HEAD, but the latest working revision.

14:38 Chouser: gotta entertain the kids. back in a while.

Logging service provided by n01se.net