#clojure logs

2008-03-01

12:48jgracinrhickey: hi! do you use emacs to write Clojure code?
12:57rhickeyyes, Aquamacs on OS X
12:57rhickeynot much of an emacs guy otherwise
13:04jgracinrhickey: The doc strings in boot.clj seem badly formatted, i.e. using tabs in the middle of sentences, line length exceeding 80 characters.
13:04jgracinam I missing something or you just didn't pay too much attention to it.
13:05jgracinI ask because maybe I'd re-format it, if you would be interested in the patch.
13:06rhickeysome were done in IntelliJ, but no, right now there isn't a good plan for formatting
13:06rhickeyif you wanted to patch you'd need to get in and out quickly, on current rev
13:07rhickeyI'm not in there right now
13:08jgracinI'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:10rhickeythat's the problem, Clojure doesn't have the notion of a line-continuation character in string literals
13:11jgracinwhat's your position on using formatting tags, such as javadoc?
13:11rhickeythey seem like a real pain
13:13jgracinI'm not too happy with those either. But OTOH, the docs become more useful if they are annotated. And eligible for automatic processing.
13:14jgracinI'm not trying to persuade you. Just saying.
13:14rhickeyI think the fact that things are in metadata is already a king of annotation
13:14rhickeykind of
13:15rhickeya problem right now is the mismatch of argnames and the docstrings, since one came from code and the other the web docs
13:19jgracinoh, another use case easily solved by annotations. :-)
13:19jgracinmaybe not so easily, but...
13:19rhickeyhow so?
13:24jgracinwe 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:25jgracinin Clojure.
13:25rhickeyright
13:26rhickeyright 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:27rhickeyand fns can be variadic
13:28jgracinif 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:28jgracinor one could run a checker to verify the code.
13:29rhickeybut there are all kinds of subtle details with possessives, plurals etc
13:33jgracinI 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:36rhickeyso it knows about -s,-es, apostrophe etc?
13:42arbschthow might one go about reading characters from a stream? as in CL's READ-CHAR
13:42rhickeyjava.io
13:43arbschtok
13:44ericthorrich: 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:45rhickeyI presume you ar etalking about the equivalent of a super call - you can't - that capability can't be proxied
13:45rhickeyyou have this and can call public methods, but only with full virtual resolution
13:48ericthorok
13:49ericthorgiven:
13:49ericthor(def cell-renderer (proxy [javax.swing.tree.DefaultTreeCellRenderer] []
13:49ericthor (getText [] "Whatever I want"))
13:49ericthor )
13:49ericthorwell...let me come back to this question...i have one more test to do first
13:50ericthor (. my-tree/cell-renderer (getText))
13:50ericthordoes not return "whatever I want"
13:51ericthoris there something else I must do in order to override a method in a base interface of the extended class?
13:57rhickeylooks like I'm not picking those up in the scan for methods to override - will fix
13:58ericthorok...it's a class method if that matters
14:07rhickeyfixed
14:10ericthorawesome!
14:10rhickeyit was just a type
14:10rhickeytypo
14:20ericthorin boot.clj ? ... just making sure I have the fix
14:22ericthori'm good...thanks!!!!!!
14:22ericthorif only life were this easy
14:25jgracinrhickey: still interested in that doc-formatting patch? it's at http://dev.inge-mark.hr/~gracin/doc-formatting.patch
14:27rhickeycool thanks!
14:28jgracinexcept adding a newline at the end of boot.clj, it doesn't touch anything besides the docs.
14:31arbschttabs and spaces are inconsistent, no?
14:32arbschtor is it my emacs untabifying
14:39jgracinhm, yes. Let me check.
15:01jgracinit'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:06ericthorRich: 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:09ericthorI suppose I could extend object to dispatch the toString call and keep instances of those in the clojure data structures?
15:37jgracinrhickey: I'm working on the better version of doc strings. Please, don't apply the previous patch. Sorry for the inconvenience!
15:38jgracinarbscht: thanks for the warning.
16:29jgracinThe new version of the patch which beautifies the doc strings is at http://dev.inge-mark.hr/~gracin/doc-formatting-2.patch
16:31jgracinthere should be no spaces in this one
16:38ericthoris there an equivalent to position for vectors? (position item-or-pred [1 2 3 4])
16:38rhickeyno, I'm missing find/position/member for seqs
16:39rhickeyjust thinking about those the other day
16:42rhickeyjgracin: thanks, that's up. feel like doing the other 3 .cljs (xml/zip/proxy)?
16:42jgracinsure.
17:03jgracinrhickey: here are the rest of the files: http://dev.inge-mark.hr/~gracin/docs-rest.patch
17:06rhickeythey're up - thanks!
17:27rhickeymap entries are now vectors
17:28rhickeyuser=> (seq {:a 1 :b 2 :c 3})
17:28rhickey([:b 2] [:a 1] [:c 3])
17:28rhickeywith proper equality semantics
17:29rhickeyand you can conj pairs onto maps:
17:29rhickeyuser=> (conj {:a 1 :b 2} [:c 3])
17:29rhickey{:b 2, :a 1, :c 3}
18:38Chouserrhickey: nice
18:39ericthorgreat....BTW, why no meta data on namespaces?
18:39ericthorthere are 10 other ways to do what I want....just curious from a design persepctive
18:40ChouserDo key and val still work on map entries?
19:03jonathan_Hey Rich, .. I have a quick question...
19:03jonathan_Why does this fail? (apply max (filter #(%) [1 nil 2]))
19:06jonathan_I was hoping that filter would work with #(%)?
19:13rhickeyyes key and val still work on map entries
19:14rhickeyno metadata on namespaces because they are not values. Would need special handling like var, not sure it's worth it
19:15rhickey#(%) ==> (fn* [p1__1507] (p1__1507))
19:16rhickeyuse identity instead
19:17ericthorlike : ^(with-meta (identity 'clojure) {:some :baggage})
20:10rhickeyno identity instead of #(%)
21:39jonathan_sorry, I figured that #(%) might act as a boolean for filter, and drop the null
21:39jonathan_rather than doing #(if (not (nil? %))true)
21:39rhickeyuse identity
21:40rhickeyfilter identity
21:40jonathan_ahhhh, ok, I get it, thanks
21:41rhickeyany emacs user know how I can force a tab in, instead of smart tabbing, in clojure-mode?
21:52jonathan_I updated my sparkline generator with a bit of a refactoring. nils are handled correctly now.
21:54rhickeyI thought I left a comment, but didn't go through? you might try destructuring your maps in let
21:56rhickeyI added a new example on the wiki: http://en.wikibooks.org/wiki/Clojure_Programming#Examples
21:56rhickeyNorvig's spelling corrector
21:56jonathan_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:56jonathan_cool
21:58rhickeyshorter than the Python (by one line :), and thus the shortest version
21:58rhickeyand added slurp, subs(tring) max-key, min-key along the way
21:59jonathan_I just ordered his Paradigms book
21:59rhickeygreat book
22:00jonathan_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:04jonathan_thanks Rich, I caught up with my blog comments
22:09jonathan_I looking forward to a new Programmers at Work
22:42rhickeynever read it