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 bei

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 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 showing the surpris

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. [

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 th

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 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) (upda

Re: ISeq documentation and mutual deftypes.

2014-02-11 Thread John D. Hume
On Tue, Feb 11, 2014 at 7:32 AM, Phillip Lord wrote: > "John D. Hume" 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 and co

Re: ISeq documentation and mutual deftypes.

2014-02-11 Thread John D. Hume
On Feb 11, 2014 4:41 AM, "Phillip Lord" 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 classes are considered im

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 ref

Re: map semantics

2014-02-07 Thread John D. Hume
On Fri, Feb 7, 2014 at 9:41 PM, Andy C 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 > semantics point of view

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 s

Re: Lessons Learned from Adopting Clojure

2014-02-05 Thread John D. Hume
On Wed, Feb 5, 2014 at 1:27 PM, Sean Corfield wrote: > On Feb 5, 2014, at 5:39 AM, John D. Hume 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-slurp-sexp

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: Profiling, VisualVM & random-pause

2014-01-22 Thread John D. Hume
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

Re: type hinting overloaded methods

2013-12-10 Thread John D. Hume
On Tue, Dec 10, 2013 at 4:25 AM, Phillip Lord wrote: > (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 ^java.io.File name))) >

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" wrote: > I'm trying to implement an interface that has properties but can't quite > seem to get it to work and I also

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" wrote: > > I know about *warn-on-reflection* but is there anyway that I can get an > error-on-reflection instead? > > I've been type hinting my application

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" wrote: > In your example a full expansion might be : (. clojure.lang.Numbers (add > 10 1)) > > > On Mo

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" 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 declarations)?

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

2013-11-21 Thread John D. Hume
tity, namely deposit! & 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-w

Re: first vals first vals

2013-11-21 Thread John D. Hume
On Nov 21, 2013 3:32 AM, "Zhemin Lin" 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. -- -- You received

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 acco

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 fo

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 :event->[hand

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 wrote: > > https://github.com/niwibe/datasource

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 u

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" wrote: > https://github.com/krisajenkins/yesql > > Yesql is a simple library for blending SQL & Clojure

Re: road map for clojure?

2013-10-30 Thread John D. Hume
Are you looking at the right repo? https://github.com/clojure/clojure/commits/master On Wed, Oct 30, 2013 at 6:02 PM, julius wrote: > Hi, > > Is clojure under dev? there is no much commits in months, any plan or road > map for clojure? > > thanks > > -- > -- > You received this message because

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" 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 probably not practic

Re: uberjar problem with Leiningen 2.3.3 (works with 2.3.2)

2013-10-18 Thread John D. Hume
How does your app serve up the home page? Have you tried extracting the working uberjar and the broken uberjar and comparing the resulting directory trees? On Oct 18, 2013 5:11 PM, "xavi" wrote: > Hello, > > I have a strange problem when running an uberjar produced by Leiningen > 2.3.3, which do

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 c

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 wrote: > How use lein compile a Java project? > > I know the java-source-paths can specify the src path. But I don't kn

Re: boolean java interopt puzzle/bug?!

2013-10-10 Thread John D. Hume
That behavior seems like a bug to me. Do you know whether there's some good (or stated, good or bad) reason for it? http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/sun/reflect/UnsafeBooleanFieldAccessorImpl.java On Oct 9, 2013 4:33 PM, "Pablo Nussembaum" wrote: > T

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 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 Grenchman knows not

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

Re: Teaching Clojure to students (how ?)

2013-10-07 Thread John D. Hume
On Oct 7, 2013 3:29 AM, "Phillip Lord" 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 equivalently simple

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 i

Re: Type of let form

2013-10-04 Thread John D. Hume
e intentionally marked > 'private'. Seems like anything 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 wrote: > >> This seems intentional, not a case of docs lagging be

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: 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 the

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 Jauvi

Re: Type hints for clojure.set functions

2013-09-28 Thread John D. Hume
On Sep 28, 2013 1:47 PM, "splondike" 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 non-reflective

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) (:core.matrix.

Re: Java Metadata Wrapper

2013-08-30 Thread John D. Hume
On Fri, Aug 30, 2013 at 2:16 PM, JvJ 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 interested in :ta

Re: problem with edn

2013-08-22 Thread John D. Hume
On Aug 22, 2013 2:19 PM, "Softaddicts" 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 data > > Metada

Re: problem with edn

2013-08-22 Thread John D. Hume
On Aug 22, 2013 6:25 AM, "Jim" 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 a value, and mayb

Re: tools for minimizing forward declaration

2013-08-19 Thread John D. Hume
On Aug 19, 2013 5:53 AM, "Phillip Lord" 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 "low-level" is going to be.

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 later,

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 wrote: > Hey everyone, > > I just thought I'd give you a heads up of what I'm currently doing with > Clojure and Ov

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

2013-08-05 Thread John D. Hume
On Mon, Aug 5, 2013 at 8:55 PM, John D. Hume wrote: > ICE concerns? > IDE concerns. -- -- 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 membe

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 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, artifact generation

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 t

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 symbol

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" 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 in the lib. > > >

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" wrote: > Is there reset! and merge a possibility for (transient {}) > > sometimes we have a doseq and it might be requirement sometime...

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)" wrote: > Hi, > > since 1.5 there is > as->

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" wrote: > OK, I've found something that shows how these two

Re: representing clojure source code as data?

2013-06-23 Thread John D. Hume
On Jun 23, 2013 1:43 AM, "kovas boguta" 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? Aren't you only worrie

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" wrote: > Only use 'doseq' when you don't care about the reuturn value. In other > words only for side-effect-y code. Use 'for' instead... > > Jim > >

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" 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 from the back

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)" 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 fi

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. htt

Re: Compiler bug?

2013-06-06 Thread John D. Hume
Guessing a bit here. 1. This file https://github.com/Engelberg/instaparse/blob/master/src/instaparse/print.cljdefines fns called parser->str and Parser->str. 2. Windows has a case-insensitive filesystem. 3. [guess] Something about class files getting overwritten? 4. [guess] Instaparse can't work on

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" 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 perfectly good Runnable,

Re: Some feedback on coding style

2013-05-27 Thread John D. Hume
pre related to metadata and dispatch? AFAICT it's 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 wrote: > >> On May 26, 2013 8:53 PM, &qu

Re: Some feedback on coding style

2013-05-27 Thread John D. Hume
On May 26, 2013 8:53 PM, "Mark Engelberg" 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 overloading) to defaul

Re: How to: reduce boolean operations?

2013-05-24 Thread John D. Hume
On Fri, May 24, 2013 at 1:25 PM, atkaaz 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 in a map.

Re: How to: reduce boolean operations?

2013-05-23 Thread John D. Hume
On Thu, May 23, 2013 at 11:30 AM, atkaaz 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 for user

Re: How to: reduce boolean operations?

2013-05-22 Thread John D. Hume
On May 22, 2013 5:35 AM, "atkaaz" 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 with that

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 th

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 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 > this. I know that

Re: Struggling with encapsulation

2013-05-10 Thread John D. Hume
y experience with most of the Java devs I have come 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, Joh

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 new-sched

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" wrote: > Well, so I just tried the following commands: > >> user=> (ns mx.clojure.contemporary.pitch-centricity-and-symmetry >> #_=> (:import [jm.music.data >> #_=> Score >> #_=

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 `wrap-s

Re: higher order functions and metadata

2013-05-02 Thread John D. Hume
On Thu, May 2, 2013 at 8:33 AM, Phillip Lord wrote: > 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)) -- -- You received this message b

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" 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 coming out of no

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 a

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" 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 nil as the ini

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 wrote: > 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? Presumably they'l

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 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 isn't

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 http://clojure.gi

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 wrote: > I'm trying to use the :or destructuring syntax as seen here applied to a map > > (def point {:y 7}) > (let [{:keys [x y] :or

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 firs

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 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 actual booleans,

Re: nested reduce/reduce-kv idiom

2013-04-04 Thread John D. Hume
On Apr 4, 2013 6:54 AM, "Jim - FooBar();" 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 k2 k3 v3]))

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(); 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 x, z y] z)) ;;

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" wrote: > ;(.log js/console (pr-str calls-log >> (map log-call calls-log))) >> >> map is lazily evaluated, so if

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" 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 run subs

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" 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 and have the handler

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 a

Re: nested map destructuring

2013-03-20 Thread John D. Hume
On Tue, Mar 19, 2013 at 2:58 PM, Jim - FooBar(); 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 this message becau

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 certai

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: Clj-record

2009-09-01 Thread John D. Hume
On Tue, Sep 1, 2009 at 4:43 PM, Luc Prefontaine 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 clj-record, so you may want to si

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 significan

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 Thorsen 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 NYC. -- http://elhum

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 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 wouldn't give y

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 th

  1   2   >