#clojure logs

2008-08-11

02:42madahi!
02:42madaI am trying to use `pr' to print objects to a file but I must be doing something wrong.
02:43madaHere is the latest piece of code I have tested with:
02:43mada (with-open *out* (new java.io.FileOutputStream "/home/mathias/txt/.tags")
02:43mada (pr "Hello!"))
02:43madaI tried with a `let' as well, temporarily overriding the value of *out*.
02:44madaThe file is created when the stream is instantiated but I get no data in it when printing to it.
02:47kotaraktry something like this: (let [writer blabla] (binding [*out* writer] ....))
02:47kotaraksee: with-out-str in boot.clj for an example
02:50kotarakpr 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.
03:25madakotarak: aha
03:25madato me the doc is a bit confusing: "Prints the object(s) to the output stream that is the current value of *out*."
03:25madaand sounds like it would work with a let
03:26madaanyway, I will try according to what you replied. thx!
03:40madakotarak: worked :)
07:30albino /window 12
07:30albinosorry
07:45rhickeyChouser: 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.
08:32Chouserok, that was something I wondered about -- thought I'd start with the minimal structure.
08:33ChouserSo, list of vectors instead of series of triples? Or do you want a named list (:methods [...]) like gen-class has?
08:34rhickeylist of vectors is probably fine
08:39ChouserI guess we can non-method options with :keyword prefixes as needed later.
08:40rhickeyChouser: I'm fine with following genclass too, this is not something to get overly succinct with
08:41Chouserhm.
08:41Chouserwhat did you think of having load-and-save as the default?
08:42rhickeyOh yeah - that's neat, but wouldn't it be more useful if it checked to see if already loaded?
08:43rhickeythen could work at dev and run times
08:44Chouserif it's already loaded, would you want the (possibly updated) version being attempt to fail silently?
08:44Chouser"being attempted"
08:45rhickeyThere's no updating in any case
08:45rhickeyso I guess yes
08:46Chouserright, updating is impossible. I guess it's just a question of silent or noisy failure.
08:46ChouserI don't have a grasp of the real use cases for this thing, so I'll just follow your instructions. :-)
08:47rhickeyI 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)?
08:48ChouserI 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?
08:48rhickeyPeople are going to get a grip on "If I change loaded Java types I need to restart" at some point
08:50Chouseryep. 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.
08:51rhickeythat's why gen-class separates the two parts, but no analogy in gen-interface
08:54rhickeyyou 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
08:55Chouserhm... so would it be good to do a silent "failure" if there're the same, and issue a warning or exception if they difffer?
08:56rhickeythere's no failure if they are the same
08:56Chouserright, hence the quotes.
08:58rhickeythat'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
08:59Chouserok, I'm on it.
10:36ChouserIs there any way to bind all the args of a fn? Like :as, but for the whole arg list.
10:37rhickeyno
10:38rhickeyshort of just taking an & arg and destructuring that
10:38Chouserok. ..and doing that messes up any useful doc references to arg names.
10:41rhickeyyou can use :arglists to map however you want - see the definition of defn
10:42rhickey(where docs don't agree with actuals)
10:42Chouserthanks, I had forgotten about that.
11:34gruenero hi everybody
11:35grueneroi am a clojure newbie
11:35Chouserhi
11:35drewrgruenero: Welcome!
11:36gruenerocould anybody explain to me how one can correctly invoke clojure libraries into a clojure program?
11:36gruenerois it "refer" or "load-file"
11:36grueneroi dont get it from the mailing list or from clojure.org
11:37grueneroi am comming from the haskell world
11:37gruenerothere it is "import MyModule"
11:39Chouser(load-file "foo.clj") will just load and run that file. Chances are it will create a namespace "foo".
11:40Chouserthen 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:43gruenerookay, so the first step to correctly invoke a clojure file is "load-file"
11:43grueneroand then one has to care about the namespace
11:43grueneroright?
11:43Chouseryes
11:44gruenerothanx a lot
11:44Chouserthere's a lib.clj in clojure-contrib that handles that and also finds .clj files anywhere in your classpath.
11:44grueneroI am just trying to achieve some clean modularity
11:45Chouserlib.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:45gruenerookay
11:46grueneroanother question: has anybody tried out the parallel.clj stuff
11:46gruenero?
11:47rhickeyI have
11:47ChouserI think there have been a couple posts to the forum with examples.
11:47gruenero:)
11:47grueneroone hast to invoke jsr166.jar when starting the repl right?
11:47rhickeyyes, that has to be in your classpath
11:48gruenerookay
11:49grueneroi am trying to write some Tensor multiplication which uses parallelism from the get go...
11:52gruenerookay, thank you very much guys
12:14ChouserI 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:15Chouserso instead of just api->bytecode I also need api->comparable and class->comparable.
12:15Chousertedious.
12:27rhickey(set/index (set (map (fn [[name params ret]]
12:27rhickey {:name name :params params :ret ret})
12:27rhickey (map first (non-private-methods java.util.Map)))) [:name])
12:28rhickeythen a similar set from your gen-interface method list, then use =
12:30rhickeyindexing will group by method names, mapped to sets of sigs, so the entire index is comparable with =
12:44ChouserCurrently 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:44ChouserIt complicates this process by requiring I resolve everything to something like strings instead of using equality directly on methods or classes.
12:46rhickeyIt's an outstanding feature request on gen-class that it support not-yet-loaded classes
12:46Chouserok
13:04ChouserI need to consider the extends list too, right, not just the method list?
13:04rhickeyfor gen-interface?
13:05Chouseryes, when comparing old and new interfaces.
13:06rhickeyI 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:08rhickeyoh, yes I see, if the interface extends multiple interfaces - I guess, although likely to be different method lists
13:08Chouseryes, *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:09rhickeyright
13:10rhickeyI imagine you wish you had chosen silent failure on reload at this point :)
13:10Chouserhehe
13:18ModiusMatthew Lamari
14:12Chouserdoes it matter in what order the base interfaces are given?
15:14rhickeyChouser: no
16:31rhickeyanyone here have any experience with the IRIS Reasoner?
18:02wwmorganis there a way to resolve specific symbols before passing them to a macro?
18:07Chouserwwmorgan: can you explain that more? maybe an example?
18:08wwmorganI 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:11Chouseroh, you want the macro to resolve it? can you just splice it into your result and let it be resolved later, after expansion?
18:14wwmorganyeah, that would work as long as I had a way of telling the macro which symbols to leave alone
19:46Chouserhow are primitive parameter types specified for genclass?
19:48rhickeyFloat/TYPE etc