On 11.05.2009, at 23:17, samppi wrote:
user= (defmacro b [ xs]
`(with-monad maybe-m (m-seq ~xs)))
#'user/b
user= (b [1 2 3])
java.lang.IllegalArgumentException: Wrong number of args passed to:
LazilyPersistentVector (NO_SOURCE_FILE:0)
So there's something wrong with how I'm phrasing the
On 12.05.2009, at 05:42, Mark Reid wrote:
I'm quite new to macros so forgive me if this is a naïve question, but
is it possible to write macros that are applied to an entire Clojure
program?
It depends on what you call a program. Clojure code is structured
in the form of namespaces, and
Thanks for your responses. I'm glad to see that I'm not entirely on
the wrong track here.
On Mon, May 11, 2009 at 6:39 PM, Sean Devlin francoisdev...@gmail.com wrote:
Okay, good point about approach #2. As I mentioned earlier, I'd use
approach #3 first. Here's how I'd write your macro as a
Ah, I see. :)
Thanks for your quick reply.
Vincent
On May 11, 8:54 pm, Rich Hickey richhic...@gmail.com wrote:
On May 11, 2:20 pm, Vincent Akkermans vincent.akkerm...@gmail.com
wrote:
Hi all,
I'm building an application in which I want some function calls to be
logged. However,
You could write a Clojure program that took in a Clojure program and spit
out an optimized Clojure program. You could do something similar to the
meta-circular evaluator, where you step through the program (which is just a
data structure) recursively matching the head each time against different
One thing hit me as I went to bed last night about this problem:
Writing a macro to optimize an s-exp *is* writing a compiler.
The good news is that you *don't* have to write a parser. There is
some low hanging fruit here (like the + macro described above), but I
imagine there will be a lot of
Hi!
I'm querying a DB and getting java.sql.Timestamp in results, among
other things. When I use print-json on this, timestamps are
serialized as #Timestamp 13:23
Stuart, any chance you could make the dispatch function for
clojure.contrib.json.write/print-json more open for extensions?
On May 12, 12:17 am, Mark Reid mark.r...@gmail.com wrote:
I guess what I'm really looking for now is the how.
It's relatively easy to write a program that transforms Clojure source
code:
(loop []
(when-let [code (read *in* false nil)]
... do some transformation on code ...
Laurent PETIT wrote:
On 8 Mai, 01:39, Laurent PETIT laurent.pe...@gmail.com wrote:
note that clojure must be compatible with JDK 1.5, so if you compile with
1.6, maybe you should verify the compatibility mode (not sure if what I
write here makes sense, I'm not a specialist in javac
I see—thank you very much. But I suppose I don't understand how vector
expressions work in macros. I thought that using ~@ would get me an
argument error.
I thought that:
`(with-monad maybe-m (m-seq ~xs)))
would insert [1 2 3] where ~xs would be, becoming the list:
(with-monad maybe-m (m-seq [1
On May 12, 2009, at 16:40, samppi wrote:
I thought that:
`(with-monad maybe-m (m-seq ~xs)))
would insert [1 2 3] where ~xs would be, becoming the list:
(with-monad maybe-m (m-seq [1 2 3]))
It does, if you define your macro as
(defmacro b [xs]
`(with-monad maybe-m (m-seq ~xs)))
But
Oh, no...I understand now—it looks like I've incorrectly explained my
problem.
I want to use the macro like this: (a 1 2 3) equivalent to (m-seq [1 2
3]).
Clojure 1.0.0-
user= (use 'clojure.contrib.monads)
nil
user= (defn a [ xs]
(with-monad maybe-m (m-seq xs)))
#'user/a
user= (a 1 2 3)
(1 2 3)
On Tue, May 12, 2009 at 11:22 AM, samppi rbysam...@gmail.com wrote:
Oh, no...I understand now—it looks like I've incorrectly explained my
problem.
I want to use the macro like this: (a 1 2 3) equivalent to (m-seq [1 2
3]).
Clojure 1.0.0-
user= (use 'clojure.contrib.monads)
nil
user=
That works perfectly. I forgot about macroexpand-1...but I also didn't
think that the (1 2 3) list would be evaluated using 1 as a function
too.
Thanks both of you for the great help.
On May 12, 8:33 am, J. McConnell jdo...@gmail.com wrote:
On Tue, May 12, 2009 at 11:22 AM, samppi
On May 10, 2009, at 12:24 PM, Stuart Sierra wrote:
I'd never say this out loud on comp.lang.lisp, but I can't think of
any CL libraries for which there is not a functionally equivalent,
more robust, better-maintained Java library.
Yeah, Java APIs aren't Lisp APIs. Whatever. Java libraries
The article I wrote just came out at JavaWorld
http://www.JavaWorld.com (archived
here) http://www.javaworld.com/javaworld/jw-05-2009/jw-05-clojure.html.
Hopefully
this article will influence Java developers to give Clojure a try.
Thanks to Rich and to the whole Clojure community: The
I just saw this on the JavaWorld article (great article by the way:
http://www.javaworld.com/javaworld/jw-05-2009/jw-05-clojure.html
) http://www.javaworld.com/javaworld/jw-05-2009/jw-05-clojure.html
(defmacro with-open [bindings body]
`(let bindings
(try
@body
(finally
(with-open [rdr (reader file)]
...)
So the vector you referred to is for binding and in imperative that means
assigning rdr to function (reader file). So now it is pretty obvious that
what you need is the variable, rdr, (in side the scope) and that's why
clojure takes only the first
Right, my question is why I can't do this:(with-open [rdr (reader file)
writer (get-writer) foo (get-a-foo)]
...)
On Tue, May 12, 2009 at 12:51 PM, Emeka emekami...@gmail.com wrote:
(with-open [rdr (reader file)]
...)
So the vector you referred to is for binding and in imperative
Hi,
Am 12.05.2009 um 18:56 schrieb Andrew Wagner:
Right, my question is why I can't do this:
(with-open [rdr (reader file) writer (get-writer) foo (get-a-foo)]
...)
In fact you can do and Clojure will close the Closables in
reverse order. The information you found is outdated.
Sincerely
On May 12, 2009, at 12:30 PM, Andrew Wagner wrote:
It seems like this idiom would be easy to implement in this macro.
Or am I missing something?
The current implementation of clojure.core/with-open works with
multiple bindings the way you're advocating. The one in the article
makes for
Wow. Ok, yeah, I'm glad he didn't put that version in the article :)
On Tue, May 12, 2009 at 1:17 PM, Stephen C. Gilardi squee...@mac.comwrote:
On May 12, 2009, at 12:30 PM, Andrew Wagner wrote:
It seems like this idiom would be easy to implement in this macro. Or am I
missing something?
On May 5, 9:10 am, Konrad Hinsen konrad.hin...@laposte.net wrote:
On Jan 29, 2009, at 16:04, Rich Hickey wrote:
I'd like to try to get a directory ofClojurelibs together and up on
theClojuresite. Towards that end, I'd appreciate it, if you are the
author of aClojurelibrary(including
I use Maven indirectly via Ivy, so I just wanted to request that,
whatever the choice of naming, the artifact and module names should
parallel. The reason for this request is that Ivy can resolve
dependencies in maven by creating URLs from a pattern. For example:
dependency org=org.clojure
Oh, it's just significantly harder to read if you don't know clojure, that's
all.
On Tue, May 12, 2009 at 2:43 PM, Emeka emekami...@gmail.com wrote:
Why?
On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wagner.and...@gmail.comwrote:
Wow. Ok, yeah, I'm glad he didn't put that version in the
Andrew, that code caused me to have headache some minutes ago :).
On Tue, May 12, 2009 at 6:43 PM, Emeka emekami...@gmail.com wrote:
Why?
On Tue, May 12, 2009 at 5:37 PM, Andrew Wagner wagner.and...@gmail.comwrote:
Wow. Ok, yeah, I'm glad he didn't put that version in the article :)
On
It's the answer to why the main artifact is called clojure-lang not
just clojure. It's do differentiate Rich's framework,
clojure-lang, from the Contrib librarys (clojure-contrib) even
though they are both in the same Maven group.
On Sun, May 10, 2009 at 8:36 AM, Phil Hagelberg p...@hagelb.org
Hello,
It seems that it's really a matter of convention, I don't see any technical
problem of having a groupId of org.clojure and an artifactId of clojure.
Please let me try to summarize this never ending discussion:
Currently the master build script is ant's build.xml.
It generates clojure.jar
I'm trying to encode a java string into utf-8 for encapsulation within
an OtpErlangBinary
(http://erlang.org/doc/apps/jinterface/java/com/ericsson/otp/erlang/OtpErlangBinary.html).
When I try to construct an OtpErlangBinary from the results of
String.getBytes(encoding), I get bad data. A string
Hi,
I've found that the capitalization is incorrect on lines 177 and 276
of core-print.clj.
To reproduce it, enter the following forms:
(print hi) ; will hit line 177
(new System.Text.RegularExpressions.Regex .) ; will hit 276
The error message is as following for both:
Now that Clojure 1.0 is out, I think it's a good time to take a look at
contrib. I noticed it didn't get an official 1.0 release along with
Clojure core. I wonder if this is because its role is just not very
well-defined. Several people have expressed this opinion here on the
mailing list and on
I also, have a very vague sense (or perhaps just incorrect) of what
contrib is. I am sharing my (possibly misguided) view because it's
likely a lot of other people think similarly.
Contrib seems to be a collection for user-created libraries for
Clojure. They all seem to be in various stages of
to me symmetry is important. That is, consistency ... because it helps
people know where to look.
So, if slurp is in the core, spit should be in the core (but why not just
use python's way more typical convention of read() and write().
Another example I recently saw is that (nth) is in the
On May 12, 2009, at 4:04 PM, Phil Hagelberg wrote:
Would love to hear what folks think about this.
I am new here and new to Java and the JVM as well. Contrib strikes me
as an improvement over the situation with Ruby where tons of code was
dumped into the Ruby distribution and much of it
Hello,
Clojure's documentation is incredible, kudos to Rich Hickey! However
I'd like to bring attention to one sentence in the docs which
definitely needs revision:
Bindings created with binding can be assigned to, which provides a
means for nested contexts to communicate with code before it
Using a java nio ByteBuffer to simulate what you're doing, the
following works ok for me;
(defmulti t-str class)
(defmethod t-str String [s] (java.nio.ByteBuffer/wrap
(.getBytes s us-ascii)))
(t-str abcde)
#HeapByteBuffer java.nio.HeapByteBuffer[pos=0 lim=5 cap=5]
(defmethod t-str String [s]
I should clarify: I asked my original question not because I wanted to
actually write an optimiser but rather I was interested in how far the
idea of code-modifying code could be pushed in a Lisp-like language
such as Clojure. The example I gave was just the simplest thing I
could think of that
Maybe there's something about the particular [ s ] object that you're
passing in?
I believe that you're right; in general, the getBytes seems to work.
It is just in this one freakish case that it doesn't, but I have no
idea how to tell what's special about my string. I'm not exactly
I often write code that I just want to run in an infinite loop. The
code generates lots of random things, and logs the interesting ones to
a file.
In Python, I'd write such code inside a try block that catches the
Ctrl-C exception. So, when I want to use my computer for something
else, I just
Hi Alex,
ataggart alex.tagg...@gmail.com writes:
I use Maven indirectly via Ivy, so I just wanted to request that,
whatever the choice of naming, the artifact and module names should
parallel. The reason for this request is that Ivy can resolve
dependencies in maven by creating URLs from a
Hello Laurent,
thanks for the summary! I'm looking forward to the decision and hope, we
can move forward soon.
-Stefan
Laurent PETIT laurent.pe...@gmail.com writes:
Hello,
It seems that it's really a matter of convention, I don't see any technical
problem
of having a groupId of
Well, under the covers the str function applies the java toString
method to any passed in object and hence the result could for some
reason be different to the original String object passed in. I think
this could occur if the object subclasses String, but has a different
representation (i.e a
I guess it may be defonce ( http://clojure.org/api#toc194 ) you're after,
Regards,
--
Laurent
2009/5/13 Mark Engelberg mark.engelb...@gmail.com
I often write code that I just want to run in an infinite loop. The
code generates lots of random things, and logs the interesting ones to
a
Maybe, (just maybe :-) what doesn't help Rich see the real interesting
candidate to core (or the most probable candidates, those that just do one
thing by filling a gap, such as spit) could be placed in a more visible
namespace.
For example, placing carefully designed general small additions such
44 matches
Mail list logo