#clojure log - Mar 29 2008

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

0:52 vagif: Hello, any webjure users ?

0:55 alec: Does clojure not have an equivalent to values/multiple-value-bind, or am I missing it in the documentation? Is there a suggested way to return multiple values from a function besides making a list out of them?

10:45 jonathan_: Thanks for the pointer to that PLT scheme paper on automata, rh ... of course your solution included at least one new keyword I'll have to go find ...

10:45 ericthor: rich: I see SourceDebugExtensionAttribute in compiler.java but where it is used? Is this till how you are writing the debug extention stuff to the bytecode?

10:47 nevermind...found it

10:47 rhickey: eric: it's not used, the smap string is just passed to ASM's visitSource in FnExpr.compile

10:48 ericthor: yup...i see that. thx

10:48 rhickey: jonathan: just be careful, the Scheme version requires TCO. You could do a Clojure version with fns and recur, but I like the maps better

10:51 jonathan_: yeah, I'd kind of spotted there would be a transformation to recur possibly, ok I'll read your solution very carefuly, thanks

11:53 gren: hi - i have a newbie question

11:53 I am just playing with getting a moving piece of text on a JFrame

11:54 and I have some text displaying - however, now I want it to move

11:54 my question is (probably common): what is the most idiomatic way for me to keep the current X,Y position of the text?

11:55 and update it?

12:07 hoeck: gren: i would use getLocation()

12:07 gren: ah, i see: rely on java's mutable state?

12:07 i am playing around with a view to writing a game in clojure

12:08 and wanted to have some clojure data structures for player etc.

12:08 rhickey: if you want a separate model, and you want to do that synchronously - refs, asynchronously - agents, but UI stuff tends to have its own state

12:08 gren: yeah - my example is probably a bit simplistic

12:09 i was looking more to get an understanding of how i create/update/mutate state within clojure itself

12:10 rhickey: refs/agents are the way

12:10 gren: e.g. if i (def *myscore* 78), then to rebind i would do (def *myscore* (inc *myscore*))?

12:10 i'll take a look into agents

12:11 rhickey: (def score (ref 0))...

12:11 (sync nil (alter score inc))

12:11 gren: ok

12:11 rhickey: but don't re-def

12:12 gren: i have a large array (representing a 'map') - presumably (def map (ref (make-array Object 300))) is ok too

12:13 then (sync nil (alter map (update-map))) or something?

12:13 rhickey: you shouldn't put anything in a ref that you intend to mutate, i.e. if you intend to modify the Object array

12:14 Instead you could use a Clojure vector

12:14 gren: yes - makes more sense

12:14 rhickey: I have an ant colony simulation for a talk I gave last week...

12:14 gren: essentially, (map-update) would just alter the members of the vector (actually a tile map of characters)

12:15 yes, i read about that

12:15 rhickey: waiting for the audio, but then I'll make available - does everything you are talking about

12:15 gren: eagerly awaiting the video :)

12:15 rhickey: literally not in my hands

12:15 gren: thanks for the help - very helpful community

13:33 ericthor: rich: the debugger change did break my stuff but I'm able to get around it by changing the range of the final source lines.

13:34 e.g. 10#1,6:1,10000

13:37 This still limits the source file mapping. Not sure if this will interfere with the eclipse problem though. Any thoughts?

14:31 rhickey: eric: 10#1,6:1,10000 => InputStartLine # LineFileID , RepeatCount : OutputStartLine , OutputLineIncrement

14:31 I don't see how that works

14:40 ericthor: it may not make sense (yet) but it does work.

14:41 rhickey: but is says that line 10 corresponds to line 1?

14:41 ericthor: in the output yes?

14:42 rhickey: inputstartline -> outputstartline

14:42 should be the same

14:42 ericthor: let me try it again that way

14:42 it will take a minute

14:43 are they referring to the binary output?

14:44 rhickey: Clojure emits output line numbers 1:1 with the source line 10 == line 10

14:46 a virtual mapping between Clojure source and imaginary java file

14:56 ericthor: ok.

14:56 here is the next question:

14:58 if i put a breakpoint on the (defn ..., when it compiles the breakpoint gets hit 2x. When I call the function, it appears the 1st line I can break on is the 1st line after the defn

14:59 all the other breakpoints on other lines work prefectly

14:59 just not the defn

14:59 rhickey: but defn isn't inside the function being defined, it's defining the function

15:00 ericthor: yes...we're ok there

15:01 rhickey: so can't expect to stop there when calling the function

15:01 ericthor: remote REPL dubugging is working and finding source

15:01 pretty cool

15:01 rhickey: wow

15:01 ericthor: I have it with a checkbox on the REPL to run it locally (which is probably only relevant for developing the module?)

15:02 rhickey: yeah, I think it will almost always be remote

15:02 ericthor: yup

15:02 it's still great to modify the debugger while I'm running through

15:02 though

15:03 there may be some value in attempting to determine the namespace of a breakpoint to help out with the preferred class stuff.

15:04 It finds it immediately when I include the namespace

15:05 I think Mark/Frank has something for that...optimization for the future.

15:05 It looks like I have to handle stepping myself but I do not think that will be a big deal.

15:06 rhickey: stepping yourself seems like more work than you should have to do

15:07 ericthor: nevermind...stepping works fine

15:08 was in the wrong...REPL...might be time for a break

15:08 any recommendations on handling the remote java process? Just using Runtime.getRuntime().exec...

15:09 rhickey: simplest thing that works...

15:09 may be some platform issues

15:10 ericthor: true...but time to move onto shoal....who knows where that will go :)

15:10 rhickey: cool

15:18 single-page API docs: http://clojure.sourceforge.net/reference/api.html

15:20 ericthor: excellent!

15:51 jgracin: The HEAD of webjure to compile. Says package javax.portlet does not exist.

15:51 i.e. the HEAD doesn't compile.

19:30 rhickey: new release: http://clojure.sourceforge.net/news/20080329_release.html

19:30 old hat to all svn-ers

19:37 ericthor: I'm currently debugging and modifying a live instance of the netbeans enclojure module. This is an amazing way to work!

19:38 ...oh..and debugging the remote REPL with the module being written

19:38 a much nicer java experience for sure

20:33 rhickey: eric: sounds cool

21:29 ericthor: can i unmap a symbol in a namespace?

21:29 rhickey: ns-unmap

21:30 ericthor: thx

21:32 is there a magic syntax?

21:32 (ns-unmap 'remote-repl-manager 'get-embedded-clojure-lib)

21:32 rhickey: it takes a namespace and a symbol

21:33 not the name of a namespace

21:33 but I'm thinking of enhancing all of the ns functions to take either

21:33 ericthor: (ns-unmap 'emote-repl-manager 'get-embedded-clojure-lib)?

21:34 rhickey: for now: (ns-unmap (find-ns 'remote-repl-manager) 'get-embedded-clojure-lib)

21:34 ericthor: got it

21:35 way too much typing for that

Logging service provided by n01se.net