Re: Call custom Clojure function with dependencies from Java

2017-12-24 Thread Justin Smith
If you require a namespace that requires another namespace, this will all be resolved and loaded automatically as long as all the namespace files can be found on the classpath. I suspect that what you showed here is not the full error output, it seems to be missing the information we would need

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-26 Thread Justin Smith
a nitpick on point 1 - I would assume you can't expect hotspot to improve anything in the timescale of a program startup am I missing something here? On Fri, Jan 26, 2018 at 10:32 AM Alex Miller wrote: > With a few custom patches (which are pending in jira) + AOT + direct

Re: what does future do after fn finish ?

2018-02-02 Thread Justin Smith
-> is just a list transform performed after reading your code into a list data structure containing symbols, and before compiling to byte code - it doesn't do anything directly. On Fri, Feb 2, 2018 at 3:55 PM Jacek Grzebyta wrote: > OK I found what makes the memory leak.

Re: what does future do after fn finish ?

2018-02-01 Thread Justin Smith
l spawn threads on a bounded thread pool, I >>> believe. >>> >>> On Jan 31, 2018 8:32 PM, "Justin Smith" <noisesm...@gmail.com> wrote: >>> >>>> Doing all the actions via one agent means that the actions are >>>> serialized thou

Re: what does future do after fn finish ?

2018-01-31 Thread Justin Smith
As a shot in the dark, a common problem with memory usage and futures that I have seen is the antipattern of launching a future for each piece of data in a collection. The problem that occurs is that the code works for small input collections and a small load of running tasks / requests, but for a

Re: what does future do after fn finish ?

2018-01-31 Thread Justin Smith
re > call and see if that works (unless you're trying to do something else). > > John > > On Wed, Jan 31, 2018 at 7:31 PM, Jacek Grzebyta <grzebyta@gmail.com> > wrote: > >> Thanks a lot. I will check it tomorrow. >> >> J >> >> On

Re: what does future do after fn finish ?

2018-01-31 Thread Justin Smith
this is exactly the kind of problem code I was describing - there's no backpressure on existing future tasks to hold up the launching of more futures - the work done by the agent calling conj is negligible. You need to control the size of the pool of threads used, and you need to impose

Re: tlc Expect like library?

2018-02-13 Thread Justin Smith
I've long thought implementing something like TCL expect in Clojure would be a fun project, as far as I know it hasn't been tried (though the google results are drowned out by the Expectations testing library so who knows...). If I were doing this from scratch I'd start with the Process and

Re: namespace - multiple people

2018-02-10 Thread Justin Smith
One approach to this sort of parallel development is having each developer code against the interface of other modules, while implementing the interface of their own module, so that their code can use stubs of interfaces before the production versions are available. Perhaps in Clojure this could

Re: namespace - multiple people

2018-02-10 Thread Justin Smith
ata should be structured, then write code that knows how to handle that data. On Sat, Feb 10, 2018 at 10:06 AM Justin Smith <noisesm...@gmail.com> wrote: > One approach to this sort of parallel development is having each developer > code against the interface of other modules, while implem

Re: macroexpand in uberjar

2018-02-15 Thread Justin Smith
To elaborate on Nicola's correct answer, when -main is run from outside its namespace, the binding of mx comes from the current environment (which doesn't see a macro, and likely has no binding for mx). If you use ` in -main, the currently visible binding is properly namespace qualified so that it

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-20 Thread Justin Smith
another false example above fixed: user=> (into '(1) '(2 3)) (3 2 1) On Fri, Jul 20, 2018 at 9:13 AM Christian Seberino wrote: > Wow thanks. That was pretty thorough. > > cs > > > On Friday, July 20, 2018 at 10:51:48 AM UTC-5, Gary Johnson wrote: >> >> Hi Christian, >> >> You are looking for

Re: (type ...) vs (class ...)

2018-10-24 Thread Justin Smith
the type function in clojure.core lets you override the nominal class of an object with the :type metadata user=> (type {}) clojure.lang.PersistentArrayMap user=> (type ^{:type :foo} {}) :foo On Wed, Oct 24, 2018 at 9:41 AM alex wrote: > Looks like pre defrecord stuff used in early days to

Re: Reify (run vs cloverage) (single node vs cluster)

2018-12-31 Thread Justin Smith
Just a hunch, but many cluster / distribution tools expect that a given Class name will refer to the same Class on each peer. You cannot ensure this with reify- the name is auto-generated. The solution might be using deftype or gen-class so that the class name would be deterministic and shared on

Re: How does Executors/newScheduledThreadPool know how or where to parallelize work?

2019-01-02 Thread Justin Smith
A ScheduledThreadPool doesn't parallelize or partition your work, it schedules tasks and keeps a pool of Thread objects it can reuse for that purpose. If you need a job to be broken into smaller pieces, executed on a schedule, you'll need to implement some sort of coordination. There's some prior

Re: error in process filter: Stack overflow in regexp matcher

2018-12-24 Thread Justin Smith
This isn't a clojure issue. A reference to "process filter" indicates this is an emacs problem. Its regex syntax matcher tends to blow up on long lines. On Mon, Dec 24, 2018, 14:57 Andy Fingerhut wrote: > I would recommend trying to temporarily rename ~/.lein/profiles.clj to a > different

Re: Confusing Regex Behavior

2018-12-04 Thread Justin Smith
You don't need to use re-matcher in that example - the output of re-find with the regex and the string is identical. If you are using the matcher to collect a series of matches in one string, you can also uses re-seq which returns a lazy-seq of the matches of your regex in the string. On Tue, Dec

Re: Confused by a bit of syntax-- Clojure(script) or Hiccup?

2018-11-20 Thread Justin Smith
I'll add that I knew this, but it took me longer than I expected to actually find the documentation to point to. I don't know how a new user of the library would be expected to discover what that symbol means. On Tue, Nov 20, 2018 at 12:43 PM Justin Smith wrote: > :> is a valid Clojure k

Re: Confused by a bit of syntax-- Clojure(script) or Hiccup?

2018-11-20 Thread Justin Smith
:> is a valid Clojure keyword, but has no special meaning on its own. In Reagent's version of the Hiccup DSL, :> introduces a Reagent component defined from a React component

Re: Using map to produce side effects, not working

2019-02-07 Thread Justin Smith
also do note that clojure.core/run! is designed for two-arg map when it's only run for side effects, and clojure.core/doseq is designed for nested side-effecting iteration On Thu, Feb 7, 2019 at 3:33 AM Pierpaolo Tofani wrote: > > Thanks ! Your diagnosis is correct. With two dorun works fine. >

Re: Invalid-token when dereferencing namespaced keywords.

2019-01-29 Thread Justin Smith
you are misusing the :: alias resolution operator, user is not an alias Clojure 1.9.0 (ins)user=> (ns foo) nil (ins)foo=> ::user/a RuntimeException Invalid token: ::user/a clojure.lang.Util.runtimeException (Util.java:221) (ins)foo=> :user/a :user/a On Tue, Jan 29, 2019 at 2:52 PM Philip

Re: Blocking behavior of >!! ?

2019-05-20 Thread Justin Smith
I might be missing something here, but when it is mentioned that something blocks, it's implicit in all cases that there's some condition that allows it to proceed (even immediately) if satisfied. If there's no buffer space it blocks, until that value is consumed. Just because we can construct a

Re: results from sort-by are not sorted

2019-05-06 Thread Justin Smith
minor nitpick to the answer Sean provided: #{:age} as a function returns :age for an argument equal to :age and nil for all other inputs, including a hash map containing that key. On Sun, May 5, 2019, 22:22 wrote: > Thanks. What a newbie question. > > 在 2019年5月6日星期一

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-22 Thread Justin Smith
> > Thanks again... > > Kind regards, > Dimitris > > ps: this repo is WIP > > > On 21 Nov 2019, at 23:43, Justin Smith wrote: > > on rereading I've clearly misunderstood you, I think we need to see > actual code reproducing this error in order to know what fa

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
it might be helpful to consider that in the jvm methods are not data, and the proto function makes the method into concrete data belongs to the namespace that owns the protocol On Thu, Nov 21, 2019 at 2:58 PM Justin Smith wrote: > > if you define proto method x, it belongs to the pr

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
if you define proto method x, it belongs to the protocol namespace no matter where it is called, and calling it as if it belonged to the namespace defining the object extending the protocol will and should fail On Thu, Nov 21, 2019 at 1:57 PM Dimitrios Jim Piliouras wrote: > > Hi folks, > > This

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
ottom > out in the ns the protocol was defined in. It's just that the middle step > could come from 3 different namespaces all containing protocol extensions. > > On Thu, 21 Nov 2019, 23:03 Justin Smith, wrote: >> >> it might be helpful to consider that in the jvm me

Re: Bizarre issue when calling protocol-fn wrapper from different namespace

2019-11-21 Thread Justin Smith
on rereading I've clearly misunderstood you, I think we need to see actual code reproducing this error in order to know what failed here On Thu, Nov 21, 2019 at 3:42 PM Justin Smith wrote: > > there is no foo/x unless you defined one - the protocol function is > created by de

Re: Conceptual difference between map and class

2020-03-31 Thread Justin Smith
I think it's also important here that Clojure methods are actual Java methods - Clojure likes to stay close to the host functionality. A map with a function isn't a class with a method because the JVM bytecode doesn't let you invoke it that way directly. A Clojure function is not a method because

Re: clojure.edn/read isn't spec compliant

2020-10-17 Thread Justin Smith
not only does clojure.edn accept invalid input, but the clojure reader also accepts invalid input for the same reason (prioritizing speed of implementation over validation) user=> (name 'a/b/c) "b/c" On Sat, Oct 17, 2020 at 5:14 PM William la Forge wrote: > > My understanding is that run-time

Re: Accessing Record fields with keywords in ClojureScript not working as in Clojure

2020-08-04 Thread Justin Smith
I don't think this is true, or if true is incidental to the real problem % cljs ClojureScript 1.10.758 cljs.user=> (defrecord Attr [has-default default]) cljs.user/Attr cljs.user=> (get (->Attr true 1) :default) 1 cljs.user=> (:default (->Attr true 1)) nil cljs.user=> On Tue, Aug 4, 2020 at

Re: first time without state - and I'm lost

2020-06-15 Thread Justin Smith
The usage of delay here is clever. I suggest as an addition, using `force` instead of `deref` to disambiguate delay vs. atom (of course if you take a few moments to think about it, swap! shouldn't return an atom etc., but I think it becomes clearer with force). On Mon, Jun 15, 2020 at 10:34 AM

Re: Idiomatic program for someone new to Clojure

2020-12-14 Thread Justin Smith
a small suggestion: you don't need to nest let inside let, a clause can use previous clauses: (defn get-latest-build [pipeline] (let [response (fetch-pipeline pipeline) json (parse-string (:body response) true) [pipeline] (:pipelines json)] (:counter pipeline also

Re: How to safely print structures that may contain infinite lazy seqs?

2020-11-02 Thread Justin Smith
> The next step might be to investigate why infinite lazy seqs don't print as > clojure.lang.LazySeq, like the finite ones. that printing of "clojure.lang.LazySeq@c5d38b66" relies on completely realizing the input, as it relies on the hash, which relies on the fully realized value On Mon, Nov

Re: How to safely print structures that may contain infinite lazy seqs?

2020-11-02 Thread Justin Smith
HashEq java.util.Collection clojure.lang.IObj clojure.lang.Sequential clojure.lang.Seqable clojure.lang.IPersistentCollection clojure.lang.ASeq clojure.lang.IReduce java.lang.Object clojure.lang.ISeq clojure.lang.IMeta clojure.lang.IReduceInit} On Mon, Nov 2, 2020 at 12:36 PM Justin Smith wrote: > > > The

Re: Socket servers, threads, and redirecting error output.

2021-01-02 Thread Justin Smith
By the time the exception is caught, you are already outside the context of the Thread which the repl client is interacting with. The default exception handler has no information tying the executing thread to the repl process (not to mention the dynamic variables clojure is using to associate

Re: Socket servers, threads, and redirecting error output.

2021-01-02 Thread Justin Smith
to be clear, in my second example you see the error from the future without using deref good luck finding your solution On Sat, Jan 2, 2021 at 12:50 PM Austin Haas wrote: > Thank you very much for the explanation, Justin. > > I don't see how I can use futures, though, without blocking on the

Re: How to get a value of a var in Java

2021-06-24 Thread Justin Smith
(sorry, hit reply too soon) On Thu, Jun 24, 2021 at 9:42 AM Justin Smith wrote: > > Clojure vars under the IFn interface. In other words, you can only > import Clojure functions, not Clojure values, through that API. > > On Fri, Jun 18, 2021 at 12:29 PM ru wrote: >

Re: How to get a value of a var in Java

2021-06-24 Thread Justin Smith
> Clojure vars under the IFn interface. In other words, you can only import Clojure functions, not Clojure values, through that API. On Fri, Jun 18, 2021 at 12:29 PM ru wrote: > Thank you, Gary, for the comprehensive answer. I have a control over > Clojure side, so I decide to add special

Re: How to get a value of a var in Java

2021-06-24 Thread Justin Smith
) On Thu, Jun 24, 2021 at 9:43 AM Justin Smith wrote: > (sorry, hit reply too soon) > > On Thu, Jun 24, 2021 at 9:42 AM Justin Smith wrote: > >> > Clojure vars under the IFn interface. In other words, you can only >> import Clojure functions, not Clojure values, thr

Re: Library like "infix"...

2021-05-17 Thread Justin Smith
unless this is an exercise in learning clojure, why not use an existing calculator parser? eg. https://inst.eecs.berkeley.edu/~cs164/sp05/ta/calculator/Parser.java for a random example found with a quick google On Sat, May 15, 2021 at 3:23 PM Blake Watson wrote: > Hello, > > I've got a

Re: How get function name in body?

2021-05-03 Thread Justin Smith
there's a handy trick for pulling in the standard repl aliases / refers: (cmd)user=> clojure.main/repl-requires [[clojure.repl :refer (source apropos dir pst doc find-doc)] [clojure.java.javadoc :refer (javadoc)] [clojure.pprint :refer (pp pprint)]] (ins)user=> (ns foo.bar) nil (ins)foo.bar=>

<    1   2