Re: Benefits to partial functions.

2019-10-20 Thread John D. Hume
It's been a long time since I looked at this, but as of a few years ago, the biggest noticeable performance detriment of comp or partial was likely to come if you pass enough args to hit a "& args" overload, which requires creating a fresh object array at each call, when the underlying function

Re: Expected inconsistency between set and map w/ ArrayList?

2014-05-12 Thread John D. Hume
On Mon, May 12, 2014 at 12:53 PM, Alex Miller a...@puredanger.com wrote: My recommendation in Java would be the same - using mutable objects as keys in a map (where mutability changes the hashcode) is a bug waiting to happen. Although I used java.util.ArrayList in the sample REPL session

Expected inconsistency between set and map w/ ArrayList?

2014-05-09 Thread John D. Hume
Is this behavioral change in Clojure 1.6.0 expected? Under 1.6.0, a set and a map seem to treat a java.util.ArrayList differently with respect to its equivalence to a vector. https://gist.github.com/duelinmarkers/7c9f84cfc238e5d37a09 user= (- {} (assoc [1 2] vec) (assoc (java.util.ArrayList. [1

Name for this pattern: side-effect from swap!

2014-04-08 Thread John D. Hume
I sometimes find that after mutating an atom, I want to create some side-effect that depends on the old and new state as well as the context in which the change was made. Because of the dependence on context, a watch doesn't work (unless there's something I'm not thinking of). So I add things to

Re: (series of swap! on atom) == single swap!

2014-02-15 Thread John D. Hume
On Sat, Feb 15, 2014 at 6:04 PM, t x txrev...@gmail.com wrote: (defn what-I-want [] (with-atom some-atom assoc-in ... assoc-in ... update-in ...)) I often do something like this and don't find it too ugly: (swap! my-atom #(- % (assoc-in [:k] v)

Re: ISeq documentation and mutual deftypes.

2014-02-11 Thread John D. Hume
On Feb 11, 2014 4:41 AM, Phillip Lord phillip.l...@newcastle.ac.uk wrote: Is the only place this is written down is by working reading the implementing classes? I believe so. Other than the new (and quite minimal) Java API for calling Clojure code[1], the details of Clojure's underlying Java

Re: ISeq documentation and mutual deftypes.

2014-02-11 Thread John D. Hume
On Tue, Feb 11, 2014 at 7:32 AM, Phillip Lord phillip.l...@newcastle.ac.ukwrote: John D. Hume duelin.mark...@gmail.com writes: Other than the new (and quite minimal) Java API for calling Clojure code[1], the details of Clojure's underlying Java classes are considered implementation details

Re: article about namespace still current?

2014-02-08 Thread John D. Hume
It includes this update, which I'd say brings it up to date. *update (4/18/2012):** As of the 1.4.0 release, there's no longer a good reason to use use. Use require :refer instead. From the Clojure 1.4.0 * *changelog**: require can now take a :refer option. :refer takes a list of symbols to

Re: Refactoring as an nREPL middleware

2014-02-07 Thread John D. Hume
I haven't attempted any code manipulation, just analysis and indexing, but I embarked on a similar idea here: https://github.com/duelinmarkers/insfactor and here: http://github.com/duelinmarkers/insfactor.el. (Nothing Vim-related there, the similar part is trying to put as much as possible of the

Re: map semantics

2014-02-07 Thread John D. Hume
On Fri, Feb 7, 2014 at 9:41 PM, Andy C andy.coolw...@gmail.com wrote: I do perceive sets, lists, vector as atoms which are indivisible (well, this is not true but this is popular meaning) from semantics standpoint. Therefore map is just a function which processes them as whole, again from

Re: Lessons Learned from Adopting Clojure

2014-02-05 Thread John D. Hume
On Wednesday, February 5, 2014, Sean Corfield wrote: It's one of the things that has me really hooked on LightTable. I have my source and test namespaces both open. I have them both connected to a REPL. I can evaluate any code, in place, in either file. If I grow some code in the source

Re: Lessons Learned from Adopting Clojure

2014-02-05 Thread John D. Hume
On Wed, Feb 5, 2014 at 1:27 PM, Sean Corfield s...@corfield.org wrote: On Feb 5, 2014, at 5:39 AM, John D. Hume duelin.mark...@gmail.com wrote: Could you clarify the difference between LightTable's M-) and using C-M-x* in Emacs jacked into an nrepl session with Cider? M-) is paredit-forward

Re: Profiling, VisualVM random-pause

2014-01-22 Thread John D. Hume
On Tue, Jan 21, 2014 at 1:50 PM, Yves Parès limestr...@gmail.com 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

Re: type hinting overloaded methods

2013-12-10 Thread John D. Hume
On Tue, Dec 10, 2013 at 4:25 AM, Phillip Lord phillip.l...@newcastle.ac.ukwrote: (defn ^IRI iri [name] (cond (instance? String name) (IRI/create ^String name) (instance? java.net.URL name) (IRI/create ^java.net.URL name) (instance? java.io.File name) (IRI/create

Re: error-on-reflection

2013-12-09 Thread John D. Hume
Are you aware of `lein check`? We have our some of our CI builds wired to fail if that finds anything. On Dec 9, 2013 4:12 AM, Phillip Lord phillip.l...@newcastle.ac.uk wrote: I know about *warn-on-reflection* but is there anyway that I can get an error-on-reflection instead? I've been type

Re: [Clojure-CLR] implement interface that has properties

2013-12-09 Thread John D. Hume
If I recall, properties are just syntactic sugar for awkwardly named methods. Have you tried the compiler-generated get and set method-names? On Dec 9, 2013 9:50 AM, Frank Hale frankh...@gmail.com wrote: I'm trying to implement an interface that has properties but can't quite seem to get it to

Re: expand a form

2013-11-25 Thread John D. Hume
You won't find the results as easy to read as what you're asking for, but clojure.tools.analyzer will show you calls that have been inlined by the compiler. On Nov 25, 2013 2:24 PM, Andy Smith the4thamig...@googlemail.com wrote: In your example a full expansion might be : (. clojure.lang.Numbers

Re: java.jdbc DSLs (java.jdbc.sql / java.jdbc.ddl)

2013-11-23 Thread John D. Hume
On Nov 22, 2013 4:09 PM, Sean Corfield seancorfi...@gmail.com wrote: Perhaps a solution here is for me to put it in a library, on Clojars, under a different name and let folks migrate to that as an interim solution (i.e., identical API so folks would just update project.clj and update some ns

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread John D. Hume
! withdraw!. I don't see how else this can be done since they are refs. I would appreciate feedback for this (hopefully) last version... many thanks in advance :) Jim On 21/11/13 13:19, John D. Hume wrote: If you want to demonstrate STM with the deposit-withdraw-transfer example, you definitely

Re: preferred way to dereference a ref: outside or inside dosync?

2013-11-21 Thread John D. Hume
If you want to demonstrate STM with the deposit-withdraw-transfer example, you definitely need a ref for each account. I'd suggest an atom for the account-num-balance-ref map (the bank) and an atom for the account-num-generator, but you say coordination is necessary for opening and closing

Re: first vals first vals

2013-11-21 Thread John D. Hume
On Nov 21, 2013 3:32 AM, Zhemin Lin lin.zhe...@gmail.com wrote: What if :cf, :cq are not fixed, and I don't really care about the keys, but only the value of the value of the value ...? Maps seem an awkward choice of data-structure for a scenario where you don't know or care about the keys. --

Re: Generating functions from data

2013-11-19 Thread John D. Hume
After some experience with excessively meta-programmed Ruby apps, I generally try to design an API that is as clean (or almost) as what I'm tempted to generate and avoid the metaprogramming. For example (api/get-user-by-id 123) is only slightly nicer than (api/get-by-id :user 123), so if the

Re: Design question - dependencies and function discovery

2013-11-18 Thread John D. Hume
Rather than having hidden mutable state for wiring events to handlers, would it be clearer if the main namespace just passed an :event-[handlers] map to the event processor? If that would create a huge, frequently changing data structure, each namespace with handlers could expose an

Re: [ANN] datasource 0.1 - Small clojure library for access to environment dependent configuration.

2013-11-14 Thread John D. Hume
One piece of feedback: the name datasource is confusing, given javax.sql.DataSource, as seen, for example, at http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html# setting-up-a-data-source On Thu, Nov 14, 2013 at 10:09 AM, Andrey Antukh n...@niwi.be wrote:

cider status

2013-11-12 Thread John D. Hume
The last (non-authoritative) word on cider on this mailing list[1] was that it is unstable. Is that really the case? Is it just a matter of many packages that depend on it not being updated? I tried checking the official mailing list[2] and was surprised to find that it's private. I'm trying to

Re: [ANN] Yesql 0.2.1 - Clojure SQL queries rethought.

2013-11-11 Thread John D. Hume
For me, the one feature that can justify an internal DSL for generating SQL is the ability to compose queries. I assume that's not on the Yesql roadmap. On Nov 11, 2013 5:10 AM, Kris Jenkins krisajenk...@gmail.com wrote: https://github.com/krisajenkins/yesql Yesql is a simple library for

Re: Compulsive over-optimization

2013-10-18 Thread John D. Hume
What kind of optimal do you compulsively rearrange for? Performance? Readability? Amusing terseness? On Oct 18, 2013 6:20 PM, Kendall Shaw ks...@kendallshaw.com wrote: With clojure in particular, I am having trouble not rearranging my code to be what I think is more optimal in ways that seem

Re: finding a call to longCast

2013-10-15 Thread John D. Hume
If you have some idea where to look in your code, or if there isn't much code, I'd take a look at clojure.tools.analyzer/analyze-ns[1]. The output is a little overwhelming, but it's pretty easy to navigate in clojure.inspector. One issue may be finding the call (e.g. to some clojure.core fn) that

Re: use lein compile a Java project

2013-10-11 Thread John D. Hume
I believe :dependencies and :resource-paths will be used for the classpath at both build and run time. Does that meet your needs? On Fri, Oct 11, 2013 at 8:00 AM, Gaofeng Zeng ndtm.i...@gmail.com wrote: How use lein compile a Java project? I know the java-source-paths can specify the src

Re: [ANN] Grenchman, for running Clojure code quickly

2013-10-09 Thread John D. Hume
On Wed, Oct 9, 2013 at 2:32 AM, Zack Maril thewitzb...@gmail.com wrote: How does this vary from flatland/drip? -Zack Grenchman connects to a JVM-with-nrepl you previously launched. Repeated invocations from the command line will hit that same JVM, potentially building up state over time, and

Re: How to go about 'proving' why dynamically typed languages are better.

2013-10-08 Thread John D. Hume
On Oct 8, 2013 5:35 AM, Phillip Lord However… I find that I am writing a lot of statements like this: (cond (hash-map? v) …… (vector? v) …… (list? v) ….. :else …..) zcaudate, in what context(s) do you

Re: Teaching Clojure to students (how ?)

2013-10-07 Thread John D. Hume
On Oct 7, 2013 3:29 AM, Phillip Lord phillip.l...@newcastle.ac.uk wrote: Tend to agree with this also. As nice as leiningen is, Clojure seems to inherit from Java bulky projects. Compare these two hello worlds: (println hello world) to #!/usr/bin/python print( hello world ) Both

Re: Who uses HtmlUnit?

2013-10-06 Thread John D. Hume
WebDriver's HtmlUnitDriver is only one of many supported drivers. Most Selenium-using teams I've been on have driven real browsers using another driver (which among other benefits allows one to generate realistic screen shots). The one team I was on that used HtmlUnit (a couple years ago) blamed

Re: Type of let form

2013-10-04 Thread John D. Hume
This seems intentional, not a case of docs lagging behind. If you look at the source of let you can see that it has :special-form true in its metadata so that it will remain documented as special even though it's just a macro. I assume the thinking is that it's more useful to continue to document

Re: Type of let form

2013-10-04 Thread John D. Hume
else is fair-game, with java bits being a clear delineation of host-specific functionality. On Fri, Oct 4, 2013 at 4:20 PM, John D. Hume duelin.mark...@gmail.comwrote: This seems intentional, not a case of docs lagging behind. If you look at the source of let you can see that it has :special

Re: Jsonify a Jdbc4Array in Clojure

2013-10-02 Thread John D. Hume
I believe it was on the clojure-docs page (linked from the clojure.java.jdbc readme) where they talk about managing your own connection. The more idiomatic way may be to wrap the whole thing in some transaction fn or macro. Sorry I'm not familiar with the API. A lot of vars are deprecated, but

Re: Jsonify a Jdbc4Array in Clojure

2013-10-01 Thread John D. Hume
I don't use clojure.java.jdbc, so this may be non-idiomatic or just wrong, but have you tried something like (with-open [connection (jdbc/db-connection *db*)] (json/write-str (jdbc/query {:connection connection} [SELECT * FROM...]))) On Tue, Oct 1, 2013 at 8:13 PM, Christian Jauvin

Re: Type hints for clojure.set functions

2013-09-28 Thread John D. Hume
On Sep 28, 2013 1:47 PM, splondike splond...@gmail.com wrote: Can anyone else think of a reason why we should not add type hints to the functions, or why coercing the arguments to sets is better (or something else I haven't thought of)? IIRC, type hints are only used by the compiler to generate

Re: Handling name collisions with clojure.core

2013-09-07 Thread John D. Hume
I haven't tried this, so apologies if it couldn't even work, but have you considered providing a fn in your library intended to be used inside the ns macro? The refer-clojure :exclude boilerplate could be replaced with something like this. (ns my-thing (:require core.matrix.ns)

Re: Java Metadata Wrapper

2013-08-30 Thread John D. Hume
On Fri, Aug 30, 2013 at 2:16 PM, JvJ kfjwhee...@gmail.com wrote: Would it be possible (or even useful) to create some kind of generic IMeta structure that can wrap other Java objects and have them act like normal, except for the added metadata (or even other Clojure-esque features)? Are you

Re: problem with edn

2013-08-22 Thread John D. Hume
On Aug 22, 2013 6:25 AM, Jim jimpil1...@gmail.com wrote: this is funny! I thought about this approach but I originally considered it to be a clever hack rather than the official way to do this... If you need some data persisted or sent over the wire, then it should probably be considered part of

Re: problem with edn

2013-08-22 Thread John D. Hume
On Aug 22, 2013 2:19 PM, Softaddicts lprefonta...@softaddicts.ca wrote: Jim, This is indeed a hack and not a best practice, maybe you're not using the right tool for your problem... - If you want to exchange data (think values), you should not be in need of keeping types and meta

Re: tools for minimizing forward declaration

2013-08-19 Thread John D. Hume
On Aug 19, 2013 5:53 AM, Phillip Lord phillip.l...@newcastle.ac.uk wrote: That would be true, if I knew what my code was going to do when I started. But most of my code is used to investigate things that I don't understand; so it evolves slowly over time. I don't know when I start what

Re: function creation, partial or #()

2013-08-13 Thread John D. Hume
Though in some cases the performance impact could be significant, my concern is readability. My understanding of the concept of partial function application is that it's about supplying some but not all of the arguments. So when I see `partial` in code, I expect more arguments to be supplied

Re: Making Music with Clojure: Meta-eX

2013-08-08 Thread John D. Hume
Great demonstration. I'd love to have the camera video side-by-side w/ screencast video (and large enough to read your code as you play). On Thu, Aug 8, 2013 at 9:16 AM, Sam Aaron samaa...@gmail.com wrote: Hey everyone, I just thought I'd give you a heads up of what I'm currently doing with

Re: ANN: paredit-widget, simple swing-based clojure paredit widget

2013-08-05 Thread John D. Hume
On Mon, Aug 5, 2013 at 8:37 PM, kovas boguta kovas.bog...@gmail.com wrote: https://github.com/kovasb/paredit-widget The bigger idea is that code editing should be available a la carte. Tying something as fundamental as code editing together with IDE concerns (file project management,

Re: core.async: throwing an exception into the channel

2013-08-01 Thread John D. Hume
I think I'd rather see separate functions or macros for consuming from a channel with the maybe throw behavior rather than having the standard consume form(s) come with that feature (or threat, depending on whether you want it). At that point you're back to the earlier advice to wrap core.async to

Re: clojure keyword spec

2013-07-31 Thread John D. Hume
It's probably worth distinguishing between the spec as documented on clojure.org (or https://github.com/edn-format/edn if you prefer) and what the reader permits. Symbols are documented to begin with a non-numeric character (with a special note in the EDN spec about the names of namespaced symbols

Re: [ANN] verily, non-magic testing lib

2013-07-24 Thread John D. Hume
I've never tried it, but I like the idea of test fns returning their results. On Jul 24, 2013 8:30 AM, Steven Degutis sbdegu...@gmail.com wrote: Also, I've been considering having a non-side-effecty way of returning test results. What do people think? It would get rid of the last bit of magic

Re: - macro and accessing context

2013-07-02 Thread John D. Hume
I believe the intended idiom for as- (and the reason it doesn't take a binding vector, like other forms that create locals) is (- {} (assoc :a a) (as- ctx (assoc ctx :b (some-fn ctx On Jul 2, 2013 1:12 AM, Meikel Brandmeyer (kotarak) m...@kotka.de wrote: Hi, since 1.5 there is

Re: reset! and merge for (transient {})

2013-07-02 Thread John D. Hume
Note that `merge` is basically just `conj` plus nil-checking, so there's a good chance `conj!` already does what you need. On Jul 2, 2013 5:33 AM, Amir Wasim amir.wa...@gmail.com wrote: Is there reset! and merge a possibility for (transient {}) sometimes we have a doseq and it might be

Re: Is there a better way to update a map atom?

2013-06-29 Thread John D. Hume
It's worth knowing that the moment is implemented via a compare-and-set, and if the value has been changed (by another thread), the fn you passed to swap! will be called again with the atom's new value. On Jun 28, 2013 11:57 PM, Greg g...@kinostudios.com wrote: OK, I've found something that

Re: representing clojure source code as data?

2013-06-23 Thread John D. Hume
On Jun 23, 2013 1:43 AM, kovas boguta kovas.bog...@gmail.com wrote: what about the other cases? Random java objects and whatnot. Those should be output in an EDN way, though its unclear what they would mean when read. Would there be any attempt to convey their contents or characteristics?

Re: Function returns nil

2013-06-21 Thread John D. Hume
If you use for, which is lazy, wrap it in a doall to force it to do its work before with-open closes your reader. On Jun 21, 2013 6:52 AM, Jim jimpil1...@gmail.com wrote: Only use 'doseq' when you don't care about the reuturn value. In other words only for side-effect-y code. Use 'for'

Re: Why does peek on a seq of vector fail?

2013-06-20 Thread John D. Hume
On Jun 20, 2013 3:11 PM, Jason Gilman jason.gil...@gmail.com wrote: (defn bar [my-list n] (if (= n 0) (peek my-list) (bar (rest my-list) (dec n (bar [1 2 3] 1) It seems likely you want either first and rest* (to work from the front of any seqable) or peek and pop (to work

Re: Performance optimizations dealing with java collections

2013-06-18 Thread John D. Hume
Offhand it looks like the only RestFn you call from filter-link is clojure.core/format. Have you tried replacing that with something like this? (String/format (.get link 1) (doto (make-array String 1) (aset 0 (.get link 2))) I'm not suggesting that's idiomatic, but if it addresses the issue then

Re: with-open and for

2013-06-11 Thread John D. Hume
On Jun 11, 2013 8:25 AM, Meikel Brandmeyer (kotarak) m...@kotka.de wrote: Or another one: (defn filter-lines [rdr] (- (line-seq rdr) (mapcat #(str/split % #\s+)) (filter #(= 4 (count %) 9)) (into #{}))) (defn filter-file [filename] (with-open [rdr (io/reader

Re: clojure diffs

2013-06-06 Thread John D. Hume
One neat hidden Github feature is that if you add the query string parameter w=1 to any diff view, it will ignore whitespace-only changes (like passing -w to git diff). That doesn't help with those final lines with added or removed close parens, but it still improves readability of many diffs.

Re: A blocking lazy sequence populated by multiple worker threads

2013-05-30 Thread John D. Hume
On May 30, 2013 4:12 AM, Colin Yates colin.ya...@gmail.com wrote: ; the following would need to reify itself to be a Runnable, not got that far yet :) (defn execute [job result-queue] (let [result (job)] (.put result-queue result))) A no-args fn is both a perfectly good Callable and a

Re: Some feedback on coding style

2013-05-27 Thread John D. Hume
On May 26, 2013 8:53 PM, Mark Engelberg mark.engelb...@gmail.com wrote: Another possible design choice is to store a domain-testing predicate in the function's metadata. Using metadata would be a much more idiomatic choice than using arity. Multiple arities are idiomatically used (like method

Re: Some feedback on coding style

2013-05-27 Thread John D. Hume
purely for macroexpansion and there is no metadata available on the precondition post-macroexpansion. Thanks, Ambrose On Mon, May 27, 2013 at 9:00 PM, John D. Hume duelin.mark...@gmail.comwrote: On May 26, 2013 8:53 PM, Mark Engelberg mark.engelb...@gmail.com wrote: Another possible

Re: How to: reduce boolean operations?

2013-05-24 Thread John D. Hume
On Fri, May 24, 2013 at 1:25 PM, atkaaz atk...@gmail.com wrote: It kinda makes sense except I wouldn't have expected that on the map it would return a vector (but then how else could it return both key and value right? ) so everyone expects the input to the pred would be a vector when passed

Re: How to: reduce boolean operations?

2013-05-23 Thread John D. Hume
On Thu, May 23, 2013 at 11:30 AM, atkaaz atk...@gmail.com wrote: So all I was saying above is that it should throw when [] is empty just as it does when [] is not empty, but it doesn't throw when empty because it's never called (by it i mean false not false?) This sort of behavior is handy

Re: How to: reduce boolean operations?

2013-05-22 Thread John D. Hume
On May 22, 2013 5:35 AM, atkaaz atk...@gmail.com wrote: I find the wording of this confusing otherwise it returns the value of the last expr. (and) returns true. I mean, I know it returns the last true value, but that's because I've tested it not because the doc is trying(failing) to tell me so

Re: xslt extension functions in clojure

2013-05-15 Thread John D. Hume
In the xalan.ext :gen-class the static methods are named foo and bar but your xslt template is using the (prefixed) names of the clojure impl fns. Did you try just foo and bar instead? To be sure the class and methods are available in your test, rather than calling the clojure fns, call the

Re: Struggling with encapsulation

2013-05-10 Thread John D. Hume
I agree with the advice you've gotten, but since no one has mentioned it, I wanted to point out that you can have encapsulation w/o protocols with something like this. Assume a queue is your only state and `add` and `clear` are your private fns that take a queue as first argument. (defn

Re: Struggling with encapsulation

2013-05-10 Thread John D. Hume
across :). I say that not be snarky, but to highlight how much it really does change things. The open-closed principle now becomes much simpler to realise for example. Thanks again. On 10 May 2013 12:44, John D. Hume duelin.mark...@gmail.com wrote: I agree with the advice you've gotten

Re: ANN: kits 1.5.1 - some of Runa's core utilities

2013-05-10 Thread John D. Hume
On Thu, May 9, 2013 at 7:15 PM, Dave Sann daves...@gmail.com wrote: There are several projects that provide a bunch of base level/common functions and extensions (similar to those here) beyond core Clojure. And I am sure that many people have their own collection of useful utilities like

Re: Import java classes in clojure

2013-05-07 Thread John D. Hume
Did you try the downloads link here? http://openrules.com/jsr331/ On May 6, 2013 12:10 AM, Caocoa p.de.bois...@gmail.com wrote: Well, so I just tried the following commands: user= (ns mx.clojure.contemporary.pitch-centricity-and-symmetry #_= (:import [jm.music.data #_=

Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread John D. Hume
On May 2, 2013 2:04 AM, David Toomey dbtoo...@gmail.com wrote: Is there anything I could show that could reveal the problem? Yes, you should have shown the stack trace of the exception (or at least the part from the top of the text down to your code). But even without that, you have an error

Re: higher order functions and metadata

2013-05-02 Thread John D. Hume
On Thu, May 2, 2013 at 8:33 AM, Phillip Lord phillip.l...@newcastle.ac.ukwrote: Well, I guess I will code up a simple macro; in my current case, I can infer the arglists anyway. Once you do, be sure to weigh the complexity against: (defn my-partial-function [y] (my-function 10 y)) -- --

Re: Clojure Login form error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom

2013-05-02 Thread John D. Hume
I've never used noir and have barely used 4clojure, but both of them apparently do hidden global things that make it hard to know the context in which your code is running. Your app needs to be wrapped in noir's `wrap-noir-session` middleware in much the same way this blog post shows Ring's

Re: [GSOC 2013] Program analysis suite, based on Rich Hickey's Codeq

2013-05-01 Thread John D. Hume
As a user of Codeq with Navgeet's proposed additions, I would definitely want to see macro usages along with runtime var references. So you're right that you'd want the result of analyzing the subject code with all macros expanded, but it would also be valuable to see the macros that got expanded

Re: testing for nil may not be enough

2013-04-29 Thread John D. Hume
On Apr 29, 2013 1:07 PM, Jonathan Fischer Friberg odysso...@gmail.com wrote: If you don't want to set the initial value to nil, set it to ::unbound or similar. Should be very hard to accidentally bind the same value. Please take Jonathan's advice if nil is a valid value for a user to bind; use

Re: recur doesn't complain when autoboxing fails?

2013-04-28 Thread John D. Hume
On Sun, Apr 28, 2013 at 5:46 AM, AtKaaZ atk...@gmail.com wrote: = (defn abc [] 3) #'ants/abc = (loop [a 1] (when (= 1 a) (recur (abc NO_SOURCE_FILE:2 recur arg for primitive local: a is not matching primitive, had: Object, needed: long Auto-boxing loop arg: a nil The compiler

Re: conform to interface for related multi-methods?

2013-04-28 Thread John D. Hume
On Fri, Apr 26, 2013 at 11:58 AM, Steven Degutis sbdegu...@gmail.comwrote: I found that I want to have multiple multi-methods, but grouped together, much like an interface. There's no syntax for grouping multimethods, but wouldn't it be good enough to put the defmulti forms near one another?

Re: Arrays and indexes

2013-04-19 Thread John D. Hume
Both `for` and `doseq` support the same vector form preceding a body. `for` returns a lazy sequence and is often appropriate for a purely functional body. `doseq` is not lazy and returns nil, so it is only appropriate when you want to run the body for side effects. Take a look at

Re: destructuring vectors with :or

2013-04-12 Thread John D. Hume
You can use a map destructuring form on a vector like so: (let [{x 0 y 1 :or {x 0 y 0}} [7]] [x y]) returns [7 0] On Fri, Apr 12, 2013 at 5:00 PM, henry clifford h.a.cliff...@gmail.com wrote: I'm trying to use the :or destructuring syntax as seen here applied to a map (def point {:y 7})

Re: Some docs on comparators, including mistakes to avoid, Clojure extended doc strings

2013-04-05 Thread John D. Hume
This seems like a good fit for http://clojure-doc.org/ -- -- 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

Re: nested reduce/reduce-kv idiom

2013-04-04 Thread John D. Hume
On Apr 4, 2013 6:54 AM, Jim - FooBar(); jimpil1...@gmail.com wrote: Thanks John, I came up with this, which uses destructuring quite heavily and might slow things down... (reduce (fn [s [t1 t2 w3 v]] (assoc-in s [t1 t2 w3] (/ (count v) all))) {} (for [[k1 v1] ems [k2 v2] v1 [k3 v3] v2] [k1

Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread John D. Hume
On Thu, Apr 4, 2013 at 8:06 AM, David Powell djpow...@djpowell.net wrote: You could use the long-form of map destructuring: (let [{odd true even false} (group-by odd? (range 1 10))] (println odd) (println even)) I do this frequently. Do be careful that if your predicate doesn't return

Re: nested reduce/reduce-kv idiom

2013-04-03 Thread John D. Hume
Destructure the map entry. (for [[k vs] some-map, v vs] v) or whatever. On Wed, Apr 3, 2013 at 1:44 PM, Jim - FooBar(); jimpil1...@gmail.com wrote: Hi all, I 've recently come across this idiom (instead of nested reduces - from Christophe's blog post of course!) (reduce f init (for [x xs, y

Re: Problem with map (only when running on browser)

2013-03-30 Thread John D. Hume
When you want a side effect and don't care about return values, it's idiomatic to use doseq. (doseq [c calls-log] (log-call c)) On Mar 30, 2013 4:23 AM, Neale Swinnerton ne...@isismanor.com wrote: ;(.log js/console (pr-str calls-log (map log-call calls-log))) map is lazily

Re: Seeking advice on a safe way to mock/stub fns

2013-03-27 Thread John D. Hume
On Mar 27, 2013 1:56 AM, Shantanu Kumar kumar.shant...@gmail.com wrote: Sorry, in the last illustration, the (binding [*deps* deps] ...) cannot be useful for Compojure route handlers because dynamic vars are bound at a thread-local level; you will probably have to `alter-var-root` it to some var

Re: Best way of doing clojure / clojurescript development

2013-03-27 Thread John D. Hume
https://github.com/emezeske/lein-cljsbuild/blob/0.3.0/doc/CROSSOVERS.md On Mar 27, 2013 6:40 AM, Steven Obua ste...@obua.de wrote: Hi, I have thought long which language to use for my current project. My main choices were Scala and Clojure, and I decided on Clojure mainly because I need to

Re: Accessing a resource inside a jar

2013-03-25 Thread John D. Hume
It looks like MimetypesFileTypeMap wants a path to a plain file. I can't try this right now, but I think you want the constructor that takes an InputStream. Something like (MimetypesFileTypeMap. (io/input-stream (io/resource thefile))) though if you just passed /thefile to io/input-stream, that

Re: Macro for bailout-style programming

2013-03-23 Thread John D. Hume
Your maybe- does almost the same thing as Clojure 1.5's some- but without support for naked fns (like `(some- 1 inc)`). It also evaluates each step but the last twice (once for the `if`, once when inserted after `op`). If you don't want to switch to some-, I'd recommend you use when-let to avoid

Re: nested map destructuring

2013-03-20 Thread John D. Hume
On Tue, Mar 19, 2013 at 2:58 PM, Jim - FooBar(); jimpil1...@gmail.com wrote: awsome!...the full thing actually is {{:keys [w1 w2 w3]} :weights u :uni-probs b :bi-probs t :tri-probs} You might also consider {:keys [uni-probs bi-probs tri-probs]} {:keys [w1 w2 w3]} :weights} -- -- You received

Re: Beginners question - emacs compiling tests

2013-03-19 Thread John D. Hume
It looks like you're missing (ns ...) forms at the top of each file. That tutorial doesn't show them, but lein would have generated them for you when it generated the project. The key element is that your test file should have a (:use clojure.test) in the (ns) form, which is what allows you to use

Re: Exception propagation design in Clojure web APIs.

2013-03-19 Thread John D. Hume
One argument against using exceptions for commonplace occurrences (like invalid user input) is that the structure of the code may make it difficult to see where those things can pop up, which can lead to misunderstanding and introduction of bugs. Even with Java's checked exceptions, where a

Re: Clj-record

2009-09-01 Thread John D. Hume
On Tue, Sep 1, 2009 at 4:43 PM, Luc Prefontainelprefonta...@softaddicts.ca wrote: Hi John, Clj-record will make its way into production in a couple of weeks. It's been working flawlessly in high volume tests here. Hi Luc, That's great to hear. I recently set up a Google Group for

Re: ANN: libraries promoted from contrib to clojure

2009-06-29 Thread John D. Hume
There may already have been a discussion about this in IRC, but I would have loved to see the 'are' macro continue to support the old syntax (maybe with deprecation warnings) as well as the new until after 1.1 is released. This change makes it relatively expensive for any library with a

Re: Interest in creating a NYC Clojure user group?

2009-06-06 Thread John D. Hume
On Thu, Jun 4, 2009 at 12:09 PM, Eric Thorsenethor...@enclojure.org wrote: what kind of interest there might be in creating a Clojure user group in the NY metro area to meet up in Manhattan once a month to discuss all things Clojure. I'd make an effort to attend monthly Clojure meetings in

Re: Google App Engine - best workflow

2009-05-15 Thread John D. Hume
On Fri, May 15, 2009 at 6:02 AM, Kees-Jochem Wehrmeijer henc...@gmail.com wrote: beyond my skill level. At first I tried to start a swank server from my servlet, but that failed because GAE doesn't allow you to open sockets. By decompiling and disabling that, I could probably work This still

Re: clojure.main always exits with code 0

2009-04-12 Thread John D. Hume
Submitted as http://code.google.com/p/clojure/issues/detail?id=106 --~--~-~--~~~---~--~~ 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

Re: [ANN] Compiling Clojure applications using Ant

2009-04-11 Thread John D. Hume
On Sat, Apr 11, 2009 at 3:49 PM, Richard Lyman richard.ly...@gmail.com wrote: http://www.lithinos.com/Compiling-Clojure-applications-using-Ant.html What do you guys think? -Rich It's a bit simpler to use clojure.lang.Compile as a main class. Here's the relevant bit from one of my

Re: clojure.main always exits with code 0

2009-04-11 Thread John D. Hume
Rich, Can I submit an issue and patch for this? I have a CA on file. Thanks. -hume. On Sun, Apr 5, 2009 at 8:15 PM, John D. Hume duelin.mark...@gmail.com wrote: Currently it does this:  (try   the good stuff ...   (catch Exception e     (.printStackTrace e *err*)))  (flush

Re: Is there a simple Clojure data schema/validation library?

2009-04-09 Thread John D. Hume
On Thu, Apr 9, 2009 at 11:58 AM, samppi rbysam...@gmail.com wrote: I've been whipping up a simple schema library for validating Clojure data based on their tags, but I'm worried that what I'm doing might be redundant with an already existing library. Is there something, such as in

Clojure on Google AppEngine

2009-04-07 Thread John D. Hume
As predicted, Google has now released Java support for AppEngine. I was lucky enough to get an early look, which I dedicated entirely to Clojure. Here's a writeup: http://elhumidor.blogspot.com/2009/04/clojure-on-google-appengine.html Have fun! -hume. -- http://elhumidor.blogspot.com/

clojure.main always exits with code 0

2009-04-05 Thread John D. Hume
Earlier today I was surprised to notice that some test-is unit tests I was running from Ant failed, but it still reported BUILD SUCCESSFUL. I figured I'd forgotten to include failonerror=true in the java task, but it was there. So I played around and found that $ java -cp clojure.jar

  1   2   >