Re: Migrating nREPL out of Clojure Contrib

2017-07-20 Thread Meikel Brandmeyer (kotarak)
Hi Chas, I have no hard feelings about the hosting or organisation of the nrepl project. If you feel that a different organisation would improve things, then go for it. In contrast to your invest, I haven't much contributed besides problems and complexity. ;-P If you need anything regarding my

Re: Private multimethods possible?

2017-01-10 Thread Meikel Brandmeyer (kotarak)
Am Dienstag, 10. Januar 2017 01:19:16 UTC+1 schrieb Didier: > > How would you declare a namespace within a namespace? Or two namespaces in > the same file? > > You can do so quite easily. (ns foo.bar) (defmulti a :dispatch) (defn b [x] (str "Called a. This was the result: " (a x

Re: Strange tooling interaction bug(?)

2016-11-03 Thread Meikel Brandmeyer (kotarak)
I think the problem happens in leiningen's meta-merge . The :init key is defined as a single expression . whidb

Re: Bug in clojure.core/take lazy seq?

2016-10-25 Thread Meikel Brandmeyer (kotarak)
However, the drop+ does not stop in case the input sequence is exhausted. So more waste there... -- 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 moder

Re: Bug in clojure.core/take lazy seq?

2016-10-24 Thread Meikel Brandmeyer (kotarak)
In fact, (doall (take (count t) t)) actually realises t completely. But not because of the doall or take, but because of the count. The problem is not take, it's the take-while of split-with, which is the trouble. You know that the input is 50 items long. take-while does not. It has to check the

Re: Bug in clojure.core/take lazy seq?

2016-10-24 Thread Meikel Brandmeyer (kotarak)
I think this is not a bug in take, but an unfortunate constellation of laziness. The solution you propose is basically making take looking one step ahead, which is not take's business. It could be actually quite dangerous to do so in case take's n was carefully calculated based on some external

Re: semantics of >! on closed channels

2014-01-23 Thread Meikel Brandmeyer (kotarak)
Hi, there is only one reason I can imagine to close a channel: the one in charge determined that there is not more input. And the one in charge is either the producing side, or a kind of supervisor. In the latter case a separate way of communication is needed to inform the sender, that they sh

Re: semantics of >! on closed channels

2014-01-23 Thread Meikel Brandmeyer (kotarak)
Hi, probably the idea is, that the one who's feeding the channel is the one in charge of closing it. After all, they know when there is no more input available. Do you have a use case where this problem manifests? Or is that just a vague fear that it might happen? Kind regards Meikel -- --

Re: How can i typecast a JavaObject?

2014-01-20 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 20. Januar 2014 11:34:29 UTC+1 schrieb Fabian Page: > > > I get a: > java.lang.IllegalArgumentException: Can't call public method of non-public > class: public final void > com.sun.media.sound.AbstractDataLine.open(javax.sound.sampled.AudioFormat,int) > > throws javax.sound.samp

Re: How can i typecast a JavaObject?

2014-01-20 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 20. Januar 2014 09:46:23 UTC+1 schrieb Fabian Page: > > > I want to output some sound with javax.sound.sampled. > > But from AudioSystem.getSourceDataLine i get a "AbstractDataLine" which i > need to typecast to a "SourceDataLine". How can i make this typecast in > clojure? > >

Re: core.async count in a channel

2014-01-17 Thread Meikel Brandmeyer (kotarak)
Hi again, and some more golfing by Christophe: (defn queue-process-uncontrolled [input output stats] (async/go (loop [q clojure.lang.PersistentQueue/EMPTY] (let [[val-to-q ch] (async/alts! (if-let [v (peek q)] [input [output

Re: core.async count in a channel

2014-01-17 Thread Meikel Brandmeyer (kotarak)
Bleh when you see the bug as you hit "Send" (defn queue-process [input output stats] (async/go ; Wait for the first input. (loop [v (async/ Empty queue. (identical? ch input) (recur nil (cons v q)) ; Write happened, and there is more in the queue.

Re: core.async count in a channel

2014-01-17 Thread Meikel Brandmeyer (kotarak)
Hi, the average channel has no queue. Processes freeze until the peer process arrives. So count doesn't make sense for the typical channel. If you want to implement a queue, you could create a process which accepts values on end and distributes to the other. Then you can keep also track of any

Re: how to check if something is a channel ?

2014-01-16 Thread Meikel Brandmeyer (kotarak)
Hi, you could check to see whether a thing implements the interface. (defn channel? [x] (satisfies? clojure.core.async.impl.protocols/Channel x)) Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cl

Re: To refer an auto-gensymed symbol in an internal unquoted expression?

2013-11-27 Thread Meikel Brandmeyer (kotarak)
Hi, you want gensym directly: (fn [d] (let [a gensym("a")] `(fn [~a] ~(if d `(drop ~d ~a) a Kind regards Meikel -- -- 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 fr

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

2013-11-21 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 21. November 2013 11:19:54 UTC+1 schrieb Jim foo.bar: > > On 20/11/13 19:36, juan.facorro wrote: > > The value for all refs whose value you don't actually modify inside a > transaction should be obtained through > ensure

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

2013-11-21 Thread Meikel Brandmeyer (kotarak)
Hi Jim, the main differences are: deref inside transaction: returns the value of bank at the end of this transaction (unless you used commute somewhere). deref outside transaction: returns the value of bank at that time, other transaction may have committed meanwhile. Hope that helps. Meikel

Re: two pass compilation, intern and def

2013-09-23 Thread Meikel Brandmeyer (kotarak)
Hi, you are right. require-owl also works as a function: (defn require-owl [file & {nspace :namespace :or {nspace *ns*}}] (with-open [rdr (io/reader file)] (doseq [entry (owl-seq rdr) :let [entry-name (translate-name (:name entry))]] (intern nspace entry-name (:init entr

Re: two pass compilation, intern and def

2013-09-23 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 23. September 2013 11:37:10 UTC+2 schrieb Phillip Lord: > > So, now I can refer to an OWL file in > exactly the same way as if it were written in Clojure. > Ok. So, it is correct to think of this as a fancy require-owl, isn't it? Then this means you read the OWL files at compilat

Re: two pass compilation, intern and def

2013-09-23 Thread Meikel Brandmeyer (kotarak)
Hi, don't get me wrong: I don't want to discuss away your use case! But I don't understand it, yet. After your calling intern, do you compile other code referencing the created Vars? If no: why do you need Vars? If yes: why don't you just generate code with a def and compile it? Meikel -- --

Re: Safely flush old value out of an atom

2013-09-20 Thread Meikel Brandmeyer (kotarak)
Hi, don't bother. That's perfectly ok, and no, there is no library function for that. I know quite a number of developers having implemented exactly this function (myself included). Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: two pass compilation, intern and def

2013-09-20 Thread Meikel Brandmeyer
Hi, 2013/9/20 Phillip Lord > > (def bob3 3) > > introduces a new symbol, I am struggling to see why > > (intern 'user 'bob3 3) > > cannot be recognised similarly. > Because intern happens at runtime. It's a normal function. The above intern call is easily translated to the def. intern is only i

Re: two pass compilation, intern and def

2013-09-20 Thread Meikel Brandmeyer
works is that it is treated the same as >> (intern 'user 'bob3 3) >> bob3 >> >> This special handling only occurs when do appears as a top-level form, >> which is the reason why your other examples fail. >> >> On Thursday, 19 September 2013,

Re: possible bug in 1.51?

2013-09-19 Thread Meikel Brandmeyer (kotarak)
Hi, the difference between type and class is, that type inspects the metadata first for a :type keyword. This let's you bless data structures with a type tag eg. for printing or multimethod dispatching. This predates records and protocols. It is used in pr, which triggers the exception while pr

Re: two pass compilation, intern and def

2013-09-19 Thread Meikel Brandmeyer (kotarak)
Hi, Clojure's compile unit is one toplevel form. Therefore (intern 'user 'bob3 3) bob3 works, while (is (do (intern 'user 'bob2 2) bob2)) does not, because the former are two compilation units while the latter is only one. (Note: (do ...) is a special case. (do (intern 'user 'bob3 3) bob3)

Re: macro woes (deftype generator)

2013-09-12 Thread Meikel Brandmeyer (kotarak)
Hi, maybe this gives you a hint, one why it happens: user=> (let [k :xyz] (macroexpand-1 '(swizzle* Vec3 v k {}))) (new Vec3 (. v k) {}) The problem is that swizzle* is a macro. It has no access to runtime information! It sees only the symbol not its value. Calling it with a literal keyword wo

Re: Possible bug in LockingTransaction

2013-09-12 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 12. September 2013 11:11:36 UTC+2 schrieb Brandon Ibach: > > Aaron, as shown in the test case attached to the ticket, I'm calling the > Clojure library from Java code, so I use the Agent.dispatch() method. The > project where this issue was found is attempting to use Clojure'

Re: Possible bug in LockingTransaction

2013-09-11 Thread Meikel Brandmeyer (kotarak)
Hi, without having a clear solution and without pinpointing to the exact issue, I remember seeing this before. Also in unit tests from Java. The person back then came up with the following solution. He created a class from Clojure. (ns your.app.CljApi (:gen-class)) (defn -init []) And then

Re: How to pass clojure.core/read-str reader-forms to clojure.tools.reader.edn/read-str?

2013-09-09 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 9. September 2013 14:21:12 UTC+2 schrieb Joachim De Beule: > > So my questions are: > > 1) Is it really required that any non-standard reader-forms are passed to > clojure.tools.reader.edn/read-str > (via the :readers option)? and > > 2) If so, how do I get to the reader-forms of

Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 9. September 2013 12:31:30 UTC+2 schrieb Alex Fowler: > > I would also add that in case, if you *need* to destructure the `options` > map for some reason, like: > > `(defn search > "Docstring" > [mapping-type & {:keys [option-1 option-2] :as options}] > (do-smth-with-option-1

Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 9. September 2013 10:42:57 UTC+2 schrieb Mark Mandel: > > > (search index mapping-type & {:as options}) > > > You don't have to use a map in the destructuring. (defn search "Docstring" [mapping-type & options] (apply esd/search es-index mapping-type options)) Kind regards Me

Re: binding and core.async? (trying to use shoreleave-remote in go block)

2013-09-05 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 5. September 2013 16:36:37 UTC+2 schrieb Mathias Picker: > > I just tried this test case (from Anderkent on IRC): > > (def pingc (chan)) > > (def ^:dynamic *text* "OUPS BAD ASYNC") > > (binding [*text* "good boy"] > (go (while true > ( (js/alert *text* > >

Re: problem with edn

2013-08-23 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 22. August 2013 17:46:42 UTC+2 schrieb kawas: > > This is indeed a hack and not a best practice > > I disagree. As long as you own the type (or write an application which is self-contained) you are free to define how it is printed. user=> (java.util.Date.) #inst "2013-08-23T07

Re: problem with edn

2013-08-22 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 22. August 2013 11:32:37 UTC+2 schrieb Jim foo.bar: > > Oh wow! I shouldn't have turned my computer off yesterday evening!!! > there were many suggestions to try out... :) > > Ok let's see...I've got a record with meta-data let's call it FOO and its > instance MFOO: > > user=

Re: IDE feature

2013-08-08 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 8. August 2013 10:45:34 UTC+2 schrieb Tassilo Horn: > > > I've never called anybody insane. I just wanted to transport that > paredit and other tools need some time to get used to, but then the > investment might be worth it. > > I meant the overall discussion. Not you in pe

Re: IDE feature

2013-08-08 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 8. August 2013 10:05:28 UTC+2 schrieb Tassilo Horn: > > now I don't know how people can edit Lisp without it. > > Quite simple: You type an (, you type some more code, you type ). Easy as that. Can we stop this arrogant "smug paredit weenie" discussion now? Writing great cod

Re: core.async: macro and visibilities of async operations

2013-08-05 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 5. August 2013 12:17:53 UTC+2 schrieb Alice: > > (defmacro foo > [c] > `( > (let [c (chan)] > (go (prn (foo c))) > (>!! c :hi)) > > I thought this would not work because foo is expanded after go is > expanded, so What am I missing? > > I'm not sure what your expectations a

Re: extend-type on

2013-08-02 Thread Meikel Brandmeyer
mber {:hello number-hello}) Meikel 2013/8/2 Phillip Lord > "Meikel Brandmeyer (kotarak)" writes: > >> Sure, I understand why it's not working! I just don't know how to fix > it. > >> > >> > > Plain old functions: >

Re: extend-type on

2013-08-02 Thread Meikel Brandmeyer (kotarak)
Hi, Am Freitag, 2. August 2013 13:24:07 UTC+2 schrieb Phillip Lord: > > "Jim - FooBar();" > writes: > > your extension point on Number is never fired because 10 is a Long. > > Sure, I understand why it's not working! I just don't know how to fix it. > > Plain old functions: (defn number-he

Re: sorted-set-by with custom comparator frauds equality

2013-07-25 Thread Meikel Brandmeyer (kotarak)
Hi, you are using comparator incorrectly. The function you pass there should return true, when x is to the left of y when called as (f x y). See the following example. user=> (defrecord Foo [a b]) user.Foo ; Wrong usage: your example (The new element is always smaller!) user=> (-> (sorted-set-b

Re: Evaluation of metadata by reader

2013-07-25 Thread Meikel Brandmeyer (kotarak)
Hi, my understanding is, that the metadata is evaluated when the literal is evaluated. In the first case this means to just strip the surrounding quote. So nothing happens to the metadata. In the second case upon evaluation the literal vector is traversed and its elements are evaluated. During

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

2013-07-24 Thread Meikel Brandmeyer (kotarak)
Am Mittwoch, 24. Juli 2013 08:14:15 UTC+2 schrieb Steven Degutis: > > It's been brought to my attention that this project is an utter waste of > time, brings no real improvement over the existing solutions, and was > wrought in complete arrogance. So I've deleted the project. Sorry for > wastin

Re: Stack overflow deep in repl printer

2013-07-11 Thread Meikel Brandmeyer (kotarak)
David, I wouldn't automatically set any values around the printing. The user should be free to do what he likes. But the repl could start out with some sane defaults, which are not limiting in the usual case, but safe in general. Like 50 for the level and 1000 for the length. Then you are not

Re: Clojure: Elegance vs. Performance?

2013-07-10 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 10. Juli 2013 11:49:35 UTC+2 schrieb MikeM: > > > Are clojure designers just lazy or is >> there a good reason for this .. lie? >> >> > SISC has its own stack, so it doesn't do TCO within the jvm. There's a > significant performance impact from this choice. > Having it's own s

Re: -> macro and accessing context

2013-07-01 Thread Meikel Brandmeyer (kotarak)
Hi, since 1.5 there is as->> : (as-> {} ctx (assoc ctx :a "a") (assoc ctx :b (some-fn ctx))) Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To po

Re: Clojure 1.5.1 head holding

2013-07-01 Thread Meikel Brandmeyer (kotarak)
Hi, I did a slight variation which does not close over the head and it seems to work fine. (defn log [f & args] (println "start") (apply f args) (println "stop")) ((fn [xs] (log take-last 3 xs)) (range 2)) Kind regards Meikel -- -- You received this message because you are s

Re: Interleaving

2013-06-27 Thread Meikel Brandmeyer (kotarak)
How about this? (interleave (take-nth 2 xys) (take-nth 2 (rest xys)) zs) Kind regards Meikel -- -- 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 moder

Re: Project Euler problem in clojure

2013-06-20 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 20. Juni 2013 15:19:40 UTC+2 schrieb John Holland: > > (defn triangle [n] (reduce + (range n))) > (def lazytri (lazy-seq (map triangle (range > > Some quick idea: here is a major difference in your clojure and your java implementation. You always recompute the whole sum f

Re: try* macro to catch multiple exception classes with one body. feedback is needed.

2013-06-19 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 19. Juni 2013 17:00:17 UTC+2 schrieb Max Gonzih: > > Hi, I implemented small macro to catch multiple exception classes with one > body. > > https://gist.github.com/Gonzih/5814945 > > What do you think? Are there better ways to achieve similar results? > > I would just extend try

Re: while loop

2013-06-13 Thread Meikel Brandmeyer (kotarak)
Am Freitag, 14. Juni 2013 08:40:51 UTC+2 schrieb Josh Kamau: > Thanks Meikel. That works exactly as i wanted. Now, how can i put all the > "names" in a vector ? > By switching from doseq to for: (vec (for [entry repeatedly #(.getNextEntry stream) :while entry] (.getName entry))) or (->> (rep

Re: while loop

2013-06-13 Thread Meikel Brandmeyer (kotarak)
Hi, another way if it's not an enumeration or the like: (doseq [entry (repeatedly #(.getNextEntry stream)) :while entry] (println (.getName entry))) Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, se

Re: problem using gen-class and using the class name in the same file

2013-06-12 Thread Meikel Brandmeyer
nstructor with an instance of > the same class as parameter. > > Le mercredi 12 juin 2013 11:14:56 UTC+2, Meikel Brandmeyer (kotarak) a > écrit : > >> Hi, >> >> test-gen.Tata should probably be test_gen.Tata everywhere. The reference >> in the pre-init function sh

Re: problem using gen-class and using the class name in the same file

2013-06-12 Thread Meikel Brandmeyer (kotarak)
Hi, test-gen.Tata should probably be test_gen.Tata everywhere. The reference in the pre-init function should be fine, because the defn is compiled after the generated class is in place. Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: alter a map in a vector (reference)

2013-06-11 Thread Meikel Brandmeyer (kotarak)
Hi, Am Mittwoch, 12. Juni 2013 06:39:59 UTC+2 schrieb Kelker Ryan: > > user> (defn update-counter [id xs] > > (let [at-after (drop-while #(not= id (:id %)) @xs) > to-modify (-> at-after first :email) > mod-key (-> to-modify keys first) > location (

Re: with-open and for

2013-06-11 Thread Meikel Brandmeyer (kotarak)
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 filename)] (filter-lines rdr))) Meikel Am Dienstag, 11. Juni 2013 11:04:14 UTC+2

Re: [pre-ANN] test2, the last Clojure testing framework

2013-06-09 Thread Meikel Brandmeyer (kotarak)
I sense a misunderstanding of transients in this message. Am Sonntag, 9. Juni 2013 18:51:00 UTC+2 schrieb Steven Degutis: > > Thanks for the feedback. I'l look into #1. Regarding #2, we just wanted a > side-effecty (mutable) way of adding assertion-results within a test. I > suppose I could use

Re: alter a map in a vector (reference)

2013-06-03 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 3. Juni 2013 22:16:54 UTC+2 schrieb Yinka Erinle: > > Given I have the following > (def result (ref [ { :id 1 :emails { "yi...@mail.com " 1}} ] > ) ) > > I like to alter the result in a transaction to become > [{:id 1 :emails { "yi...@mail.com " 2}}]; increment the > counter

Re: optional first map argument

2013-06-03 Thread Meikel Brandmeyer (kotarak)
Hi, there is always the possibility of a macro. (defmacro defwidget [name & body] (let [[docstring [attrs _ contents] body] (if (string? (first body)) [(first body) (second body) (nthnext body 2)] [nil (first body) (next body)])] `(d

Re: gen-class - ClassNotFoundException

2013-06-01 Thread Meikel Brandmeyer (kotarak)
You have to compile your namespace. gen-class only works with AOT compilation. see: http://clojure.org/compilation Kind regards Meikel -- -- 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

Re: Why the need for an explicit new operator in Clojure?

2013-05-16 Thread Meikel Brandmeyer (kotarak)
stinguish between accessing the class itself and creating a > new >>instance of it? > > (Foo. 42) > > vs > > (instance? Foo 42) > > Is that what you mean? > > Timothy > > On Thu, May 16, 2013 at 11:43 PM, Meikel Brandmeyer (kotarak) < > m...@kotka

Re: Why the need for an explicit new operator in Clojure?

2013-05-16 Thread Meikel Brandmeyer (kotarak)
Hi, how do you distinguish between accessing the class itself and creating a new instance of it? Meikel -- -- 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: who's not using leiningen?

2013-05-16 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 16. Mai 2013 02:05:31 UTC+2 schrieb Dave Sann: > > If you are not using Leiningen, what do you use? > > why do you prefer it? > > I use gradle. Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, se

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-13 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 13. Mai 2013 16:56:11 UTC+2 schrieb tbc++: > > Let's not forget that allocations on the JVM are super, super cheap. In > the order of something like 10 cycles. So don't worry so much about > throw-away objects. > > seq involves realization of the first step of the sequence which

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-13 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 13. Mai 2013 16:48:13 UTC+2 schrieb Jim foo.bar: > > So the following is not encouraged because we disregard the result of > calling seq? > I would prefer (not-any? empty? ...) with empty? being #(zero? (count %)) if all the values are data structures. If there might be sequence

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-13 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 13. Mai 2013 16:16:57 UTC+2 schrieb Sean Corfield: > > > So you think (count (map inc [1 2 3])) should be illegal? > > (I'm just trying to understand your logic here) > > In the hardcore version, yes. In the practical version, probably not. I never had to call count on a seq. (Va

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-13 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 13. Mai 2013 16:16:36 UTC+2 schrieb Mark: > > That's a fair point, but do you always know that what you've gotten back > is a sequence or a data structure, if you aren't looking directly at the > code that you're calling? > Most of my code are either sequence-y things (mostly tra

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-13 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 13. Mai 2013 13:57:57 UTC+2 schrieb Herwig Hochleitner: > > 2013/5/13 Meikel Brandmeyer (kotarak) > > >> seq belongs to seq-land. empty? belongs to data structure land. It should >> actually be implemented as #(zero? (count %)). But unfortunately it is n

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-13 Thread Meikel Brandmeyer
2013/5/13 Mike Thvedt > A good implementation of ISeq won't return a new object, and new > short-lived objects are cheap on the JVM anyway. OTOH count can be slow for > some data structures. if you don't like instantiating lots of new objects > only to throw them away, you're missing out on one o

Re: Utility libraries and dependency hygiene

2013-05-13 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 13. Mai 2013 10:35:14 UTC+2 schrieb Stuart Sierra: > > > > I believe "lightweight dependency loading system" is an oxymoron. Either > you A) design a new module format and try to get everyone to follow it > (OSGI) or B) build an ad-hoc solution that tries to guess at the right >

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-12 Thread Meikel Brandmeyer (kotarak)
Hi, Am Samstag, 11. Mai 2013 21:25:11 UTC+2 schrieb Alex Baranosky: > > Most of the code I see and write at work at Runa uses (not (empty? foo)). > I'll continue to defend the position that it is more obvious code, and > therefore better (imo :) ) > > seq belongs to seq-land. empty? belongs to

Re: Calling a java function with multiple implementations based on type

2013-05-12 Thread Meikel Brandmeyer (kotarak)
For reference: https://github.com/hugoduncan/clj-ssh/blob/develop/src/clj_ssh/ssh.clj#L145 -- -- 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 moderate

Re: Calling a java function with multiple implementations based on type

2013-05-12 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 13. Mai 2013 02:25:03 UTC+2 schrieb Korny: > > If I call (add-identity agent {:private-key-path "foo" :passphrase "bar"}) > the clj-ssh library (eventually) calls a java method: > > (.addIdentity agent "foo" "bar") > > This method has several implementations, including: > public

Re: Iota, reducers, word counting

2013-04-30 Thread Meikel Brandmeyer (kotarak)
Hello, your function does not follow the contract of fold. What you provided is basically the reduce function, but it doesn't work together with fold. For fold you need to merge the different maps you created in the subtasks. So the combine function must look different. (defn my-frequencies

Re: Failed to import java.text.Normalizer.Form

2013-04-29 Thread Meikel Brandmeyer (kotarak)
Subclasses are accessed with $. java.text.Normalizer$Form/NFD Should do the trick. Or (import 'java.text.Normalizer$Form) and Normalizer$Form/NFD. Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send em

Re: Namespace loading with defrecord and attempting to call unbound fn

2013-04-16 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 16. April 2013 11:32:38 UTC+2 schrieb Pierre Allix: > > Thank you the patch works. > > I though it would have made sense to just create a record directly from > Java since they can implement Java interfaces. > > As a rule of thumb, I go with the non-AOT behaviour of Clojure. In t

Re: proxy doesn't care about type hints?

2013-04-15 Thread Meikel Brandmeyer (kotarak)
Am Montag, 15. April 2013 23:03:56 UTC+2 schrieb Jim foo.bar: > > On 15/04/13 21:37, Meikel Brandmeyer (kotarak) wrote: > > > > (proxy [YourClass BarInterface] [] > > (bar [x-or-y] > > (if (instance? InterfaceY x-or-y) > > (override x-

Re: proxy doesn't care about type hints?

2013-04-15 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 15. April 2013 20:57:30 UTC+2 schrieb Jim foo.bar: > > Hi everyone, > > I was very surprised to find out that it is practically impossible to > subclass some Class Foo and override only 1 overload of some method bar() > via proxy...especially, if there are more than 1 methods 'ba

Re: Namespace loading with defrecord and attempting to call unbound fn

2013-04-15 Thread Meikel Brandmeyer (kotarak)
Hi Pierre, does this patch work? 8<--8<--8< diff --git a/test/eu/markosproject/test/LicenseCheckerTest.java b/test/eu/markosproject/test/LicenseCheckerTest.java index 2e017cc..1a1cc82 100644 --- a/test/eu/markosproject/test/LicenseCheckerTest.java +++ b/test/eu/markosproject/test/License

Re: Namespace loading with defrecord and attempting to call unbound fn

2013-04-15 Thread Meikel Brandmeyer (kotarak)
Hi, reading the resources you linked, I got the impression that just the initial require is missing. Instead of adding the require to the method, it should be added to the application init (or some appropriate static initializer? The class giving out instances of the record might be a candidat

Re: What guarantees (if any) does Clojure make about laziness?

2013-03-15 Thread Meikel Brandmeyer (kotarak)
The fact that lazy-seq actually was introduced to increase laziness pretty much shows the path. There is no official specification of Clojure you could rely on bureaucratically. Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group

Re: What guarantees (if any) does Clojure make about laziness?

2013-03-15 Thread Meikel Brandmeyer (kotarak)
Hi, this highly depends on the sequence function at hand. Usually they are guaranteed to be as lazy as possible. But the are two aspects: a) sometimes you need to look ahead to actually perform the action (eg. take-while or drop-while) and b) sometimes there might be a bug in the implementation

Re: Using transients within fold

2013-03-14 Thread Meikel Brandmeyer (kotarak)
You could use the proposed change (second link) and use a patched clojure in your application. Meikel -- -- 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

Re: Using transients within fold

2013-03-14 Thread Meikel Brandmeyer (kotarak)
Hi, that's not really possible at the moment. cf. https://groups.google.com/d/topic/clojure-dev/UbJlMO9XYjo/discussion and https://github.com/cgrand/clojure/commit/65e1acef03362a76f7043ebf3fe2fa277c581912 Kind regards Meikel -- -- You received this message because you are subscribed to the

Re: What's the point of -> ?

2013-03-13 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 12. März 2013 18:21:22 UTC+1 schrieb sw1nn: > > I find the need to switch between -> and ->> in a pipeline disturbs the > clarity of my code. > In my experience having problems with switching between -> and ->> is closely related to unknowingly cross borders between collection

Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread Meikel Brandmeyer (kotarak)
Hi, silly question are you using the call in a sequence pipeline with pmap or mapcat or the like? Or does clj-http that under the covers? Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to c

Re: Custom repositories

2013-03-05 Thread Meikel Brandmeyer (kotarak)
Hi, Am Dienstag, 5. März 2013 13:19:53 UTC+1 schrieb BJG145: > > [com.badlogic.gdx/gdx "0.9.9"] > > there is no "0.9.9" in the repository. Try "0.9.9-SNAPSHOT". Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Custom repositories

2013-03-05 Thread Meikel Brandmeyer (kotarak)
Hi, Adding something like this to your defproject should probably do the trick to get the repository known in leiningen. You should check the available versions there. :repositories [["libgdx" "http://libgdx.badlogicgames.com/nightlies/maven/"; ]] Kind regards Meikel -- -- You received this

Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Meikel Brandmeyer (kotarak)
Hi Chas, Am Montag, 4. März 2013 14:33:29 UTC+1 schrieb Chas Emerick: > > There are a lot of reasons for this, but #1 for me is that few people > understand the implications of version ranges, either downstream of their > published libraries or when they are consuming a library and place a range

Re: Wrong clojure version depending on lein dependencies (was: ANN: Clojure 1.5)

2013-03-04 Thread Meikel Brandmeyer (kotarak)
Hi, Am Montag, 4. März 2013 13:00:31 UTC+1 schrieb Wolodja Wentland: > > > It is up to a community to fix things that are broken in their toolset and > "Do > not use version ranges" is IMHO the wrong answer. > > Huge +1. I was about to blog in favour of version ranges. As I'm a toolmaker mysel

Re: fully populated protocols (or not)?

2013-03-01 Thread Meikel Brandmeyer (kotarak)
Hi, I would extend protocols using the normal function approach as with extend. user=> (defprotocol P (foo [this] [this that])) P user=> (extend-type String P (foo ([this] this) ([this that] (str this that nil user=> (foo "foo") "foo" user=> (foo "foo" "bar") "foobar" Howev

Re: defmacro/gen-class/annotation woes

2013-02-27 Thread Meikel Brandmeyer
Hi, if you want to avoid reflection in macro-generated code you have to quote the class because the compiler expects the classname and not the class itself. I figured it could be similar here. Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "

Re: defmacro/gen-class/annotation woes

2013-02-27 Thread Meikel Brandmeyer (kotarak)
Hi, just a wild guess: quote the annotation in the macro. (with-meta name `{Deprecated true}). Note the backtick. Kind regards Meikel -- -- 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

Re: Clojure Performance For Expensive Algorithms

2013-02-27 Thread Meikel Brandmeyer (kotarak)
Hi, the recur is not for optimisation but for short-circuiting so that every? kind of works like and. Stoppable reduce allows now to exploit the internal reduce for strings while still keeping the short-circuiting of every?. Kind regards Meikel -- -- You received this message because you are

Re: was there a time when clojure empty seqs were falsy?

2013-02-25 Thread Meikel Brandmeyer (kotarak)
I talked about the history of lazy-seq and friends at the EuroClojure 2012: http://vimeo.com/channels/357487/45561410 Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups

Re: creating code stubs to use inside an extend-protocol form

2013-02-24 Thread Meikel Brandmeyer (kotarak)
Hi, why don't you just use extend? (defn default-run [this ^String text] (let [ann (edu.stanford.nlp.pipeline.Annotation. text)] (.annotate this ann) ann)) (extend POSTaggerAnnotatorIComponent {:run default-run} PTBTokenizerAnnotator IComponent {:run default-run} ...) You

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Meikel Brandmeyer (kotarak)
Hi, Am Donnerstag, 21. Februar 2013 16:08:36 UTC+1 schrieb Jim foo.bar: > > I apologise...this works almost perfectly: > > (defmacro defcomponent [name co] > `(let [c# ~co] > (assert (component? c#) "Not a valid IComponent") > (def ~name c#))) > > the only slight problem is the error thrown

Re: Creating a hash-map with conditional keys

2013-02-21 Thread Meikel Brandmeyer (kotarak)
Hi, merge works with nil. So (merge (create-map) (create-key-value "some-value")) should work as you intend with the functions as they are defined now. Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Meikel Brandmeyer (kotarak)
Then simply add a (var ~name) as last statement in the do. Kind regards Meikel -- -- 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 b

Re: assertion-forms inside macros without using eval?

2013-02-21 Thread Meikel Brandmeyer (kotarak)
(defmacro defcomponent [name co] `(do (def ~name ~co) (set-validator! (var ~name) component?))) Maybe like this? (Untested) Kind regards Meikel -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cl

Re: How to invoke java method obtained using clojure.reflect

2013-02-12 Thread Meikel Brandmeyer (kotarak)
You can also do away with the argument names. You just need the number of arguments. (defn call-fn [class method n-args] (let [o(gensym) args (repeatedly n-args gensym) [class method] (map symbol [class method])] (eval `(fn [~o ~@args] (. ~(with-meta o {

  1   2   3   4   5   6   7   8   9   10   >