#clojure log - Aug 11 2008

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

2:42 mada: hi!

2:42 I am trying to use `pr' to print objects to a file but I must be doing something wrong.

2:43 Here is the latest piece of code I have tested with:

2:43 (with-open *out* (new java.io.FileOutputStream "/home/mathias/txt/.tags")

2:43 (pr "Hello!"))

2:43 I tried with a `let' as well, temporarily overriding the value of *out*.

2:44 The file is created when the stream is instantiated but I get no data in it when printing to it.

2:47 kotarak: try something like this: (let [writer blabla] (binding [*out* writer] ....))

2:47 see: with-out-str in boot.clj for an example

2:50 pr sees the global *out*. Defining with let a new *out* shadows this for the forms in the let, but not for pr. (This is the nature of a closure.) Binding modifies the global *out* which is seen by pr.

3:25 mada: kotarak: aha

3:25 to me the doc is a bit confusing: "Prints the object(s) to the output stream that is the current value of *out*."

3:25 and sounds like it would work with a let

3:26 anyway, I will try according to what you replied. thx!

3:40 kotarak: worked :)

7:30 albino: /window 12

7:30 sorry

7:45 rhickey: Chouser: finally getting to look at gen-interface. One thing - I would prefer there to be some grouping around each method spec, in case we need to extend it at some point.

8:32 Chouser: ok, that was something I wondered about -- thought I'd start with the minimal structure.

8:33 So, list of vectors instead of series of triples? Or do you want a named list (:methods [...]) like gen-class has?

8:34 rhickey: list of vectors is probably fine

8:39 Chouser: I guess we can non-method options with :keyword prefixes as needed later.

8:40 rhickey: Chouser: I'm fine with following genclass too, this is not something to get overly succinct with

8:41 Chouser: hm.

8:41 what did you think of having load-and-save as the default?

8:42 rhickey: Oh yeah - that's neat, but wouldn't it be more useful if it checked to see if already loaded?

8:43 then could work at dev and run times

8:44 Chouser: if it's already loaded, would you want the (possibly updated) version being attempt to fail silently?

8:44 "being attempted"

8:45 rhickey: There's no updating in any case

8:45 so I guess yes

8:46 Chouser: right, updating is impossible. I guess it's just a question of silent or noisy failure.

8:46 I don't have a grasp of the real use cases for this thing, so I'll just follow your instructions. :-)

8:47 rhickey: I guess the question is, if there was a version that only dynamically loaded, and failed noisily if already loaded, and a version that checked for already loaded and did nothing if so, which would you use in source files (i.e. non-interactively)?

8:48 Chouser: I guess the .class file *can* be updated though, even if an old version is already loaded. Should we let the .class file and loaded interface get out of sync?

8:48 rhickey: People are going to get a grip on "If I change loaded Java types I need to restart" at some point

8:50 Chouser: yep. Although I think a lot of the coming-from-Java people are actually in more danger of erring the other way, and "rebuilding" everything after any change.

8:51 rhickey: that's why gen-class separates the two parts, but no analogy in gen-interface

8:54 you do have the tools to determine if it is an incompatible reload, just look up the methods in the existing class - see non-private-methods in genclass

8:55 Chouser: hm... so would it be good to do a silent "failure" if there're the same, and issue a warning or exception if they difffer?

8:56 rhickey: there's no failure if they are the same

8:56 Chouser: right, hence the quotes.

8:58 rhickey: that's the feature I am requesting, so a single file can gen and consume an interface, will work when loaded the first time, and will work at runtime. If different - throw

8:59 Chouser: ok, I'm on it.

10:36 Is there any way to bind all the args of a fn? Like :as, but for the whole arg list.

10:37 rhickey: no

10:38 short of just taking an & arg and destructuring that

10:38 Chouser: ok. ..and doing that messes up any useful doc references to arg names.

10:41 rhickey: you can use :arglists to map however you want - see the definition of defn

10:42 (where docs don't agree with actuals)

10:42 Chouser: thanks, I had forgotten about that.

11:34 gruenero: hi everybody

11:35 i am a clojure newbie

11:35 Chouser: hi

11:35 drewr: gruenero: Welcome!

11:36 gruenero: could anybody explain to me how one can correctly invoke clojure libraries into a clojure program?

11:36 is it "refer" or "load-file"

11:36 i dont get it from the mailing list or from clojure.org

11:37 i am comming from the haskell world

11:37 there it is "import MyModule"

11:39 Chouser: (load-file "foo.clj") will just load and run that file. Chances are it will create a namespace "foo".

11:40 then you can use foo/this and foo/that, or you can alias foo to something else, or you can say (refer 'foo) to allow you to leave off the namespace entirely.

11:43 gruenero: okay, so the first step to correctly invoke a clojure file is "load-file"

11:43 and then one has to care about the namespace

11:43 right?

11:43 Chouser: yes

11:44 gruenero: thanx a lot

11:44 Chouser: there's a lib.clj in clojure-contrib that handles that and also finds .clj files anywhere in your classpath.

11:44 gruenero: I am just trying to achieve some clean modularity

11:45 Chouser: lib.clj is nice, but it's not part of Clojure proper quite yet, so you still have to you load-file or something to get started with it.

11:45 gruenero: okay

11:46 another question: has anybody tried out the parallel.clj stuff

11:46 ?

11:47 rhickey: I have

11:47 Chouser: I think there have been a couple posts to the forum with examples.

11:47 gruenero: :)

11:47 one hast to invoke jsr166.jar when starting the repl right?

11:47 rhickey: yes, that has to be in your classpath

11:48 gruenero: okay

11:49 i am trying to write some Tensor multiplication which uses parallelism from the get go...

11:52 okay, thank you very much guys

12:14 Chouser: I can't think of a better way to do this than to convert both the interface specs given by the user and the existing class into a common format (which is neither the bytecode nor the raw specs).

12:15 so instead of just api->bytecode I also need api->comparable and class->comparable.

12:15 tedious.

12:27 rhickey: (set/index (set (map (fn [[name params ret]]

12:27 {:name name :params params :ret ret})

12:27 (map first (non-private-methods java.util.Map)))) [:name])

12:28 then a similar set from your gen-interface method list, then use =

12:30 indexing will group by method names, mapped to sets of sigs, so the entire index is comparable with =

12:44 Chouser: Currently you can gen interfaces that refer to non-loaded classes (by passing in a symbol or string instead of a class). Is that worth keeping?

12:44 It complicates this process by requiring I resolve everything to something like strings instead of using equality directly on methods or classes.

12:46 rhickey: It's an outstanding feature request on gen-class that it support not-yet-loaded classes

12:46 Chouser: ok

13:04 I need to consider the extends list too, right, not just the method list?

13:04 rhickey: for gen-interface?

13:05 Chouser: yes, when comparing old and new interfaces.

13:06 rhickey: I thought you were only doing this when already loaded, in which case you can call non-private-methods on the already-loaded interface class

13:08 oh, yes I see, if the interface extends multiple interfaces - I guess, although likely to be different method lists

13:08 Chouser: yes, *very* likely to be different method lists. But swapping out one base interface for an identical one with a different name is still different.

13:09 rhickey: right

13:10 I imagine you wish you had chosen silent failure on reload at this point :)

13:10 Chouser: hehe

13:18 Modius: Matthew Lamari

14:12 Chouser: does it matter in what order the base interfaces are given?

15:14 rhickey: Chouser: no

16:31 anyone here have any experience with the IRIS Reasoner?

18:02 wwmorgan: is there a way to resolve specific symbols before passing them to a macro?

18:07 Chouser: wwmorgan: can you explain that more? maybe an example?

18:08 wwmorgan: I have a macro foo that does symbol manipulation, but I also want to be able to do (let [a 1] (foo a b c)) and have it resolve a, but leave b and c alone

18:11 Chouser: oh, you want the macro to resolve it? can you just splice it into your result and let it be resolved later, after expansion?

18:14 wwmorgan: yeah, that would work as long as I had a way of telling the macro which symbols to leave alone

19:46 Chouser: how are primitive parameter types specified for genclass?

19:48 rhickey: Float/TYPE etc

Logging service provided by n01se.net