Hi all,
I've stumbled upon some interesting behaviour regarding macros and
anonymous functions. I couldn't find doco anywhere on this so if you
have any pointers please let me know.
Considering the macro:
(defmacro splicer [a] `(list ~@ a))
What's the expected result of:
(macroexpand-1 '(splic
(1) #( ... ) is tanslated to (fn* [ ARGS ] ( ... )) before any macros
are expanded because it is a *reader macro*.
(2) The contents of #() are taken to be a function application. That's
why you can write #(+ 1 %) and have + applied to 1 and %. By the same
token, you can't write #(true) and expect
Thanks, Ben,
I think that while simplifying the example to create a small failing
test case I made some confusion about the root cause of the problems I
was having.
Cheers
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send e
Why not use a constraint? It looks much cleaner.
(defn hello [& {:keys [a b] :as input}]
{:pre [(= (set (keys input)) #{:a :b})]}
"hello")
You can learn more about constraints here:
http://vimeo.com/channels/fulldisclojure#8399758
--
You received this message because you are
On Sat, Jan 29, 2011 at 01:58, Max Weber wrote:
> Give clj-http a try (https://github.com/getwoven/clj-http). It has an
> architecture similar to the one of Ring. Especially the Ring-style
> middleware helps a lot, if you want to add custom behaviour like error
> handling to clj-http.
>
>
Looks gr
On Jan 30, 2:17 pm, Alexander Yakushev
wrote:
> Why not use a constraint? It looks much cleaner.
>
> (defn hello [& {:keys [a b] :as input}]
> {:pre [(= (set (keys input)) #{:a :b})]}
> "hello")
This is not the use case I was looking for (I listed it in a post
above). Constrai
Hi,
I've recently heard about the locals clearing feature of Clojure 1.2 (from a
recent post by Ken Wesson), and decided to test-drive it. Here is a
contrived example:
(defn garbage []
(make-array Byte/TYPE 10485760))
(defn -main [& args]
(let [a (garbage)
b (garbage)
c (ga
On Jan 28, 12:55 pm, David Nolen wrote:
> (ns atest)
>
> (set! *warn-on-reflection* true)
>
> (def buffer-size 192)
> (def array (byte-array buffer-size))
> (defn java-like [^bytes cpuArray]
> (loop [i (int 0)]
> (if (< i (int buffer-size))
> (let [b (byte (aget cpuArray i))
>
Part of the difference (under 1.2) is due to the (substantial)
overhead of accessing the buffer-size var on every iteration.
I ran a quick check and using David's version of the code result
averaged 17.2ms. Just changing buffer-size to a local with using (let
[buffer-size (int 192)]...) the ti
On Jan 28, 12:55 pm, David Nolen wrote:
> (ns atest)
>
> (set! *warn-on-reflection* true)
>
> (def buffer-size 192)
> (def array (byte-array buffer-size))
> (defn java-like [^bytes cpuArray]
> (loop [i (int 0)]
> (if (< i (int buffer-size))
> (let [b (byte (aget cpuArray i))
>
David Nolen wrote:
> (ns atest)
>
> (set! *warn-on-reflection* true)
>
> (def buffer-size 192)
> (def array (byte-array buffer-size))
> (defn java-like [^bytes cpuArray]
> (loop [i (int 0)]
> (if (< i (int buffer-size))
> (let [b (byte (aget cpuArray i))
> g (byte (aget
On Jan 30, 6:08 am, Daniel Janus wrote:
> Hi,
>
> I've recently heard about the locals clearing feature of Clojure 1.2 (from a
> recent post by Ken Wesson), and decided to test-drive it. Here is a
> contrived example:
>
> (defn garbage []
> (make-array Byte/TYPE 10485760))
>
> (defn -main [& a
Am I correct in assuming that if those allocations had been smaller (i.e. if
the JVM had not run out of memory), the GC would have eventually detected
the dead references and freed them once the locals went out of scope?
Bill Smith
On Sunday, January 30, 2011 7:41:44 AM UTC-6, Rich Hickey wrote
Hi.
I'm trying to create a java.io.Writer proxy (which writes to a
JTextArea) but I can't get it to work.
Here is my clojure code so far:
(def text-area (javax.swing.JTextArea.))
(def frame
(let [f (javax.swing.JFrame.)]
(.. f getContentPane (add text-area))
(.setMinimumSize f
GrumpyLittleTed wrote:
> Part of the difference (under 1.2) is due to the (substantial)
> overhead of accessing the buffer-size var on every iteration.
>
> I ran a quick check and using David's version of the code result
> averaged 17.2ms. Just changing buffer-size to a local with using (let
> [buf
I'm trying to set up debugging for my application using the Clojure
Debugging Toolkit. I'm fairly certain I have everything set up properly, but
I can't seem to get it to "reval" appropriately.
I am using the Clojure maven plugin to launch a swank server. (with the
debugging args from George's
Hi
On 30 January 2011 15:49, .Bill Smith wrote:
> Am I correct in assuming that if those allocations had been smaller (i.e. if
> the JVM had not run out of memory), the GC would have eventually detected
> the dead references and freed them once the locals went out of scope?
Yes, once they are ou
On Sun, Jan 30, 2011 at 9:26 AM, Jonas Enlund wrote:
> Hi.
> I'm trying to create a java.io.Writer proxy (which writes to a
> JTextArea) but I can't get it to work.
> Here is my clojure code so far:
>
> (def text-area (javax.swing.JTextArea.))
>
> (def frame
> (let [f (javax.swing.JFrame.)]
>
"Ken Wesson" wrote:
>On Sat, Jan 29, 2011 at 1:46 PM, Mike Meyer
> wrote:
>> Ditto. Most often, the "code" site is the sole project site, and
>everything is there. Some larger projects may have a separate "home"
>page, but it's always prominently mentioned on the "code" site. In
>either case, th
On Sun, Jan 30, 2011 at 5:36 AM, Shantanu Kumar
wrote:
> On Jan 30, 2:17 pm, Alexander Yakushev
> wrote:
>> Why not use a constraint? It looks much cleaner.
>>
>> (defn hello [& {:keys [a b] :as input}]
>> {:pre [(= (set (keys input)) #{:a :b})]}
>> "hello")
Where is this docum
On Sun, Jan 30, 2011 at 12:07 PM, Mike Meyer
wrote:
> Sure, Sturgeon's law is closer to 99% than 90% for the web. But if you don't
> even look at the right page to start with
That is why I say it behooves projects that wish to grow a large
user-base to have a highly-ranked google result be clea
"Ken Wesson" wrote:
>On Sun, Jan 30, 2011 at 12:07 PM, Mike Meyer
> wrote:
>> Sure, Sturgeon's law is closer to 99% than 90% for the web. But if
>you don't even look at the right page to start with
>
>That is why I say it behooves projects that wish to grow a large
>user-base to have a highly-ra
On Sat, Jan 29, 2011 at 10:37 AM, GrumpyLittleTed wrote:
> Part of the difference (under 1.2) is due to the (substantial)
> overhead of accessing the buffer-size var on every iteration.
>
> I ran a quick check and using David's version of the code result
> averaged 17.2ms. Just changing buffer-si
On Sun, Jan 30, 2011 at 12:31 PM, Mike Meyer
wrote:
> "Ken Wesson" wrote:
>>That is why I say it behooves projects that wish to grow a large
>>user-base to have a highly-ranked google result be clearly the place
>>for prospective end-users to go for further information,
>>documentation, friendly
"Ken Wesson" wrote:
>On Sun, Jan 30, 2011 at 12:31 PM, Mike Meyer
> wrote:
>> "Ken Wesson" wrote:
>>>That is why I say it behooves projects that wish to grow a large
>>>user-base to have a highly-ranked google result be clearly the place
>>>for prospective end-users to go for further information
On Sun, Jan 30, 2011 at 7:01 PM, Ken Wesson wrote:
> On Sun, Jan 30, 2011 at 9:26 AM, Jonas Enlund wrote:
>> Hi.
>> I'm trying to create a java.io.Writer proxy (which writes to a
>> JTextArea) but I can't get it to work.
>> Here is my clojure code so far:
>>
>> (def text-area (javax.swing.JTextAr
On Sun, Jan 30, 2011 at 1:24 PM, Mike Meyer
wrote:
> "Ken Wesson" wrote:
>
>>On Sun, Jan 30, 2011 at 12:31 PM, Mike Meyer
>> wrote:
>>> "Ken Wesson" wrote:
That is why I say it behooves projects that wish to grow a large
user-base to have a highly-ranked google result be clearly the plac
On Sun, Jan 30, 2011 at 1:35 PM, Jonas Enlund wrote:
> On Sun, Jan 30, 2011 at 7:01 PM, Ken Wesson wrote:
>> On Sun, Jan 30, 2011 at 9:26 AM, Jonas Enlund wrote:
>>> Hi.
>>> I'm trying to create a java.io.Writer proxy (which writes to a
>>> JTextArea) but I can't get it to work.
>>> Here is my c
On Sun, 30 Jan 2011 13:38:24 -0500
Ken Wesson wrote:
> On Sun, Jan 30, 2011 at 1:24 PM, Mike Meyer
> wrote:
> > "Ken Wesson" wrote:
> >
> >>On Sun, Jan 30, 2011 at 12:31 PM, Mike Meyer
> >> wrote:
> >>> "Ken Wesson" wrote:
> That is why I say it behooves projects that wish to grow a large
On Sun, Jan 30, 2011 at 8:39 PM, Ken Wesson wrote:
> On Sun, Jan 30, 2011 at 1:35 PM, Jonas Enlund wrote:
>> On Sun, Jan 30, 2011 at 7:01 PM, Ken Wesson wrote:
>>> On Sun, Jan 30, 2011 at 9:26 AM, Jonas Enlund
>>> wrote:
Hi.
I'm trying to create a java.io.Writer proxy (which writes t
On Sun, Jan 30, 2011 at 1:45 PM, Mike Meyer
wrote:
>> Not until after they go there once or twice, find confusing project
>> pages with no clear starting point for prospective end users, and form
>> an opinion of the site. :)
>
> Yup. Those pages are about as well organized as every other page one
Hey Daniel:
I'm embarrassed to say I've never tried it before on 1.3. You've
found a real bug. I'll try to get a proper patch out later today, but
if you're in a hurry, you might try changing this line in cdt.clj:
(def ge (memoize #(first (find-methods (va) #"get"
to this:
(def ge (memoiz
That's excellent. Thank you everyone.
Maybe someone could compile all these "let's speed up this clojure
code" threads and put it somewhere as a valuable resource we could
point to when things like this come up again?
sincerely,
--Robert McIntyre
On Sun, Jan 30, 2011 at 1:01 PM, David Nolen wr
On Sun, Jan 30, 2011 at 1:47 PM, Jonas Enlund wrote:
> user=> (.write text-area-writer "Hello, World!")
> ArityException Wrong number of args (2) passed to: user$fn--38$fn
> clojure.lang.AFn.throwArity (AFn.java\
> :439)
> user=> (pst)
> ArityException Wrong number of args (2) passed to: user$fn--
On Sun, 30 Jan 2011 13:51:40 -0500
Ken Wesson wrote:
> On Sun, Jan 30, 2011 at 1:45 PM, Mike Meyer
> wrote:
> >> Not until after they go there once or twice, find confusing project
> >> pages with no clear starting point for prospective end users, and form
> >> an opinion of the site. :)
> >
> >
On Sun, Jan 30, 2011 at 2:58 PM, Mike Meyer
wrote:
> On Sun, 30 Jan 2011 13:51:40 -0500
> Ken Wesson wrote:
>> But that's neglecting a crucial biasing factor: with project-hosting
>> sites it's very easy to just slap together a few text blurbs for the
>> front page and carry on your business usin
On Sun, Jan 30, 2011 at 12:12 PM, Ken Wesson wrote:
> On Sun, Jan 30, 2011 at 5:36 AM, Shantanu Kumar
> wrote:
>> On Jan 30, 2:17 pm, Alexander Yakushev
>> wrote:
>>> Why not use a constraint? It looks much cleaner.
>>>
>>> (defn hello [& {:keys [a b] :as input}]
>>> {:pre [(= (set (key
That did the trick.
The keys on my keyboard that spell out "println" thank you.
On Sun, Jan 30, 2011 at 2:25 PM, George Jahad
wrote:
> Hey Daniel:
>
> I'm embarrassed to say I've never tried it before on 1.3. You've
> found a real bug. I'll try to get a proper patch out later today, but
> if y
On Sun, Jan 30, 2011 at 4:03 PM, Aaron Cohen wrote:
> On Sun, Jan 30, 2011 at 12:12 PM, Ken Wesson wrote:
>> On Sun, Jan 30, 2011 at 5:36 AM, Shantanu Kumar
>> wrote:
>>> On Jan 30, 2:17 pm, Alexander Yakushev
>>> wrote:
Why not use a constraint? It looks much cleaner.
(defn hell
> Where is this documented?
I couldn't find the documentation for it. I learned about them in Full
Disclojure screencasts by Sean Devlin.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
> You just discard all references to an object.
And then afterwards I called (makea), creating a new 'a object. But
then why does it throw an exception when I deref it?
I searched the archives and learned that my intended coding style
(using global vars) isn't idiomatic:
http://groups.google.com/
Nice! That version runs in 6 milliseconds on my machine, fastest of
all the code posted so far. One more idea: use 'unchecked-inc'
instead of 'unchecked-add'. This takes it under 3 milliseconds in my
tests.
(defn java-like [^bytes cpu_array]
(let [buffer-size (int buffer-size)]
(loop [i (
This is not solvable in the most general case. Java serialization tries
really hard to be a completely generic format, but when you have a large
graph of complex objects it becomes unwieldy and inefficient.
Clojure's pr/read will suffice if you restrict yourself to types that can be
read by the
Alexander Yakushev wrote:
> Why not use a constraint? It looks much cleaner.
>
> (defn hello [& {:keys [a b] :as input}]
> {:pre [(= (set (keys input)) #{:a :b})]}
> "hello")
>
> You can learn more about constraints here:
> http://vimeo.com/channels/fulldisclojure#8399758
{:pre
On Sun, Jan 30, 2011 at 5:08 PM, Alexander Yakushev
wrote:
>> Where is this documented?
>
> I couldn't find the documentation for it. I learned about them in Full
> Disclojure screencasts by Sean Devlin.
There is another, quite active thread on this topic right here, right
now. It includes some m
I've been studying network analysis recently, in an attempt to
automatically infer relationships between various Clojure projects. If
a program can determine which similar libraries are good replacements
for eachother, and which libraries tend to work well together, I can
build a browseable directo
Benny Tsai wrote:
> Nice! That version runs in 6 milliseconds on my machine, fastest of
> all the code posted so far. One more idea: use 'unchecked-inc'
> instead of 'unchecked-add'. This takes it under 3 milliseconds in my
> tests.
>
> (defn java-like [^bytes cpu_array]
> (let [buffer-size (i
47 matches
Mail list logo