Re: core.async: communicating termination

2013-07-12 Thread vemv
If one used those preds to try putting values on the channels one is asking about, then yes, that would generate a classic nasty check-then-act scenario: (when-not (closed? c) (>! c 42)) ;; Value could be never put, in face of interleavings Programmers experienced in concurrency should have de

core.async: communicating termination

2013-07-11 Thread vemv
Consider a happy, oblivious producer of values: (def c (chan 42)) (go (while true (>! c (rand It doesn't know where/now the channel is consumed (which part of the point of channels/queues). However, we *do* know that at some point, nobody will need the result of our producing, so we should

Re: Don't understand why this core.async code fails

2013-07-08 Thread vemv
Took me a while to get the idea but higher-order channels are brilliant - that way one ensures a given reply was actually targeted at one's request. Thanks for the suggestion! Faux-agents would have the limitation of not being to (reasonably) perform blocking I/O - which is the point of my samp

Don't understand why this core.async code fails

2013-07-07 Thread vemv
As you can read here: http://martintrojer.github.io/clojure/2013/07/07/coreasync-and-blocking-io doing blocking IO in a go block should be avoided. So I was thinking that an alternative to non-blocking IO APIs is using agents and channels. The following sample program intends to illustrate the

Need to render some entities moving across a grid

2013-06-17 Thread vemv
I'm implementing a program D. Hofstadter describes in *Fluid Concepts: * https://github.com/vemv/jumbo/* *Even in the original text, concurrency/parallelism is a crucial part of the domain so Clojure is super well-suited. While visualising the carried-in process is not a goal of the pr

Re: Names and clojure.core

2013-03-28 Thread vemv
Yeah being able to reuse names is part of the point of namespaces :) it makes me sad when libraries use ugly names like megaref (for ref) or alter!! (for alter) instead of exploiting this fact. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

would FixedThreadPool-backed reducers make sense?

2013-03-28 Thread vemv
I recall from Rich's presentation on reducers (and it's intuitively true anyway) that FJ is not well suited to all workloads: uniform ones would do just fine with a fixed allocation of tasks to threads. I believe the tradeoff in that case is that one has to manage parallelism very explicitly. N

Re: Raw strings

2013-03-18 Thread vemv
story. On Monday, March 18, 2013 12:50:13 PM UTC+1, Marko Topolnik wrote: > > On Monday, March 18, 2013 12:35:31 PM UTC+1, vemv wrote: > >> Nobody wants to store every regexp in a separate file. >>> >> >> That's because regexes are 'atomic' -

Re: Raw strings

2013-03-18 Thread vemv
- doc strings with examples could be more human readable (defn ^{:examples '[(with-out-str (clipboard (doc distinct)))] clipboard [x] ...) Just if a mechanism like this were used more widely... we'd get syntax coloring for free, and a facility for programatically querying examples.

Re: Raw strings

2013-03-18 Thread vemv
> > Nobody wants to store every regexp in a separate file. > That's because regexes are 'atomic' - you don't place Clojure expressions in the middle of them. SQL or math are vastly different from that. As for SQL, it *is* common practice to store them as isolatedly as possible. I have not

Re: Raw strings

2013-03-17 Thread vemv
> > Python has a notation for "raw strings" > Python also has multiple inheritance :) what I want to mean is that some features have dubious value, regardless of whether they made it to language X or Y. I'm working on a project right now where the lack of raw strings is > killing me.

Re: Cannot access a public static volatile field

2013-03-16 Thread vemv
Ahhh I tracked it down - the class was not public. I thought .java files had to define at least (and at most) *one* public class/enum/interface. How much sense can it make to define a private class in its own file? :( On Sunday, March 17, 2013 5:54:58 AM UTC+1, vemv wrote: > > The relevan

Cannot access a public static volatile field

2013-03-16 Thread vemv
not access a member of class vemv.NGSession with modifiers "public static volatile" sun.reflect.Reflection.ensureMemberAccess (Reflection.java:95) Fortunately I could reproduce the issue isolatedly, in the following class which has no dependencies/etc: https://gist.github.com/vemv/5180

Re: Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread vemv
>> Yeah I was working in that direction now! >> >> Anyway, how come (Class/forName) can work if used from the repl? My >> understanding is that the classloader provided by Class is different from >> DynamicClassLoader. >> >> >> On Sun, Mar 17, 2013 at 3

Imported Java lib can't find classes compiled on the fly

2013-03-16 Thread vemv
Related with my immediately previous question (generate static methods at runtime), but not the same. There's a Java lib which I import and run from a Clojure repl. In that repl, if I perform e.g. (defrecord Foo []), then

Generate static methods at runtime?

2013-03-16 Thread vemv
All class-generating Clojure constructs that one can use at runtime such as proxy, reify, or defrecord, seem to generate instance methods only. gen-class can emit static methods, but one cannot leverage its functionality at runtime. Any way to accomplish this? -- -- You received this message

Re: Google Summer of Code 2013 Ideas

2013-03-16 Thread vemv
Given that you like webdev, you may be interested in improving cemerick's Friend library. There are a bunch of interesting features yet to be implemented! On Saturday, March 16, 2013 6:00:44 AM UTC+1, Chris Bui wrote: > > Hi everybody, I'm a student looking to apply for GSOC 2013. I'm trying to

Re: Google Summer of Code 2013 Ideas

2013-03-16 Thread vemv
Starting from today organisations can send their applications, so you may be running out of time for posting ideas! I just pointed out this at the main thread https://groups.google.com/forum/?fromgroups=#!topic/clojure/vDiha4tYC_s On Saturday, March 16, 2013 6:00:44 AM UTC+1, Chris Bui wrote: >

Re: Google Summer of Code 2013

2013-03-16 Thread vemv
Daniel, Starting from today and until March 29 organisations can send their applications. Which date will you pick? Thanks, Victor On Thursday, February 14, 2013 7:03:58 PM UTC+1, Daniel Solano Gómez wrote: > > Hello, all, > > It's official: Google Summer of Code 2013 is on. > > Last year, Cl

Using Leiningen 2.1.0-SNAPSHOT

2013-03-15 Thread vemv
A bunch of bugfixes have been introduced since 2.0.0 which I need ASAP for the projects I'm working on. How to use the development version of Lein? One cannot perform lein upgrade "2.1.0-SNAPSHOT". -- -- You received this message because you are subscribed to the Google Groups "Clojure" group

Re: what is a good book about Java queues?

2013-03-09 Thread vemv
Two queues cover the 80% case: an implementation of BlockingQueue (array, linked list backed), and clojure.lang.PersistentQueue. The former provides concurrency semantics: there are no 'stale values' issues associated to mutation, and you can choose whether your reads/writes are blocking (which

Re: How to ensure consistency when accessing database?

2013-03-09 Thread vemv
On the Clojure side the only thing you can do is to serialize writes to the resouce (the db connection). So at most one thread can be performing an update operation, at a given time. You can increase concurrency by mantaining "read-only" db connections (most likely in an ad-hoc/by-convention ma

Re: clojure.core/protocol?

2013-03-09 Thread vemv
(defprototocol P ...) does two things: define a map on the current namespace, and generate an interface on a package that will have the same name as the current namespace. (defprotocol P (x [_])) ;; -> P (class P) ;; -> clojure.lang.PersistentArrayMap (:on-interface P) ;; -> user.P (.isInterface

Re: features expression

2013-03-05 Thread vemv
I believe protocols can entirely alleviate the need for feature expressions. On Saturday, February 16, 2013 5:28:59 PM UTC+1, Mimmo Cosenza wrote: > > Hi all, > the more I learn cli/cljs the more I find myself in looking for libraries > running on both sides of a clojurean web app. hiccup/valip,

Re: Interesting Light Table post

2013-03-03 Thread vemv
IIRC they're building it in such a way it can be extended via plugins. So just wait :) On Friday, March 1, 2013 6:04:50 PM UTC+1, Charles sanders wrote: > > Is there a way for outsiders to contribute to lighttable ? > > On Fri, Mar 1, 2013 at 9:03 AM, Mark C > > wrote: > >> This release is a big

AOT and side-effects associated to ns initialization

2013-02-27 Thread vemv
So I was playing with AOT for the first time. My main reason to use it is so the consumer Java code doesn't look so alien / run-timey. The thing is, I encountered that the following line causes `lein compile` to hang: (def server (jetty/run-jetty #'app {:port 8000 :join? false})) (for tho

AOT and side-effects associated to ns initialization

2013-02-27 Thread vemv
So I was playing with AOT for the first time. My main reason to use it is so the consumer Java code doesn't look so alien / run-timey. The thing is, I encountered that the following line causes `lein compile` to hang: (defn -server [] (jetty/run-jetty #'app {:port 8000 :join? false})) (fo

Re: how can I ensure a dosync is finished?

2013-02-26 Thread vemv
Looks like refs are not particularly the best tool for the job in this case - those values aren't going to change a lot right? And they could be expressed as a single hashmap - removing the needs for transactionality. Answering to your question, it is impossible to reach the (when...) without t

Re: nREPL + Emacs: How to get new definitions to load reliably?

2013-02-22 Thread vemv
Being *x* is the function you use for switching between buffers, one can add a hook to *x* that will perform a nrepl-eval-ns-form, or more sophisticated stuff like adding a :reload clause, sending the ns form to the nrepl console as well, etc. -- -- You received this message because you are s

The case for as->> ("as-last")

2013-02-18 Thread vemv
While there are other possible uses (example), I see myself mainly using as-> as a mechanism for resorting to thread-last within a thread-first expression. For example, given (-> [[1 1 1] 2 3] (nth 0)) I might want to add an operation th

Re: RC 16: Last chance to test against Clojure 1.5 before it ships

2013-02-18 Thread vemv
Your additional points make more evident the need to put some final effort on the design of ExceptionInfo - leaving it "alpha" would be pretty unfortunate. On Monday, February 18, 2013 2:05:39 PM UTC+1, Dave Sann wrote: > > I don't expect this to go into 1.5. > > But

Re: alternative to passing parameters to functions

2013-02-17 Thread vemv
fn's "keyword arguments" feature provide unrolled, optional key-value args: (defn foo [& {:keys [a b c]}] [a b c]) (foo :c 4) ;; [nil nil 4] On Sunday, February 17, 2013 10:06:13 PM UTC+1, AtKaaZ wrote: > > Was there a library or some other way to pass ie. maps to functions > so that the order

Re: RC 16: Last chance to test against Clojure 1.5 before it ships

2013-02-17 Thread vemv
e wrote: > > You can create an ExceptionInfo instance easily by using the core fn > `ex-info`. So something like ... (throw (ex-info {:foo "bar"})) works > fine. ~BG > > On Sun, Feb 17, 2013 at 10:05 PM, vemv > > wrote: > > Couldn't clojure.lang.ExceptionInfo

Re: RC 16: Last chance to test against Clojure 1.5 before it ships

2013-02-17 Thread vemv
Couldn't clojure.lang.ExceptionInfo be imported by default? That'd surely help making ExceptionInfo the idiomatic exception to be thrown. On Thursday, February 14, 2013 4:33:42 AM UTC+1, stuart@gmail.com wrote: > > If you care about Clojure 1.5 compatibility for your codebase, please test >

Re: STM in Clojure vs Haskell, why no retry or orElse?

2013-02-16 Thread vemv
You can increase the chances of generating discussion by boiling down both the relevant content of paper and your program to a minimal, self-contained form. Cheers - Victor On Friday, February 15, 2013 4:05:09 PM UTC+1, thattommyhall wrote: > > A few months ago I reread Simon Peyton Joneses art

Re: Looping and accumulation

2013-02-14 Thread vemv
You want either `reduce` or `loop` as the control flow construct, and `conj` for appending items to a collection (without resorting to mutability). Have a look at them, they're pretty well covered in the available books, tutorials etc. Hope it helps - Victor On Friday, February 15, 2013 12:11

Re: Why is this so difficult?

2013-02-14 Thread vemv
12:26:15 AM UTC+1, Jules wrote: > > Sure, but you have assumed that you have a perfectly working clojure > environment set up. *That* is the hard part. > > On Friday, February 15, 2013 12:19:34 AM UTC+1, vemv wrote: >> >> I never tried out core.logic. This is how I

Re: Why is this so difficult?

2013-02-14 Thread vemv
I never tried out core.logic. This is how I just got it "installed" in less than a minute. Really no magic here: lein new foo; cd foo # google "core.logic", grab the dependencies vector ([org.clojure/core.logic "0.7.5"]), attach it to your project.clj lein repl (use 'clojure.core.logic)(run* [q

Pretty-printing `lein test`s output?

2013-02-14 Thread vemv
First of all, I must say I'm new to testing in Clojure. My current workflow is pretty simple: * Edit + save the tests (which use clojure.test - I hear Midje is better though) in emacs * Run `lein test` in the terminal * recur But then the printed values (triggered when e.g. an `are` case fails)

Re: `let` to automatically add metadata / fn names?

2013-02-10 Thread vemv
Glad to hear that Phil! You're entirely right - I didn't realise that distributing jar to Java consumers doesn't imply AOT-compiling the libraries at all. David, on your implementation - I may be missing something, but why not just vary-meta each collection found in the bindings? Also, it migh

Re: `let` to automatically add metadata / fn names?

2013-02-09 Thread vemv
ndencies false}} Does it sound good enough? On Friday, February 8, 2013 6:18:54 PM UTC+1, vemv wrote: > > Given that: a) fns can have names for debugging purposes, and b) data > structures can have metadata, wouldn't it be a good idea to let let auto > attach (where possible

Re: `let` to automatically add metadata / fn names?

2013-02-09 Thread vemv
> > Going the build route, probably use maven to produce debug and production > artifacts of differing versions: blah-1.0.0-DEBUG.jar and blah-1.0.0.jar. > My thoughts too. And there's no need for convention madness - e.g. Leiningen could transparently create those versions to the user: the

Re: Clojure - Python Style suggestion

2013-02-09 Thread vemv
> > I like the parentheses better. My only complaint is that I have to press > the shift key to type them. > You can always remap your keyboard / keyboard bindings. For example in emacs: (define-key clojure-mode-map "9" 'paredit-open-round) -- -- You received this message because you are su

Re: Building a REST API / efficient RPC interface in Clojure

2013-02-09 Thread vemv
> > Define an API in terms of messages > I'm not familiar with the concept - just out of curiosity, what does a mesagge-based API consist of? Is the drastically different from most REST/JSON web APIs out there? Thank you - Victor -- -- You received this message because you are subscribed t

`let` to automatically add metadata / fn names?

2013-02-08 Thread vemv
Given that: a) fns can have names for debugging purposes, and b) data structures can have metadata, wouldn't it be a good idea to let let auto attach (where possible) the names of the bindings to their corresponding values? For example, the improved let I'm thinking of would translate this inpu

Re: What people want from Clojure error messages

2013-01-24 Thread vemv
repl-y (Lein's default repl) only shows the first line of the stack trace rather than the whole thing. nrepl.el can optionally behave the same. It's a good default - as I see it, it relieves 90% of the pain associated to errors in clojure. As for the contents of those first-lines - it often is

Re: iOS and Windows RT support?

2013-01-24 Thread vemv
The issue is more like, Apple forbids using development tools other than those they foster. Relatively succesfull efforts have been made to compile Clojure to ObjC, but they aren't legally usable in practice. On Tuesday, January 22, 2013 8:27:51 PM UTC+1, JSchmitt wrote: > > On Tue, Jan 22, 201

Re: emacs - how to wean me off the family of Java IDEs

2013-01-16 Thread vemv
The traditional project explorer / directory tree I use is dirtree: https://github.com/zkim/emacs-dirtree - with a couple of tweaks I found it to be very useful. It is based on tree-mode. There are other available file browser plugins based on it. -- You received this message because you are

What would you use a #[] data literal for?

2012-12-28 Thread vemv
I was just wondering - given that we have the #() and #{} literals, why not a #[] as well? Queues look like a good fit. -- 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

Conflation and objectivity

2012-12-21 Thread vemv
> > "One man's composition is another's conflation" - someone on Twitter > I don't necessarily agree with the opening quote, but I thought it was an interesting one :) It is not uncommon to hear/read from the Clojure commmunity that "X complects a with b", hence X is bad, without giving furthe

Re: Who's using Clojure?

2012-12-15 Thread vemv
Surely because Fogus was in process of upgrading it :D go check it out now! http://dev.clojure.org/display/community/Clojure+Success+Stories On Friday, December 14, 2012 3:34:23 PM UTC+1, Jeff Heon wrote: > > I'm asked to log in now to access this page. > > On Thursday, April 28, 2011 11:03:53 P

Re: import blah.*

2012-11-26 Thread vemv
Thanks for the answer Herwig! swank-clojure and nrepl(.el) can do pretty amazing things. But in my opinion, at least in the context of Java interop there is still work left to do... Lastly, as of today, what can clojurescript do that clojure can't? On Saturday, November 24, 2012 11:36:50 PM UT

Re: import blah.*

2012-11-24 Thread vemv
While coarse-grained imports are pretty obviously a suboptimal practice, I believe the lack of some this possibility (in at least some form) hinders exploratory programming / API discoverability. Would it be feasible to add an :as directive to 'import? An use case: ; --- state of the editor at

Re: Can't start clojurescript browser-connected repl

2012-10-29 Thread vemv
Hi Tim, I followed your recipe and unfortunately it doesn't work - one keeps waiting for the output at the repl. The `foo` namespace seems to be loaded twice. So I modified index.html to load main.js only. This doesn't fix the issue though. Could you please verify this? Thanks - Victor On We

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Hi Matthias, I can't disagree with you, and am open to change my mind. Just a question. Given again this example: (ns protocols) (defprotocol P (get [_])) (ns app) (defrecord R [] protocols/P (get [_] 42)) (can you call R's get without resorting to dot-notation, this is, with a na

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Would it be feasible to efficiently make them first class? Surely this isn't a new question, as many would desire to write (mapv .toString (range 10)) rather than (mapv #(.toString %) (range 10)). Couldn't find info on that topic... *(just an example, I know there's str) On Monday, September 3

Re: Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Correction: records/types actually include plenty of dot-accesible methods, though less than lists -for instance- do. (mapv println (.getMethods (.getClass (ARecord. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Protocol methods, name shadowing and dot notation

2012-09-03 Thread vemv
Hello there, I'm not quite sure whether is convenient for each method implementation to possibly shadow previous names, particularly those of clojure.core. (defprotocol Example (get [this])) The previous example redefines get in the current namespace. But is that we usually mean by "me

Re: Question about sets

2012-09-02 Thread vemv
This issue best illustrates how imperative and functional thinking differ. When I write code such as (map not [true false]) , I implicitly think imperatively: "compiler, please traverse this collection, applying 'not to each element...". I could also word my thoughts functionally: "I desire the

Re: Rich's "The Value of Values" and REST

2012-08-23 Thread vemv
There are few -if any- concepts attached to REST; it is just a low-level, "ideologically"-neutral technique. There is more than one way to do it, hence you really can't talk 'against' it any more than you can talk against hashmaps, for instance. That said, getting RESTful design right is pretty

Re: School Seating Charts

2012-08-07 Thread vemv
Tried it. It's not hard to see how it can be one little practical app worth its price. Thanks for sharing Evan! -- 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 mem