ANN: inet.data 0.5.1

2012-10-25 Thread Marshall T. Vandegrift
Hi: Inet.data is a Clojure library for modeling various Internet-related conceptual entities as data. It is intended to support applications which are *about* the modeled entities versus *interfacing* with them. It presently contains types and associated APIs for representing IP addresses, IP ne

Re: clojure.logic project.clj file

2012-08-15 Thread Marshall T. Vandegrift
David Nolen writes: > Should core.logic support specific versions of Lein? Ideally Lein 2 > would support Lein 1.X files. My understanding is that the reason the new version is lein 2.0 instead of 1.8 is because it does break backwards compatibility. However, if this is the only problem, it's f

Re: binding vs futures bug or feature (or more likely, am I missing the picture?)

2012-08-03 Thread Marshall T. Vandegrift
Daniel Silén writes: > If I rebind a var's value it receives the new value - but it shouldn't, > because it is in another thread, right?! Clojure 1.3 introduced a feature known as "binding conveyance," which causes the functions passed in for futures and agent actions to be wrapped so as to cap

Re: Using gen-class to generate methods with same names and arities but different type signatures

2012-08-03 Thread Marshall T. Vandegrift
David Greenberg writes: > I can easily generate a map from signatures to implementations, but I > need to generate the class with all the overloads. > > Is there any way to do this? Should I resign myself to writing out a > .java file, and compiling that? In my experience just writing a stub Jav

Re: What concurrency models to document?

2012-08-02 Thread Marshall T. Vandegrift
Brian Marick writes: > Which raises the question: *is* concurrency actually a strong selling > point for functional languages? It definitely was/is for me. I'd avoided threads for most of my career-to-date because in imperative languages any thread could mutate any value to be anything at any p

Re: atom / swap! question

2012-07-31 Thread Marshall T. Vandegrift
"Vinay D.E" writes: > I am a newbie and was doing some exercises when I ran across something that > I don't understand. > I am trying to count the number of elements in an array less than 100. > > My first attempt didn't work. The counter returns 0 > > (let [a (atom 0) > i (take-while (fn[

Re: atom and lock

2012-07-18 Thread Marshall T. Vandegrift
Warren Lynn writes: > I have a hard time understanding why there is a need to retry when > doing "swap!" on an atom. Why does not Clojure just lock the atom > up-front and do the update? This is just my two cents, but I think the/one big reason is that Clojure atoms just *are* non-locking STM-ba

Re: compile dynamic ns ?

2012-04-15 Thread Marshall T. Vandegrift
Stuart Sierra writes: > Clojure doesn't currently support generating Java classes dynamically, > but you could hack the compiler to allow it. And if you don't feel like doing it yourself, check out shady and `shady.gen-class/gen-class`: https://github.com/llasram/shady/blob/master/src/shady

Re: Compiling Libraries With :aot

2012-04-04 Thread Marshall T. Vandegrift
octopusgrabbus writes: > Is there any reason to compile a Clojure library with :aot? Here's all the reasons I know of for doing AOT-compilation: - The code produces JVM classes with `clojure.core/gen-class`, which only produces any results when compiling. - The code needs to expose a J

[ANN] shady 0.1.0: JVM interop classes with less heartache

2012-04-04 Thread Marshall T. Vandegrift
Hi all: Shady is intended to be a collection of JVM interop facilities. Right now it contains two useful pieces of functionality for producing iterop classes: a version of `gen-class` supporting dynamic redefinition like `deftype`; and a `defclass` macro providing a `deftype`-like interface to th

Re: Initializers for AOTed deftype classes

2012-04-03 Thread Marshall T. Vandegrift
"Marshall T. Vandegrift" writes: > So, is this entirely expected behavior? Or am I missing something > which would make initializing the defining namespace happen as part of > a static initializer for the AOTed `deftype` class? To answer my own question, the Clojure w

Initializers for AOTed deftype classes

2012-04-01 Thread Marshall T. Vandegrift
Hi, I'm trying to define some bits of Hadoop glue using `deftype` from Clojure. I'm using Leiningen to produce an AOT-complied JAR of the generated classes. At runtime, Hadoop uses reflection to load classes specified by name in (non-code) configuration. Hadoop is able to locate and instantiate

Re: Bug in extend-protocol macro? (Clojure 1.3.0)

2011-12-31 Thread Marshall T. Vandegrift
Alan Malloy writes: > Stuff like this always worries me. It may happen to work now, but I > doubt if that's a guarantee. extend-protocol's contract is that you > give it a Symbol, which it resolves into a Class. It surely isn't > expecting a Class as an argument, because you can't enter that as a

Re: Bug in extend-protocol macro? (Clojure 1.3.0)

2011-12-30 Thread Marshall T. Vandegrift
Peter Taoussanis writes: > Thanks- that explains it: dropping to extend works as expected. Another option I've been making use of for exactly this situation is to use the #= reader macro to evaluate the Class/forName at read-time. Something like: (extend-protocol MyProtocol java.lang.Inte

Re: let-else macro

2011-12-07 Thread Marshall T. Vandegrift
Stephen Compall writes: > And may be anyway further generalized: > > (defmacro <<- [& forms] > `(->> ~@(reverse forms))) > > (<<- (let [x (foo) y (bar)]) > (when y) > (let [ ]) > (do )) Another alternative, (require '[clojure.algo.monads :as m]) (m/domonad m/maybe-m

Re: Clojure-in-CommonLisp?

2011-11-15 Thread Marshall T. Vandegrift
Konrad Hinsen writes: > That may be a minority, but an implementation based on Common Lisp > could also open the way to an integration with the world of C, via a > Common Lisp implementation with a decent C interface. Integrating the JVM with C via JNA [1] is pretty straightforward. I've been d

Re: Confusing interplay between macros and metadata

2011-11-09 Thread Marshall T. Vandegrift
Tassilo Horn writes: > I'm facing the same issue. I have this macro for java interop: > > (defmacro with-traversal-context > [[g tc] & body] > `(let [old-tc# (.getTraversalContext ^Graph ~g)] > (try >(.setTraversalContext ^Graph ~g ^TraversalContext ~tc) >~@body >

Re: Code problem: setting an atom from a deref'd atom that's inside a let.

2011-10-25 Thread Marshall T. Vandegrift
Tim Robinson writes: > => (defn oops! [] > (let [x1 (atom (hash-map)) > v1 (filter > #(let [xv1 (@data %)] >(if (= xv1 "v1") >(swap! x1 assoc :k1 "other"))) >(keys @data)) > rxv (rese

Re: Confusing interplay between macros and metadata

2011-10-25 Thread Marshall T. Vandegrift
Alan Malloy writes: > It seems to me that it would be nice to have macros automatically > include, on their result forms, the metadata from their input > &form. Of course, macros may wish to add metadata as well, so the two > maps should probably be merged. However, there are certainly some > pro

Re: Potential bug: pmap vs chunked seqs

2011-10-21 Thread Marshall T. Vandegrift
Stefan Kamphausen writes: > Chunked seqs are supposed to realize more elements than you > consume. That's for performance reasons. But since you will only ever > apply side-effect-free functions to seqs, that will make no > difference, no? Sorry, yes, I'm talking about within the code of `pmap'

Potential bug: pmap vs chunked seqs

2011-10-21 Thread Marshall T. Vandegrift
Hi: I found what I think might be considered a bug, but I'm not certain. The doc-string for `pmap' just says that the passed-in function is applied "in parallel," but the code as-written is pretty clearly intended to keep only (+ 2 #CPUS) future-wrapped function applications realized at a time. I

Re: Macro not working - newbie question

2011-10-18 Thread Marshall T. Vandegrift
Dusan writes: > (symbol(str "(str (:" % " " vv "))")) This expression is the (immediate) problem child. You are producing a symbol which contains literal space and parenthesis characters embedded in it. When you print out the macro-expansion, it looks fine, but the actual forms generated conta

Re: when quotes and when syntax-quotes?

2011-10-17 Thread Marshall T. Vandegrift
Guofeng Zhang writes: > I do not understand why "`'~v" has be to used this way. If I used > "`~v" instead (that is, remove the quote), it still works. So my > question is, why "~v" needs to be first quoted and then syntax-quoted? I'm not the most experienced Clojure programmer, but I'll have a g

Re: Exception handling changes in Clojure 1.3.0

2011-10-12 Thread Marshall T. Vandegrift
Stuart Sierra writes: > I was a little worried about this when the exception behavior for fns was > changed. I think it's solvable, but don't know right now what the solution > is. I'm not incredibly experienced with Java, but would using a Java construct which tricks the language into allowin

Re: Closures in macros

2011-05-04 Thread Marshall T. Vandegrift
Alessio Stalla writes: > The key point is that in Lisp "code" does not mean "text" [1]. Code is > made of data structures - lists, symbols, vectors, numbers, ... - and > macros are just functions that operate on those data structures. Hmm, interesting. One of the things that's drawn me to learn

Re: Closures in macros

2011-05-04 Thread Marshall T. Vandegrift
André Thieme writes: > Please try this minimal example in your REPL: > (defn f [x] (fn [] x)) ; the closure factory > (def foo (f 0)) ; a useful instance > (defmacro bar [] `(let [a# ~foo])) > and then call (bar) I'm new to Clojure and don't have much experience with Lisps in general, but trying