#clojure log - Mar 01 2008

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

12:48 jgracin: rhickey: hi! do you use emacs to write Clojure code?

12:57 rhickey: yes, Aquamacs on OS X

12:57 not much of an emacs guy otherwise

13:04 jgracin: rhickey: The doc strings in boot.clj seem badly formatted, i.e. using tabs in the middle of sentences, line length exceeding 80 characters.

13:04 am I missing something or you just didn't pay too much attention to it.

13:05 I ask because maybe I'd re-format it, if you would be interested in the patch.

13:06 rhickey: some were done in IntelliJ, but no, right now there isn't a good plan for formatting

13:06 if you wanted to patch you'd need to get in and out quickly, on current rev

13:07 I'm not in there right now

13:08 jgracin: I'd first have to figure out the proper format. I haven't figured out how to meet all the criteria: it must look good in the code, it must look good extracted, it must not contain formatting instructions in the text.

13:10 rhickey: that's the problem, Clojure doesn't have the notion of a line-continuation character in string literals

13:11 jgracin: what's your position on using formatting tags, such as javadoc?

13:11 rhickey: they seem like a real pain

13:13 jgracin: I'm not too happy with those either. But OTOH, the docs become more useful if they are annotated. And eligible for automatic processing.

13:14 I'm not trying to persuade you. Just saying.

13:14 rhickey: I think the fact that things are in metadata is already a king of annotation

13:14 kind of

13:15 a problem right now is the mismatch of argnames and the docstrings, since one came from code and the other the web docs

13:19 jgracin: oh, another use case easily solved by annotations. :-)

13:19 maybe not so easily, but...

13:19 rhickey: how so?

13:24 jgracin: we are talking about the problem of maintaining consistency of argument names and positions between real argument lists and stuff described in the doc metadata, right?

13:25 in Clojure.

13:25 rhickey: right

13:26 right now there is the :arglists metadata which is from the actual code, and :doc which is separately authored, and may or may not need to refer to the args

13:27 and fns can be variadic

13:28 jgracin: if doc strings used symbolic references to argument names (e.g. @arg instead of just arg), at least print-doc could check that all the names existed.

13:28 or one could run a checker to verify the code.

13:29 rhickey: but there are all kinds of subtle details with possessives, plurals etc

13:33 jgracin: I can't think of an example where it would be a problem. E.g. Takes a @map and returns new map. If @map's keys are...etc.

13:36 rhickey: so it knows about -s,-es, apostrophe etc?

13:42 arbscht: how might one go about reading characters from a stream? as in CL's READ-CHAR

13:42 rhickey: java.io

13:43 arbscht: ok

13:44 ericthor: rich: what is the syntax for calling a base class function from within a proxied clojure function? (sorry if it's in the docs...didn't see it)

13:45 rhickey: I presume you ar etalking about the equivalent of a super call - you can't - that capability can't be proxied

13:45 you have this and can call public methods, but only with full virtual resolution

13:48 ericthor: ok

13:49 given:

13:49 (def cell-renderer (proxy [javax.swing.tree.DefaultTreeCellRenderer] []

13:49 (getText [] "Whatever I want"))

13:49 )

13:49 well...let me come back to this question...i have one more test to do first

13:50 (. my-tree/cell-renderer (getText))

13:50 does not return "whatever I want"

13:51 is there something else I must do in order to override a method in a base interface of the extended class?

13:57 rhickey: looks like I'm not picking those up in the scan for methods to override - will fix

13:58 ericthor: ok...it's a class method if that matters

14:07 rhickey: fixed

14:10 ericthor: awesome!

14:10 rhickey: it was just a type

14:10 typo

14:20 ericthor: in boot.clj ? ... just making sure I have the fix

14:22 i'm good...thanks!!!!!!

14:22 if only life were this easy

14:25 jgracin: rhickey: still interested in that doc-formatting patch? it's at http://dev.inge-mark.hr/~gracin/doc-formatting.patch

14:27 rhickey: cool thanks!

14:28 jgracin: except adding a newline at the end of boot.clj, it doesn't touch anything besides the docs.

14:31 arbscht: tabs and spaces are inconsistent, no?

14:32 or is it my emacs untabifying

14:39 jgracin: hm, yes. Let me check.

15:01 it's difficult to get it right because code formatting gets in the way. To make the code look good, one has to use spaces in the doc-strings.

15:06 ericthor: Rich: I'm working with a swing component that at some point asks the object (in this case what's enclosed in a tree node) for it's string representation. I want to stick with clojure data structures. What is an idiomatic way to address this since the nodes may contain MepEntrys, ISeqs, Maps etc.

15:09 I suppose I could extend object to dispatch the toString call and keep instances of those in the clojure data structures?

15:37 jgracin: rhickey: I'm working on the better version of doc strings. Please, don't apply the previous patch. Sorry for the inconvenience!

15:38 arbscht: thanks for the warning.

16:29 The new version of the patch which beautifies the doc strings is at http://dev.inge-mark.hr/~gracin/doc-formatting-2.patch

16:31 there should be no spaces in this one

16:38 ericthor: is there an equivalent to position for vectors? (position item-or-pred [1 2 3 4])

16:38 rhickey: no, I'm missing find/position/member for seqs

16:39 just thinking about those the other day

16:42 jgracin: thanks, that's up. feel like doing the other 3 .cljs (xml/zip/proxy)?

16:42 jgracin: sure.

17:03 rhickey: here are the rest of the files: http://dev.inge-mark.hr/~gracin/docs-rest.patch

17:06 rhickey: they're up - thanks!

17:27 map entries are now vectors

17:28 user=> (seq {:a 1 :b 2 :c 3})

17:28 ([:b 2] [:a 1] [:c 3])

17:28 with proper equality semantics

17:29 and you can conj pairs onto maps:

17:29 user=> (conj {:a 1 :b 2} [:c 3])

17:29 {:b 2, :a 1, :c 3}

18:38 Chouser: rhickey: nice

18:39 ericthor: great....BTW, why no meta data on namespaces?

18:39 there are 10 other ways to do what I want....just curious from a design persepctive

18:40 Chouser: Do key and val still work on map entries?

19:03 jonathan_: Hey Rich, .. I have a quick question...

19:03 Why does this fail? (apply max (filter #(%) [1 nil 2]))

19:06 I was hoping that filter would work with #(%)?

19:13 rhickey: yes key and val still work on map entries

19:14 no metadata on namespaces because they are not values. Would need special handling like var, not sure it's worth it

19:15 #(%) ==> (fn* [p1__1507] (p1__1507))

19:16 use identity instead

19:17 ericthor: like : ^(with-meta (identity 'clojure) {:some :baggage})

20:10 rhickey: no identity instead of #(%)

21:39 jonathan_: sorry, I figured that #(%) might act as a boolean for filter, and drop the null

21:39 rather than doing #(if (not (nil? %))true)

21:39 rhickey: use identity

21:40 filter identity

21:40 jonathan_: ahhhh, ok, I get it, thanks

21:41 rhickey: any emacs user know how I can force a tab in, instead of smart tabbing, in clojure-mode?

21:52 jonathan_: I updated my sparkline generator with a bit of a refactoring. nils are handled correctly now.

21:54 rhickey: I thought I left a comment, but didn't go through? you might try destructuring your maps in let

21:56 I added a new example on the wiki: http://en.wikibooks.org/wiki/Clojure_Programming#Examples

21:56 Norvig's spelling corrector

21:56 jonathan_: yeah!!!!!! That's a great suggestion ... There's a whole bunch of stuff I haven't caught up with yet in Clojure, and I'm trying to apply it where errr applicable. I added doc strings, and changed to be iterative, rather than a loop, since I want to leave a blank for nils, rather than stop.

21:56 cool

21:58 rhickey: shorter than the Python (by one line :), and thus the shortest version

21:58 and added slurp, subs(tring) max-key, min-key along the way

21:59 jonathan_: I just ordered his Paradigms book

21:59 rhickey: great book

22:00 jonathan_: Good, I'm hoping that I can eventually just start codegen'ing any C++ I need, and therefore avoid writing any C++ or C ever again

22:04 thanks Rich, I caught up with my blog comments

22:09 I looking forward to a new Programmers at Work

22:42 rhickey: never read it

Logging service provided by n01se.net