Debugging a custom reader literal for a sorted-set

2013-08-08 Thread David James
I am having trouble with an implementation of a custom reader literal called #sorted-set. Please see my short code first: https://github.com/xpe/sorted-map-literal Why does this work correctly: (to-sorted-map '(1 2 3 4)) #sorted-map (1 2 3 4) ; correct While this does not? #sorted-map (1 2 3 4)

Re: Debugging a custom reader literal for a sorted-set

2013-08-08 Thread David James
That's a good point about: user=> eval (to-sorted-map '(1 2 3 4))) {1 2, 3 4} But this should work, right? user=> (assoc #sorted-map (:a 1 :b 2) :c 3) {:c 3, :a 1, :b 2} ; incorrect -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: Debugging a custom reader literal for a sorted-set

2013-08-08 Thread David James
e.lang.PersistentArrayMap > user=> (class (read-string "#foo/sm (1 2 3 4)")) > clojure.lang.PersistentTreeMap > > It's quite puzzling. In both cases the evaluation does not take place, but > still the transition to PersistentArrayMap occurs. > > JW >

Re: Debugging a custom reader literal for a sorted-map

2013-08-09 Thread David James
>> [1 2 3 4]) >> #'user/x >> user> x >> (quote (1 #sorted-map (1 2 3 4))) >> user> (.eval (clojure.lang.Compiler/analyze >> clojure.lang.Compiler$C/EXPRESSION x)) >> (1 #sorted-map (1 2 3 4)) >> user> (eval x) >> (1 {1 2, 3

Heuristic search: convenient memoization?

2015-01-26 Thread David James
Background: I'm implementing a heuristic search over a tree of possibilities. The heuristic calculation runs over a map of state. I have a large number of nested functions that support this heuristic. So, for convenience, I often pass around `state` as the first argument in these functions. Ins

Re: Convenient memoization with destructured arguments

2015-01-26 Thread David James
I just renamed the subject line since my question has nothing inherently to do with heuristic search. (That was just my particular use case.) This kind of thing can happen in any codebase where destructuring of function arguments is used. On Monday, January 26, 2015 at 12:16:04 PM UTC-5, David

Re: Convenient memoization with destructured arguments

2015-01-27 Thread David James
Thanks for mentioning it, Rob. (I have looked at Prismatic Graph before. Putting arguments in a graph (at macro time) is a powerful idea; plumbing uses this to offer a declarative way to offer various evaluation strategies. It is nice to show off Clojure macros! In this case, it makes Clojure f

Re: Resources don't work in uberjar

2015-01-27 Thread David James
You may find value in reading this: From: http://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html > Methods in the classes Class and ClassLoader provide a location-independent way to locate resources. On Tuesday, January 27, 2015 at 9:12:23 AM UTC-5, Benjamin VanRyseghem wrot

Re: OO Programmer trying to move to Clojure: Namespace Organization

2015-02-08 Thread David James
I often group functions that operate on similar data structures together in a namespace. This isn't always clear-cut, because some functions may "fit" in more than one namespace. I sometimes use a (soft) convention to group functions by the first argument. Yes, this means that my Clojure project

Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-18 Thread David James
Summary: I'd like to find a public API to work with the underlying tree of a sorted-map. For example: (def t (sorted-map 1 :a 2 :b 3 :c 4 :d 5 :e 6 :f)) The underlying implementation of sorted-map uses a PersistentTreeMap, which can be accessed with `tree`: (.tree t) ;=> [2 :b] I have not f

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-19 Thread David James
ableMap and NavigableSet interfaces could be > done by using the existing subseq and rsubseq functions in clojure.core? > > It doesn't give you access to subtree nodes directly, but perhaps it is > sufficient for your purposes? > > Andy > > On Wed, Feb 18, 2015 at 6:04 PM,

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-19 Thread David James
> > If you don't want it soon, you could try persuading a few dozen people to > vote on CLJ-1008, and hope the Clojure developers also want this change. > No guarantees there. > > Andy > > On Thu, Feb 19, 2015 at 12:18 PM, David James > wrote: > >> An

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-20 Thread David James
Thanks for your comments. I see now that I should clarify: all I really need is public access to the left and right Java methods in PTM. (So, perhaps CLJ-1008 is asking for more than I really need.) It seems to me that since Clojure's RB-Tree implementation (i.e. sorted-map = PTM), it might as

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-20 Thread David James
stly around the > possibility that a slice, say, removes an endpoint of an interval – you may > need to add the slice boundary as a replacement in that case). > > Cheers, > Michał > > > On 20 February 2015 at 16:15, David James > wrote: > >> Thanks for your comme

Re: Deterministic macro expansion for Clojure?

2015-03-27 Thread David James
I agree with this motivation behind this request, which I explain in more detail here: http://stackoverflow.com/questions/16745135/how-to-test-a-clojure-macro-that-uses-gensyms We should be able to test the behavior *and* the macroexpansion. (Most things in life are not simple either/or decisi

Re: Deterministic macro expansion for Clojure?

2015-03-30 Thread David James
(let [counter (atom 0)] > (fn [& [extra]] (symbol (str (or extra "G_") (swap! counter inc)) > > (with-redefs [gensym (new-gensym)] (macroexpand-1 '(m1 1 inc))) > > (not tested) > > On Fri, Mar 27, 2015 at 5:50 PM, David James > wro

Re: A more flexible versio of -> ?

2015-05-05 Thread David James
In addition to the Swiss Arrows library, I'd also suggest the shield blazoned with a green arrow on a white bend on green from the House Sarsfield of Sarsfield, a noble house from Sarsfield in the Westerlands: http://awoiaf.westeros.org/index.php/House_Sarsfield On Tuesday, May 5, 2015 at 9:37:

Re: What does ^:internal mean?

2015-05-12 Thread David James
Re: "Some people don't like the native approach to private vars since anyone who wants to override it can do so anyway, so they go with a purely conventional and unenforced approach: delineate the boundaries of API vs internal using :internal or :impl and/or put the internal bits in an impl nam

Re: Need advice/idiom to reduce number of parameters in functions

2015-05-13 Thread David James
Well, this is question many people ask. :) It is a matter of tradeoffs: - Too many arguments may be an aesthetic problem. It may also reflect a design problem; you might be able to rethink a system to simplify it. (What "too many" means is debatable.) - With many arguments, you may c

Re: ANN: ClojureScript 0.0-2411

2014-12-05 Thread David James
I'm getting the following warnings from `lein cljsbuild auto`. Anybody else? WARNING: Use of undeclared Var cljs.core.async/do-alts at line 62 file:/Users/david/.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async/impl/ioc_helpers.clj

Re: ANN: ClojureScript 0.0-2411

2014-12-07 Thread David James
Thanks. Problem solved. On Saturday, December 6, 2014 5:34:53 AM UTC-5, David Nolen wrote: > That's an issue with core.async. Make sure you have the latest. If you do, > please file an issue for core.async. -- You received this message because you are subscribed to the Google Groups "Clojure" g

Questions about Clojure 1.7 Release / Process / Helping Out

2014-12-30 Thread David James
I'm curious about the future Clojure 1.7 release. I recently looked over these pages: - Clojure JIRA Workflow - Contributing to Clojure - Next Release Planning

Re: Questions about Clojure 1.7 Release / Process / Helping Out

2014-12-30 Thread David James
Andy and Alex: Thanks for the answers! -- 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 unsubscri

Compiling gen-class runs static initializers: workarounds, solutions?

2015-01-02 Thread David James
I have a problem when compiling while using gen-class with static initializers. I use gen-class to extend a JavaFX 8 class, javafx.scene.control.Control. During compilation, a static initializer is run, raising an exception saying that the JavaFX toolkit has not been initialized. I'm going t

Using dev/user.clj breaks java compilation

2015-01-02 Thread David James
I noticed this issue which I'm currently facing: https://github.com/technomancy/leiningen/issues/1477 Technomancy commented in the issue: "This appears to be a bug in Clojure causing an incorrect error message that's masking the actual issue. What's happening here is that the javac task is invok

Re: A (foolish) plan to re-invent IO on top of core.async

2015-01-05 Thread David James
In case you are interested in a recent example, I wrote an NIO.2 based Riak client in Clojure without Netty. https://github.com/bluemont/kria It uses callback functions, so the consumer can do whatever they want; such as core.async. I agree with Timothy, above. My take-away from the experience

[ANN] Kria, an async driver for Riak 2

2014-03-06 Thread David James
Kria (a right rotation of "Riak") is an asynchronous Clojure driver for Riak 2.0 built on top of Java 7's NIO.2. It uses Riak's protocol buffer interface. https://github.com/bluemont/kria https://clojars.org/kria In my work projects, we have found that core.async works great as a layer on top of

Re: [ANN] Kria, an async driver for Riak 2

2014-03-11 Thread David James
I started Kria in January I think. It has tests, and I use in for (currently small) but real projects. It works great so far for me. I'd appreciate it if you try it out. On Fri, Mar 7, 2014 at 9:24 PM, dgrnbrg wrote: > This is really exciting! One question I have is how mature is Kria? Given >

Remote function calls / simple distributed computation

2014-05-25 Thread David James
What are the ways to do remote function calls with Clojure? Here is a *low-level list* I have so far: * Java Remote Method Invocation API: http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/index.html * nREPL: https://github.com/clojure/tools.nrepl There are *higher-level tools*, too, such

Re: Where did the chunked sequence presentations go?

2014-05-26 Thread David James
+1. I can't find these online. On Saturday, June 8, 2013 9:43:26 AM UTC-4, David Williams wrote: > > Hi all, > > I'm interested in Rich Hickey's chunked sequence presentation but both the > video and the pdf seem to have been taken down. What happened to those and > where can I hear a good disc

Feedback on destructuring code walkthrough? (could not nest :keys inside :keys)

2013-11-22 Thread David James
I made a quick destructuring code walkthrough at https://github.com/xpe/clj-destruct/blob/master/src/destruct/core.clj I was hoping to show how to nest :keys inside of :keys but failed. Did I overlook something? -- -- You received this message because you are subscribed to the Google Groups "

Re: Feedback on destructuring code walkthrough? (could not nest :keys inside :keys)

2013-11-23 Thread David James
1 b2] :as b} :b}] [a b1 b2 b]) > > (foo {:a 1 :b {:b1 2 :b2 3}}) > ; => [1 2 3 {:b2 3, :b1 2}] > > On 22 November 2013 19:06, David James > > wrote: > > I made a quick destructuring code walkthrough at > > https://github.com/xpe/clj-destruct/blob/master/src/dest

Auto-reloading static HTML resource with Enlive + Pedestal

2013-12-07 Thread David James
I took a stab at trying to answer this but hit a wall. http://stackoverflow.com/questions/20108899/enlive-template-auto-reload-detect-changes-in-a-pedestal-service/20447481#20447481 What are we missing? Thanks, David -- -- You received this message because you are subscribed to the Google Gro

[ANN] Example async TCP echo client/server using Java 7 NIO.2.

2013-12-19 Thread David James
of nesting, which led to some minor callback hell. The scoping is clearer that way, even if the program flow is not. I would expect that different people would have different preferences. I would be interested to see other ways of handling it (like core.async, perhaps?). -- David James http://bluemo

Possible heisenbug in test suite (not in individual test runs) with memoization

2014-01-06 Thread David James
I've got a Clojure test suite that fails when run as whole but passes when run piecemeal. This just started happening. I've tested the code thoroughly. The bug pops up in a part of the code that I did not change. So, at present, it feels like a heisenbug! These may be some relevant pieces: * I'm u

Re: Possible heisenbug in test suite (not in individual test runs) with memoization

2014-01-16 Thread David James
1M does not necessarily equal 1 >> (a Long): >> >> > (= 1 1M) >> false >> > (== 1 1M) >> true >> >> Your memoized functions could be recomputing values unnecessarily if >> you're giving them different types of numbers. >> >>

Suggestion: add `into` on clojure.org/data_structures page

2013-01-06 Thread David James
I noticed that `into` is not currently mentioned on http://clojure.org/data_structures How do community-suggested documentation changes work? Is there a wiki? Auto-generated docs from source? Thanks, David -- You received this message because you are subscribed to the Google Groups "Clojure" gr