Clojure people say that jvm doesn't support tco, which it doesn't. So
they implemented a recur macro that turns the function into an
explicitly tcoable function. But, take a look at scala. It can do
(naive) tco optimization without any extra effort from the developer.
And on other
Got an out of memory when experimenting with core.async channels in go
blocks. The following is a simple example.
(defn go-loop
[]
(let [c0 (chan)]
(while true
(go
(! c0 1))
(go
(println (! c0))
;(.start (Thread. go-loop))
Clojure 1.5.1, Java 1.7.0_25 32-bit running under
On Saturday, July 6, 2013 11:46:51 AM UTC-4, David Nolen wrote:
This isn't a bug, you're in a infinite loop constructing go blocks. You
should probably move the loops into the go blocks.
I assumed go blocks are garbage collected when they go out of scope, but
maybe I don't understand
On Saturday, July 6, 2013 4:01:31 PM UTC-4, tbc++ wrote:
Go blocks are GC'd but not until they complete running. The problem is
that you're creating go blocks faster than they can run. Creating go blocks
is very cheap, taking/putting into channels is also cheap but not quite as
cheap.
I'm using nrepl with a client created as described in the github
readme (https://github.com/clojure/tools.nrepl). The nrepl server and
client are on the same machine. Everything's working well, except when
I try to eval a long-running bit of code. It seems that the timeout
defined for the client
I may have misunderstood what I've read about protocols, so please set
me straight if the following is wrong -
On Aug 25, 11:08 pm, Stuart Halloway stuart.hallo...@gmail.com
wrote:
I think the current behavior follows the principle of least surprise:
(1) bar is a function, in whatever
(deftype Foo [a b c])
(defprotocol P (bar [x] bar docs))
(extend ::Foo P {:bar (fn [afoo] :foo-thing)})
A common error may be to:
(extend Foo P {:bar (fn [afoo] :foo-thing)})
when (extend ::Foo ... is intended. I notice that (extend Foo...
doesn't throw - should extend check that it is
BDFL says:
http://groups.google.com/group/clojure/browse_frm/thread/3826ba3a52ec8cf7/ea899cfd965744a8?lnk=gstq=hickey+seqable#ea899cfd965744a8
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to
I don't know if this is part of the problem, but you appear to be
calling getInputStream repeatedly on the socket. I think more
typically the socket connnection is established, input and output
streams are obtained one time only, then the streams are used as
needed for the duration of the
So how to do this? As far as I can tell, these various modules are
all hard-linked to point at one another, and I don't see how to make
this linkage more dynamic. To change one file, I'd have to create new
versions of ALL the files. It would be great if each file could store
a variable
Nice!
I had to learn a bit about jogl to get it to work - had to add -
Djava.library.path={path to my jogl lib directory} to my shell script.
The following is in model.clj:
(defn update [ref val]
(when (not (= @ref val)) (dosync (ref-set ref val
I believe this is not right: the deref
In case you haven't seen this thread:
http://groups.google.com/group/clojure/browse_frm/thread/aa22a709501a64ac/79b1c858c6d50497?lnk=gstq=transaction+database#79b1c858c6d50497
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Starting with your version, I got about a 2x improvement with the
following:
(defn check-bounds [x y]
(let [f2 (float 2.0)
f4 (float 4.0)]
(loop [px (float x)
py (float y)
zx (float 0.0)
zy (float 0.0)
zx2 (float 0.0)
zy2 (float
However the code (proxy-super publish m) throws this exception:
#IllegalArgumentException java.lang.IllegalArgumentException: No
matching method found: publish for class
clojure.proxy.javax.swing.SwingWorker
publish is a protected method, and I don't think proxy (even with
proxy-super)
I've used print-dup and read for saving and restoring data and it
worked well for me once I defined the needed print-dup methods.
Since you said it's ok for you to read your struct back in as a hash
map, you can do the following:
(defmethod print-dup clojure.lang.PersistentStructMap [o w]
Every launch of Clojure has the opportunity to specify a classpath to
use. Since user.clj is loaded from classpath, it seems to me that's a
sufficient mechanism to avoid loading a given user.clj for a given
launch of Clojure.
Sure, I can definitely control the loading of user.clj. I
On Mar 9, 2:18 pm, Raffael Cavallaro raffaelcavall...@gmail.com
wrote:
On Mar 9, 10:58 am, MikeM michael.messini...@invista.com wrote:
Could you share what benefits you get by the auto-load of user.clj
early in the launch process?
It allows the automatic loading of development utilities
Currently, user.clj is loaded automatically during Clojure boot (in RT
static init). I think this is done as a convenience for repl usage,
since other apps could easily include a 'load' 'require' or 'use' of
whatever is needed. I am proposing that auto-loading of user.clj be
removed. A command
How about removing it from the RT static init and into the REPL function?
I think that would work and it would be transparent for repl users. A
command line option to not load user.clj might be nice to have in this
case.
--~--~-~--~~~---~--~~
You received this
On Mar 4, 5:39 pm, Robert Feldt robert.fe...@gmail.com wrote:
I meant if ASM is already coming with clojure since it is used by
clojure when generating bytecode. Maybe I am missing something... ;)
You can look at genclass.clj for an example of using the ASM that is
bundled with Clojure.
I think that a
shared syntax for both macros and functions calls is a flaw in the
syntax of Lisps, because you can't tell, just by looking at a form,
which expressions get evaluated and which don't, at least when you are
dealing with side effects.
You might want to think about macros such
The only function I could find that takes a vector and returns a list
instead of a vector or a sequence is the reverse function. Are there
others?
Map and other lazy functions currently return a LazySeq -
(map #(+ %) [1 2 3]) = (2 3 4)
cons currently returns a Cons type -
(cons 0 [1 2 3])
I read the part of your article (on lists and vectors) that you linked
to in another thread -
In the list section you show the function into and conj as applied to
lists, but these can also be applied to vectors and will return
vectors,
(into [1 2 3] [4 5]) = [1 2 3 4 5]
(conj [1 2 3] 4 5) = [1
At the end of the Vectors section I say this:
All the code examples provided above for lists also work for vectors.
Do you think I should provide more detail than that?
I missed that sentence. I think it's helpful to know that some
functions return a list type when given a vector, others
I've updated cfa.clj (original thread:
http://groups.google.com/group/clojure/browse_frm/thread/ce795dd1fb646df1/e211230f5e230bc5?lnk=gstq=cfa#e211230f5e230bc5)
in the user files for SVN 1315, also many changes to (hopefully) use
more idiomatic code.
Comments welcome.
Not sure if I understand what you need, but could you build on the
existing capability to send to the current agent: (send *agent* ...) ?
You could have the agent send to itself, then exit the function with
some work left to do that would be restarted on the next go-around.
Thanks very much for the help. Looks like quoting will work.
--~--~-~--~~~---~--~~
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
To unsubscribe from this
Under SVN 1303, I'm getting a ClassNotFoundException from a macro.
Here's a simplified example of the problem:
(defn test1 [x] (+ x 1))
(defmacro test2
[form] (list 'list form {:a test1}))
(test2 (+ 1 1)) = java.lang.ClassNotFoundException: user$test1__3765
Is this a bug?
(if [] true false)
I'd hate to lose the ability to distinguish between an empty
collection and nothing.
As a trade-off to allow nil-punning, you could stipulate the use of
coll? in the above situation:
(if (coll? []) true false) = true
This seems less burdensome - fewer cases where I'd
Other than that, there is just the general loss of nil-punning. This
was the theoretical problem that kept me from making this tradeoff
earlier. I'm very much interesting in hearing from those for whom the
lazy branch represents a real problem due to loss of nil punning.
To preserve
Code written with the fully-lazy branch certainly looks cleaner than
the streams branch equivalent, and having full laziness seems like a
plus. The local-clearing mechanism seems like it will be
straightforward to use.
Seems like this is the way to go. Are there any drawbacks?
There is a lazy branch in SVN. The streams branch has been
discussed, but I haven't seen any discussion of the lazy branch -
perhaps I missed it. Rich and/or other contributors if you have a
little time - I'm curious what changes are being considered and when
these might show up in trunk. Also
On Jan 27, 10:08 am, Tom Ayerst tom.aye...@gmail.com wrote:
I thought the validator just set Agent has errors and you have to check it
explicitly.
Vars, refs and agents can have validators. A validator on a ref can
prevent the ref from taking on a new value by throwing an exception,
which
The power set function for lists should use () as the empty set. If
you use nil, then it seems that you would have
(powerset nil) = (nil)
but this is wrong, since the only subset of an empty set is the empty
set. You could try to fix this by making
(powerset nil) = nil
but then your
This might be helpful:
http://os-lists.sun.com/thread.jspa?messageID=457986
--~--~-~--~~~---~--~~
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
To unsubscribe
There's no event mechanism to monitor namespace changes. I accomplish
this by taking a snapshot before and after any possible namespace-
changing execution, using ns-map. Not as efficient as an event
callback, but I haven't had any performance issues (map lookups are
plenty fast for me).
You can
Not a macro, but does what you want:
(defn alt [ functions]
(fn [tokens]
(some #((force %) tokens) functions)))
;define sub-functions the same way
(defn a-meta-meta-function [c]
(alt (delay (sub-function1 c)) (delay (sub-function2 c)) (delay (sub-
function3 c
After a calling
of alt finishes, what happens to all those Delay objects and their
cached values? Are they garbage-collected, or will they remain
indefinitely? Should I worry?
I believe the references to the delays will be dropped as alt
executes, so they'll be eligible for grabage
Do people want it now?
I would vote for 1.0 ahead of streams if adding streams now will delay
1.0.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email to
I believe the exception is expected here due to the implementation of
sorted sets. See this thread for explanation of a similar exception
thrown by a sorted map:
http://groups.google.com/group/clojure/browse_frm/thread/34def2ec6342f40c/c87ee712482110ee#c87ee712482110ee
With SVN 1162,
((hash-map 'a 1 'b 2) a) = nil
((sorted-map 'a 1 'b 2) a) = ClassCastException
I would think that sorted-maps and hash-maps should both give nil for
this, but perhaps the sorted-map implementation requires a cast?
--~--~-~--~~~---~--~~
You received
You can try this:
(let [t (new Thread (fn[] (shutdown-agents)))]
(.. java.lang.Runtime (getRuntime) (addShutdownHook t)))
It works for me, but seems to take a long time to complete the
shutdown.
Your question made me wonder if the agent thread pools should use
daemon threads - then this
To make sure your driver is really on the classpath, try this from the
REPL:
(. Class (forName com.microsoft.sqlserver.jdbc.SQLServerDriver))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post
I share your concern about the LazyCons problem - hopefully Rich and
others are looking into this.
I have continued to experiment to see if I can gain some understanding
that might help with a solution.
The following is something I thought of today, and I'd like to see if
others get the same
A while back I posted an experimental patch to capture each form that
is compiled into a fn. This might be useful in your case, where you
have identified a function but don't have details on it. Here's the
thread:
http://groups.google.com/group/clojure/browse_frm/thread/e63e48a71935e31a?q=
Also,
I think I've been able to duplicate your results with a simpler
example.
I first tried this:
(defn splode [n]
(with-local-vars [doc-count 0]
(doseq [document (filter #(= % 1) (range n))]
(var-set doc-count (inc @doc-count)))
'done))
and it doesn't blow up with (splode
Perhaps the reason to not include it is that the utility of the
boolean? function is limited. Any value can be used where a clojure
boolean is expected - any non-nil value is true and nil is false.
--~--~-~--~~~---~--~~
You received this message because you are
When (if ever) is it good form to call the underlying Java APIs used
by Clojure's special forms?
I was thinking Rich might reply and weigh in on my suggestion to use
an RT method. I'd also like to know if this should be avoided. It
seems like it might be ok, since the var method is public
I would like to print sorted maps readably (otherwise my sorted maps
when printed and read back get turned into the default map), so I
tried this:
(defmethod print-method clojure.lang.PersistentTreeMap [o,
#^java.io.Writer w]
(let [eprint (fn eprint [e sep?] (do (print-method (key e) w)
Now *I'm* confused. It's your code that's printing #=(sorted-map ...
for me, without any call to prefer-method required.
--Chouser
Well, you're not the only one confused. I thought the #=(sorted-
map ... came from boot.clj somehow, but I now realize my local REPL
pulled in user.clj, where
For the book would people rather see Swing or Qt Jambi examples?
I use Swing occasionally, and have never used Qt, but I'd vote for Qt
examples to see how it compares.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
On Oct 23, 9:02 pm, Mike Hinchey [EMAIL PROTECTED] wrote:
Binding isn't suppose to work for macros. Macros expand during
compile-time, and binding only affects vars at runtime.
Binding works on vars, and a macro is a function in a var, so binding
does work on macros. But you hit the nail
In SVN 1075, binding doesn't seem to work for macros:
;defined as fn to avoid can't take value of a macro exception
(defn bind-test
[ args] `(println bind-test [EMAIL PROTECTED]))
(binding [and bind-test]
(and 1))
I recall this used to work (from some experiments I ran in May of
this year).
I'd like to offer the following version of interpose as a replacement
for the current interpose in boot.clj. It's been useful for me and I
think it may be for others.
(defn intpose
(intpose n sep coll)
Returns a lazy seq of the elements of coll separated by sep, with
sep inserted after every
In SVN 1067, the following throws an NPE:
(let [frdr (new java.io.StringReader {:a 1})
prdr (new java.io.PushbackReader frdr)
eof (new Object)]
(read prdr nil eof)
)
Using false instead of nil works:
(let [frdr (new java.io.StringReader {:a 1})
prdr (new
What project types lend themselves to using Java over Clojure, vice
versa, or in combination?
A project where a GUI-building tool (such as Matisse in Netbeans) is
needed would be a case where Java may still be required. Anything done
in Java can be done in Clojure quite readily, with proxy
If you haven't already seen it, an interesting post from Charles
Nutter on implementing dynamic languages on the JVM:
http://blog.headius.com/2008/09/first-taste-of-invokedynamic.html
Nutter mentions a possible OutOfMemory condition that can occur due to
filling the PermGen part of the heap with
Adding meta data to a lazy cons throws an NPE in line 44 of
LazyCons.java:
(let [lazycons (map identity (range 10))]
(with-meta lazycons {:a 1}))
It appears that when the LazyCons(IPersistentMap meta, Object first,
ISeq rest) constructor is used, the supplied first and rest are
ignored,
58 matches
Mail list logo