Consider the following attempt:
for some reason, after the assertion fails, the main repl thread seems to
lock up
Line 1
Line 2 // after this, no more is printed
Question: what is causing the problem -- and how do I fix it?
Thanks!
=== code ===
(ns test
(:require
#+clj [clojure.core.as
With apologies for spamming:
in case anyone else wanted a solution to this problem:
I believe the right layer is to wrap at the Channel layer, rather than the
Buffer layer: for example:
(ns test
(:require
#+clj [clojure.core.async.impl.protocols :as impl]
#+cljs [cljs.core.async.impl.pr
use filter>
user=> (def c (chan 10))
#'user/c
user=> (def cf (filter> #(if (even? %) % (throw
(IllegalArgumentException.))) c))
#'user/cf
user=> (>!! cf 2)
nil
user=> (>!! cf 1)
IllegalArgumentException user/fn--4294
(form-init9067455327434905636.clj:1)
user=> (>!! cf 4)
nil
user=> ( ( wrote:
>
So far, this is the only way I've figured out that works:
(defn try-fib [n]
(let [ch (timeout 1000)
th (Thread. #(>!! ch (fib n)))
_ (.start th)
answer (http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Gr
You can put the computation into a future, and cancel the future after the
timeout.
BTW is it idiomatic to write to the timeout channel? I thought one should
use something like (alts!! [c (timeout 1000)]).
JW
On Wednesday, January 22, 2014 11:30:23 AM UTC+1, puzzler wrote:
>
> So far, this is
Sorry Luc P., you are right.
I meant that people wouldn't do that without a good reason, but it was not
what I wrote.
On Wednesday, January 22, 2014 3:10:27 AM UTC-2, Luc wrote:
>
> Your last statement is incomplete.
>
> It all depends on trust. We do eval at
> runtime of code and data w/o edn
Hi,
I have a processing loop in a go block and I wanted to make sure that the
processing continue with the next iteration if an exception is thrown.
The following code doesn't seem to be accepted by the go macro:
(go
(loop [xs (range 10)]
(when-let [x (first xs)]
(try
(println x)
Thank you for that. I've found that the code works correctly if I just copy
it into the repl and run it; it's only when I load it in Eclipse (with
Counterclockwise) using ctrl-alt-s that it displays the error. Is there
some way to reset the repl to a blank state (remove all previous class
defin
Sorry,
too eager too soon. (loop (try ..) ) obviously doesn't work :)
2014/1/22 László Török
> Hi,
>
> I have a processing loop in a go block and I wanted to make sure that the
> processing continue with the next iteration if an exception is thrown.
>
> The following code doesn't seem to be ac
Hi,
I've been using clojure for a few months now, but I've tried to avoid
writing my own macros in production code, because of the general warnings
I've heard about misusing their power and the challenges I've run into with
debugging them.
I was looking through the core.async code, and I noti
Just pull the exception out of the loop logic:
(go
(loop [xs (range 10)]
(if-let [x (first xs)]
(if (= ::error (try (println x) (catch Throwable t ::error)))
(recur (rest x))
- James
On 22 January 2014 11:05, László Török wrote:
> Hi,
>
> I have a processing loop in a go b
Hi all!
Trying to use clojure.tools.cli to help us parse command line arguments.
However we are having trouble understanding how to specify required
arguments.
The following example taken from the documentation (
https://github.com/clojure/tools.cli#quick-start) should give a required
argument (b
I like #_, it's very useful
I had a thought I'd like to have #__ - two _ to comment 2 expressions -
specifically for commenting in maps
Then I thought
#_n where n is an integer - to comment as many as you need.
end of my thought.
Dave
--
--
You received this message because you are subs
On Wed 22 Jan 2014 at 01:48:22PM +0100, Alf Kristian Støyle wrote:
> From the documentation it seems that specifying the second part of the
> "long option" should be enough to make an argument required. So this
> minimal example should also produce errors:
>
> (def cli-options-simplified
> [["-p
On Tue 21 Jan 2014 at 07:33:43PM -0800, Alejandro Ciniglio wrote:
> I was wondering if people had advice on when to write these sorts of
> macros vs. when to just use the trivial expansion in the code? (Or
> alternatively, what am I missing in this macro definition?)
>
> (defmacro go-loop
> "Lik
Thanks! That does explain it :)
Would be nice to be able to specify that an option "must be specified in
every invocation" though. I think it would lead to better error messages,
e.g. if several "mandatory" options are forgotten, they will be shown at
once. That is a bit of a hassle when doing it
#_ nests nicely:
#_#_ comments out the next two expressions.
Christophe
On Wed, Jan 22, 2014 at 2:03 PM, Dave Sann wrote:
> I like #_, it's very useful
>
> I had a thought I'd like to have #__ - two _ to comment 2 expressions -
> specifically for commenting in maps
>
> Then I thought
>
> #_n
another little gem. Just what I wanted.
It didn't occur to me that it would work this way - but now it seems
obvious
Thanks Christophe
Dave
On Thursday, 23 January 2014 00:21:53 UTC+11, Christophe Grand wrote:
>
> #_ nests nicely:
> #_#_ comments out the next two expressions.
>
> Christ
guns writes:
> On Tue 21 Jan 2014 at 07:33:43PM -0800, Alejandro Ciniglio wrote:
>
>> I was wondering if people had advice on when to write these sorts of
>> macros vs. when to just use the trivial expansion in the code? (Or
>> alternatively, what am I missing in this macro definition?)
>>
>> (de
On 22 January 2014 13:21, Alf Kristian Støyle wrote:
> Thanks! That does explain it :)
>
> Would be nice to be able to specify that an option "must be specified in
> every invocation" though. I think it would lead to better error messages,
> e.g. if several "mandatory" options are forgotten, they
Sorry about the late response, Gary. Would you mind taking the discussion over
to cider’s issue tracker? (I tend to miss emails, but I don’t miss issues :-)
).
The second change seems totally reasonable. I guess ritz’s complete middleware
returns the completion candidates in some odd format.
On 22/01/14 13:21, Christophe Grand wrote:
#_ nests nicely:
#_#_ comments out the next two expressions.
Christophe
WHAT?!!! I had no idea.I guess you do learn something new every day :)
Jim
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
T
Take a look at Stuart's tools.namespace (
https://github.com/clojure/tools.namespace), although be wary of the
protocol issue as it is something that is pointed out in the warnings
section of that project.
Mauricio
--
--
You received this message because you are subscribed to the Google
Groups
On Wed 22 Jan 2014 at 02:21:51PM +0100, Alf Kristian Støyle wrote:
> Would be nice to be able to specify that an option "must be specified
> in every invocation" though. I think it would lead to better error
> messages, e.g. if several "mandatory" options are forgotten, they will
> be shown at onc
Ok, thanks for the reply guys :)
Cheers,
Alf
On 22 January 2014 16:04, guns wrote:
> On Wed 22 Jan 2014 at 02:21:51PM +0100, Alf Kristian Støyle wrote:
>
> > Would be nice to be able to specify that an option "must be specified
> > in every invocation" though. I think it would lead to better e
Just joking :)
There are a bunch of "golden rules"
that violate on a regular basis for
good reasons.
With some satisfaction I have to
confess.
When you have a
muti purpose tool in your hands
that you can bend to almost any
use it's hard to be restrained by
taboos :)
Luc P.
> Sorry Luc P.,
There's nothing built in to Clojure that does this, but you can easily
define a function in one namespace that calls `require` for your other
namespaces.
Note that this may reduce readability of your source code if you forget
exactly which namespaces that special function loads.
-S
--
--
Y
t x writes:
> (ns foo.bar
> ...
> ...
> ... )
>
> There's basically 10 lines of require that I want as part of nearly _every_
> ns I declare is there a way to define some soft of alias / abbrevraviation
> that is used in namespaces at will?
>
> For example:
>
> ## somewhere, in a magic file:
Not addressing the main problem, but require takes multiple libspecs,
so you can write
(ns foo
(:require [foo.bar :as bar]
[foo.quux :as quux]))
to avoid repeating the keyword, at least. :require in ns expands to a
call to require-the-function, so the latter supports multiple
Looks nice. Thanks for sharing.
--
--
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
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe
On Wed, Jan 22, 2014 at 2:51 AM, Jozef Wagner wrote:
> You can put the computation into a future, and cancel the future after the
> timeout.
>
I experimented with that, but it didn't seem to work. I suspect that
"canceling a future" doesn't really do what I think it should do. I would
appreciat
hi, that's what I ended up doing :)
2014/1/22 James Reeves
> Just pull the exception out of the loop logic:
>
> (go
> (loop [xs (range 10)]
>(if-let [x (first xs)]
> (if (= ::error (try (println x) (catch Throwable t ::error)))
>(recur (rest x))
>
> - James
>
>
> On 22 Jan
What is the task doing? If it is in a tight loop, it must check explicitly
whether the interrupt flag is set and abort. If it is waiting on some
resource, it will receive InterruptedException.
Regards,
Praki Prakash
On Wed, Jan 22, 2014 at 11:20 AM, Mark Engelberg
wrote:
> On Wed, Jan 22, 2014
I think the fib example is a good one in the sense that you are dealing
with an already function that takes a long time, and isn't written as a
loop.
But in general, I want to solve the problem for an arbitrary long-running
computation, for example, a call into a library that you don't control.
O
Jozef:
(let []
(def c (async/chan 10))
(def cf (async/filter> #(if (even? %) %
(assert false))
c))
(async/>!! cf 2)
(try
(async/>!! cf 1)
(catch Exception e
(println "caught exception")))
)
I believe filter> caus
Staurt, Phillip:
Correct me if I'm wrong, the main idea recommended is:
(1) don't try to do it via (:require ...) inside of (ns ... )
(2) define a function, which calls (require ... ) [i.e. the function,
outside of (ns ... )]
Thus, the end solution ends up being:
magic.cljx
(defn load-standard
If you want to be able to control an arbitrary long-running function, a
safe way is to run it in a separate process. That way you can safely
terminate it anytime you want. Of course this opens up a lot of other
issues :)
On Wed, Jan 22, 2014 at 9:15 PM, Mark Engelberg wrote:
> I think the f
no, in the same thread. your code is wrong, assert never throws an
exception.
On Wed, Jan 22, 2014 at 9:17 PM, t x wrote:
> Jozef:
>
> (let []
>
> (def c (async/chan 10))
>
> (def cf (async/filter> #(if (even? %) %
> (assert false))
> c
Damn it, you're right. :-)
(try
(async/>!! cf 1)
(catch Throwable e
(println "caught exception")))
catches it.
On Wed, Jan 22, 2014 at 12:30 PM, Jozef Wagner wrote:
> no, in the same thread. your code is wrong, assert never throws an
> exception.
>
>
> On Wed, Jan 22, 2014 at 9
If you're interested in submitting a talk to Clojure/West in San Francisco,
March 24-26, time is running out!
CFP: https://cognitect.wufoo.com/forms/clojurewest-2014-call-for-presentations/
Other useful links:
Site: http://clojurewest.org
Registration:
https://www.eventbrite.com/e/clojurewest-
Is there a convenient way within Clojure to launch a Clojure function or
Java call in a separate process as opposed to a separate thread? Only way
I know of is to literally shell out to the command prompt and launch a new
executable.
On Wed, Jan 22, 2014 at 12:19 PM, Jozef Wagner wrote:
> If yo
On Wed, Jan 22, 2014 at 3:19 PM, t x wrote:
> (defn load-standard-requires []
> (require ... )
> (require ... ))
...
> Can either of you confirm this is the main plan of attack you have
> suggested?
>
I don't actually *recommend* doing this. But it will work.
My recommendation is to just
On Thursday, 23 January 2014 02:37:43 UTC+5:30, puzzler wrote:
>
> Is there a convenient way within Clojure to launch a Clojure function or
> Java call in a separate process as opposed to a separate thread? Only way
> I know of is to literally shell out to the command prompt and launch a new
So I guess this gets back to my earlier question: when is it safe to
terminate a thread?
I know that I often hit Ctrl-C in the REPL to terminate a long running
function, and I've never really worried about it screwing things up.
On Wed, Jan 22, 2014 at 1:29 PM, Shantanu Kumar wrote:
>
>
> On Th
It's not safe if the thread is holding any locks. It *may* also leak native
resources if the thread is holding those, but native resources held by a
heap-allocated Java object are supposed to be cleaned up by the finalizer
if the object is GC'd, and I think Thread.stop properly removes that
thread'
On Tue, Jan 21, 2014 at 1:50 PM, Yves Parès wrote:
> 2) All my methods listed in the profiler are suffixed by .invoke. Is it
> normal or is pathological of something (I haven't aot-compiled anything, I
> don't know if it may have an impact here), like unnecessary reflection
> calls?
>
That's nor
For processes, there is a https://github.com/Raynes/conch but I haven't
used it yet so I don't know how mature it is.
On Wed, Jan 22, 2014 at 10:45 PM, Cedric Greevey wrote:
> It's not safe if the thread is holding any locks. It *may* also leak
> native resources if the thread is holding those,
Maybe there should be a way to export stuff for transitive inclusion:
(ns common-includes
(:require [foo.core :refer [fooify] :export true])
...)
...
(ns my-ns
(:require [common-includes :as c]))
(defn bar [x]
(c/fooify x 42))
On Wed, Jan 22, 2014 at 4:22 PM, Stuart Sierra wrote:
>
Very impressive work!
I was thinking of letting components not only implement the Lifecycle
protocol but also a protocol that defines the functionality of the
component. To give a simple example, there could be a jdbc component that
establishes a connection on init etc., and which also impleme
I took a stab at it in pure core.async, unfortunately, it does not work; I
would be curious if anyone could explain why.
(use '[clojure.core.async :only [timeout http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure"
(follow up)
I just realized that another approach would be to hold the jdbc connection
type implementing the JDBCProtocol in system under [:jdbc-component :db] or
something, and then call the clojure.java.jdbc/query like functions on
that. Anyway, I would be very happy to hear your comments on
Not true. More RAM, more power. If it hits swap, even more power. That has
been my personal observation.
On Monday, January 20, 2014 6:53:14 AM UTC+1, g vim wrote:
>
> On 20/01/2014 05:43, john walker wrote:
> > The JVM hasn't been receiving the love it deserves lately! Fortunately,
> > percent
In clj, I can do something like:
(defn exception->error [exception]
{:tag :error
:object (ex-data exception)
:message (.getMessage exception)
:stack-trace (=> **
(.getStackTrace exception)
(filter #(.endsWith (.getFileName %) "clj") **)
Langohr [1] is a minimalistic, feature complete Clojure client for RabbitMQ.
Release notes:
http://blog.clojurewerkz.org/blog/2014/01/22/langohr-2-dot-3-2-is-released/
1. http://clojurerabbitmq.info
--
MK
http://github.com/michaelklishin
http://twitter.com/michaelklishin
--
--
You received t
Hi,
I apologize for my vague question.
Does anyone have a good example / blog / library for using the core.async
abstraction across a websocket.
* one side of the channel is in clojure land
* other side of the channel is in cljs land
* I promise that all messages can be encoded via pr
Ah, what good timing!
David Pollak's project Plugh does this, essentially as an implementation
detail. I spent some time with him today discussing this, as I want to use
exactly this functionality in a project I'm building.
The plan is for me to create a standalone project, based on the kernel
56 matches
Mail list logo