Re: What does the ref *loaded-libs* do?

2018-02-05 Thread Stephen Gilardi
It is there to support the “:reload” and “:reload-all” features of “require” and to help separate the concern of loading libs from the concern of tracking namespaces. --Steve > On Jan 29, 2018, at 6:36 PM, Raymond Huang <12ay.hu...@gmail.com> wrote: > > I was poking around `tools.namespace` an

Re: How to configure a library from a file in the project that has it as a dependency?

2016-04-19 Thread Stephen Gilardi
If you end up using a separate config file rather than project.clj, you might find Carica https://github.com/sonian/carica useful. It allows merging config files on the classpath into one effective config hierarchy with predictable overriding behavior. Sample

Re: Complex swap!

2016-02-01 Thread Stephen Gilardi
Here are a few discussions about this issue: http://dev.clojure.org/jira/browse/CLJ-1454 http://stackoverflow.com/questions/15441638/alternate-version-of-swap-also-returning-swapped-out-value

Re: [ANN] New clojure.org!

2016-01-14 Thread Stephen Gilardi
+1 great fresh look and process! > On Jan 14, 2016, at 11:01 AM, Marc O'Morain wrote: > > Very nice! Good job all. -- 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 ne

Re: ClojureScript compiler says "No such namespace" ?

2015-12-23 Thread Stephen Gilardi
The namespace name is not the same as the dep name. ‘require' clauses use namespace names, for example: [cljs-time.format :as something] You can get the namespace name from the ns form at the top of its file, e.g., https://github.com/andrewmcveigh/cljs-time/blob/master/src/cljs_time/for

Re: difficulties using extend--'elp!

2015-11-24 Thread Stephen Gilardi
There are a several small things here that need fixing: - in the “gran” section of your “extend”, you’re defining “blap” which is not part of the gran protocol - perhaps blip was intended - the first argument in protocol function declarations refers to the object itself, often named “this” - c

Re: safety and reusability of clojure.lang.RT, Compiler and co. in multi-classloader environment

2015-09-28 Thread Stephen Gilardi
I haven’t seen discussion of isolating some of the RT data structures while sharing others and the executable parts. In case you haven’t seen these, here are some references about isolated Clojure runtimes that may be helpful: https://github.com/boot-clj/boot

Re: Anotating functions for pre-processing

2015-08-05 Thread Stephen Gilardi
> I wish I could do that in Clojure: > > (defn ^:transactional someFunction [...] ...) > > and then have somehow means to decorate someFunction (yes, I am aware there > is no container) The code you proposed does have an effect on the someFunction var (but not the function it ends up bound to)

Re: Identifying dependency that's pulling in SLF4J

2015-06-08 Thread Stephen Gilardi
> On Jun 8, 2015, at 1:26 PM, Michael Gardner wrote: > > I've started to see unwanted SLF4J console messages from one of my projects. > I'm not (directly) using SLF4J, and would like to find out which of my > dependencies is. But the dependency tree is a bit large to search by hand. Is > ther

Re: clojure.main on a clj file does not show up any println

2014-12-08 Thread Stephen Gilardi
> On Dec 8, 2014, at 9:02 AM, Ganesh Krishnamoorthy > wrote: > > I have been trying all my bit on to get my hello world working; Any help is > much appreciated... > > am trying to run it by > java -cp clojure-1.6.0.jar clojure.main hey.clj > I just get an empty line. > Below is my file: > >

Re: Retrieving the namespace an expression in compiled in

2014-10-23 Thread Stephen Gilardi
> On Oct 23, 2014, at 5:06 PM, James Reeves wrote: > > Or a macro: > > (defn endpoint [config] > (routes >(GET "/" [] (resource/url (this-ns) "index.html" Perhaps a macro 'ns-path’: (defn endpoint [config] (routes (GET "/" [] (resource/url (ns-path "index.html”) —Steve --

Re: Modelling in Clojure

2014-10-22 Thread Stephen Gilardi
> Clojure's laziness is restricted to seqs > and is guaranteed to always produce the same value for the same field. > > Nope: > > => (def foo (int-array [1 2 2 5 9 3])) > #'user/foo > => (def bar (seq foo)) > #'user/bar > => bar > (1 2 2 5 9 3) > => (aset foo 3 3) > 3 > => bar > (1 2 2 3 9 3) T

Re: Namespace circular dependencies

2014-10-16 Thread Stephen Gilardi
> So, I'm confused. I'm not sure what is allowed and under what circumstances, > and I'm not sure what I should be validating here. Zach very reasonably > argued that Clojure clearly permits this since Manifold works, but I'm not > sure if this is just a happy accident. Looking at the clojure.co

Re: Keyword comparison performance

2014-10-11 Thread Stephen Gilardi
On Oct 11, 2014, at 10:59 AM, Jony Hudson wrote: > But if any of these Keyword objects were garbage-collected, I think it would > break the parity between identical? and =. The Keyword construction and interning mechanism ensures that whenever there exists at least once (strong) reference to

Re: Keyword comparison performance

2014-10-10 Thread Stephen Gilardi
> I've been optimising a piece of code lately, and have come to wonder about > the performance of keyword comparison. Specifically, I'm not sure whether the > performance I'm seeing is what is expected. The data structures page on > clojure.org [1] indicates that keywords "provide very fast eq

Re: Convert clj-time date-time to UTC

2014-06-14 Thread Stephen Gilardi
You're welcome. As another small refinement, I noticed that there's a var for the utc timezone: (t/time-zone-for-offset 0) can be replaced with t/utc --Steve On Jun 14, 2014, at 12:49 PM, gvim wrote: > On 14/06/2014 16:12, Stephen Gilardi wrote: >> This i

Re: Convert clj-time date-time to UTC

2014-06-14 Thread Stephen Gilardi
This is not quite to your exact specification, but should help you to write what you want: user> (defn to-utc [dt] (t/to-time-zone dt (t/time-zone-for-offset 0))) #'user/to-utc user> (to-utc (t/from-time-zone (t/date-time 1967 7 31 6 30) (t/time-zone-for-id "America/Caracas"))) # --Stev

Re: 4Clojure exercise 47 question

2014-06-02 Thread Stephen Gilardi
On Jun 2, 2014, at 4:53 PM, Erlis Vidal wrote: > Hi guys, > > Quick question about exercise 47, http://www.4clojure.com/problem/47 > > Here you could find the following > > (not (contains? '(1 2 4) __) > > If I try to execute it in my REPL it gives the following error: > > contains? not

Re: Confusion about binding *ns* before defining a var

2014-05-30 Thread Stephen Gilardi
On May 30, 2014, at 12:57 AM, ian.tegebo wrote: > I don't see the reason why def should behave as it currently does; it seems > like it should lookup the current thread-binding for *ns*, making the second > case's use of eval unnecessary. Since it doesn't, I'd like to know why it > couldn't

Re: Confusion about binding *ns* before defining a var

2014-05-29 Thread Stephen Gilardi
On May 29, 2014, at 7:11 PM, ian.tegebo wrote: > user> (binding [*ns* (the-ns 'blah)] (defn foo [])) > #'user/foo > user> (binding [*ns* (the-ns 'blah)] (eval '(defn foo []))) > #'blah/foo clojure.core/eval evaluates a form by compiling it and then executing the compiled code. For a def form,

Re: regex strings

2014-05-27 Thread Stephen Gilardi
clojure.string/replace replaces the portion of the string matched by the regex with the replacement. If you add ".*" to the regex, the regex will match the entire input string and the form will evaluate to "First". --Steve On May 27, 2014, at 11:24 AM, Glen Rubin wrote: > I have a string of t

Re: ArithmeticException from unchecked-add

2014-05-19 Thread Stephen Gilardi
On May 19, 2014, at 2:17 PM, Greg D wrote: > user> (unchecked-add ^Long(Long/MAX_VALUE) ^Long(Long/MAX_VALUE) ) > ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow > (Numbers.java:1424) The docs for unchecked-add (http://clojure.github.io/clojure/clojure.core-api.htm

Re: Is there a term for non-map collections?

2014-05-16 Thread Stephen Gilardi
On May 16, 2014, at 1:23 PM, Mars0i wrote: > I think I'd use "kws" or "keywords" in that case. I'd expect a seq of > keywords. > > I don't think keyw-seq is too narrow though. The items in a seq on a map are > "map entries" or more generically "pairs", not "keywords". > > OK, but "seq" impli

Re: Is there a term for non-map collections?

2014-05-16 Thread Stephen Gilardi
On May 16, 2014, at 12:53 PM, Mars0i wrote: > Sometimes I write a function that will work in the intended way only with > collections that are not maps. (For example, suppose I write a function > that's supposed to operate on vectors, lists, sets, or lazy sequences of > keywords, what do I c

Re: Save map contentns to external file?

2014-05-15 Thread Stephen Gilardi
On May 15, 2014, at 3:35 PM, Steven Jones wrote: > Thanks, edn looks like the way to go but your example is not quite > working. The issue appears to be with pr. > > (defn foo [] 'foo) > > (def data {0 foo, >1 '[a b c]}) > > (spit filename (pr data)) Use pr-str instead of pr. It

Re: How to convert this list into map?

2014-05-10 Thread Stephen Gilardi
As a slight simplification you can take advantage of the fact that apply handles in-line arguments as well as a seq of arguments at the end. This also works: user=> (apply hash-map :op '(:= :language "Clojure")) {:op :=, :language "Clojure"} --Steve On May 10, 2014, at 6:37 PM, Hussein B. wro

Re: What does ^{} actually translate to?

2014-05-08 Thread Stephen Gilardi
On May 8, 2014, at 8:34 AM, Pascal Germroth wrote: > I'm trying to attach metadata to some values (not the vars holding them). > I thought ^{x} y was the same as (with-meta y {x}), There was a recent thread about this here. https://groups.google.com/forum/#!searchin/clojure/metadata$20reader/c

Re: clojure.repl/pst problem

2014-05-07 Thread Stephen Gilardi
On May 7, 2014, at 12:55 PM, Plínio Balduino wrote: > But the documentation also shows that I can set the depth of stacktrace, what > I guess that can be a number of lines: > > (pst 5) > > IllegalArgumentException No matching field found: getStackTrace for class > java.lang.Long clojure.lan

Re: Contagious BigDecimals?

2014-05-07 Thread Stephen Gilardi
On May 7, 2014, at 12:11 PM, Mars0i wrote: > To me, the fact that BigDecimal is contagious sometimes but not always, seems > confusing in a way that could encourage bugs. The fact that BigInts are > contagious would also lead one to assume that BigDecimals are contagious. I don't think it's

Re: ClassCastException: Object arguments

2014-05-04 Thread Stephen Gilardi
> How do you call a method which accepts Object arguments? > > String/format | > http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#format(java.lang.String, > java.lang.Object...) > > user=> (String/format "%s" "foo") > ClassCastException java.lang.String cannot be cast to [Ljav

Re: Basic question: metadata reader

2014-05-03 Thread Stephen Gilardi
> I just read: > > http://clojure.org/reader > > Metadata (^) > Metadata is a map associated with some kinds of objects: Symbols, Lists, > Vector, Sets, Maps, tagged literals returning an IMeta, and record, type, and > constructor calls. The metadata reader macro first reads the metadata and >

Re: Cleaner solution, anyone?

2014-05-01 Thread Stephen Gilardi
> I wrote a blog post discussing Thomson's Paradox, and simulated it in Clojure- > http://pizzaforthought.blogspot.in/2014/05/and-infinity-beyond.html > > The state function defined towards the end is not very functional. > Could someone guide me towards a cleaner approach? Here's an option:

Re: puzzled by RuntimeException

2014-04-23 Thread Stephen Gilardi
> Just FYI, some background on keywords that start with a number... > > The reader docs (http://clojure.org/reader) states that symbols (and keywords > follow symbols in these rules) must "begin with a non-numeric character". Thanks, Alex. The REPL-y and sjacket issues cited the Clojure issues

Re: puzzled by RuntimeException

2014-04-22 Thread Stephen Gilardi
On Apr 22, 2014, at 5:37 PM, Greg D wrote: > I believe this is a problem in REPL-y, which is used when using 'lein repl'. > > I used Cider to start a nREPL server, then used 'leing repl :connect' to get > the REPL-y interface. > > The problem was evident in the latter, but not the former. I

Re: puzzled by RuntimeException

2014-04-21 Thread Stephen Gilardi
> The sequence in the transcript below shows runtime exceptions when a numeric > keyword is followed by a list starting with a symbol or character. > > Would anyone help me with a reason for the failing cases? > > user=> (clojure-version) > "1.6.0" > user=> '(:42 a) > (:42 a) > user=> '(:42 "a"

Re: Data Literals: How to handle read "errors"?

2014-04-13 Thread Stephen Gilardi
On Apr 13, 2014, at 8:31 AM, Thomas Heller wrote: > [...] confusing error messages. > > user=> (pr-str #time/local-datetime [2014 4 1 0 0 2 999]) > > [...] > RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException > (Util.java:221) Using default #inst reader gives

Re: Is it possible to give an atomic message?

2014-04-12 Thread Stephen Gilardi
On Apr 12, 2014, at 7:24 AM, Cecil Westerhof wrote: > 2014-04-12 11:40 GMT+02:00 Max Penet : > Be aware that SimpleDateFormat is not threadsafe though. > > What should I use instead of SimpleDateFormat then? One solution to that facet of the problem is to use a ThreadLocal instance of Simpl

Re: list all functions in namespace?

2014-04-04 Thread Stephen Gilardi
On Apr 4, 2014, at 7:53 PM, Christopher Howard wrote: > Is there some trick Clojure command to list all functions defined in a > namespace? http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/ns-publics is a good start. --Steve -- You received this message because you are su

Re: How to update an atom & return the change?

2014-03-20 Thread Stephen Gilardi
There was a stackoverflow question recently that requested a solution for a similar problem: https://stackoverflow.com/questions/22409638/remove-first-item-from-clojure-vector-atom-and-return-it One solution there is similar to this: (defn swap*! "Like swap! but returns a vector of [old-value

Re: Is it possible to get Clojure files in Spotlight search?

2014-02-19 Thread Stephen Gilardi
I'm aware of one Mac application that declares to OS X that it handles Clojure source files: Light Table . In its info.plist, Light Table declares ".clj" ".cljs" and ".edn" to map to "Document Type Name" "Clojure Source" and marks itself as the default Editor for the

Re: set!

2013-03-13 Thread Stephen Gilardi
The repl's thread binding for those vars is set here: https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L267 using this macro: https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L85 Users of your library would need to do something similar, possibly

Re: Why can't I use/require namespaces not associated with files?

2011-11-18 Thread Stephen Gilardi
why does the existance of a namespace not suffice to use or require it? Currently, with clojure 1.3, it has to be associated with a class or clojure file. The primary purpose of both use and require is to load code from a file in classpath. So while I can't use or require it, I can refer

Re: reader macros

2008-11-15 Thread Stephen Gilardi
Clojure does not currently allow programs to define new reader macros. That is unlikely to change. There are more details here: http://groups.google.com/group/clojure/search?group=clojure&q=reader+macro&qt_g=Search+this+group There is a clever technique described on the wiki that allows Clojur

Re: (. Classname-symbol (method-symbol args*))

2008-11-15 Thread Stephen Gilardi
In my opinion, idiomatic Clojure for this is: (.println System/out "smile") --Steve On Saturday, November 15, 2008, at 09:32PM, ".Bill Smith" <[EMAIL PROTECTED]> wrote: > >Clojure doesn't know what to do with "System.out"; you need to express >that as (. System out). Of course (.. System out