Re: top-level lets or private globals

2015-08-27 Thread pmf
On Thursday, August 27, 2015 at 1:15:14 AM UTC+2, red...@gmail.com wrote: I have found the access control stuff in Java to be an incredible pain. When attempting to compose a larger system from the parts. Generally everything is compulsively private, so if an api doesn't exactly expose

Remember old namespace when using in-ns

2015-02-27 Thread pmf
I have a peculiar problem (due to being used in a scripting context) related to in-ns. I have a file that is executed in a namespace which is provided by the scripting infrastructure (per invocation, i.e. I do not know the namespace statically,it will be something like prefix.unknown-123).

Referencing aliased namespace

2014-11-18 Thread pmf
When I refer to a namespace like this: (require '[clojure.test.check :as tc]) using tc/whatever works as expected, but I have not found a way to use the handle tc to refer to the namespace: user= (the-ns 'tc) Exception No namespace: tc found clojure.core/the-ns (core.clj:3933) Using the

Default implementation for defprotocol

2014-11-17 Thread pmf
Is there a way to provide a default (fallback) implementation for a method defined in a defprotocol directive? I do realize that I could extend the protocol for type java.lang.Object, but this raises the question about how protocol implementations with extend are sorted, i.e. how

Re: Clojure statechart / hierarchical FSM implementation

2014-09-05 Thread pmf
On Friday, September 5, 2014 9:13:43 AM UTC+2, Andre Van Der Merwe wrote: Alternatively are there any papers or examples that you know of that discuss implementing statecharts? Most of the ones I’ve seen are code-gen tools and that does not really what I am after. You should definitely

Re: ANN: [vinyasa 0.1.5] - dynamic reloading of java code without repl restart

2014-01-04 Thread pmf
Very nice; I also found your Clojure workflow article ( http://z.caudate.me/give-your-clojure-workflow-more-flow/) tremendously useful. -- -- 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

core.async JAR

2013-07-04 Thread pmf
Is there a prebuilt binary JAR of core.async available somewhere? I did not find it on Clojars. -- -- 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

- macro and accessing context

2013-07-02 Thread pmf
Hi, I sometimes (in fact quite often) want to use the - macro like this: (- {} (assoc :a a) (assoc :b (some-fn CTX))) where CTX should be the current value of the threaded element. Currently, I'm forced to write a helper function (defn add-some-fn [ctx] (assoc ctx :b (some-fn ctx)))

Re: - macro and accessing context

2013-07-02 Thread pmf
That looks like it can do the job; thanks! On Tuesday, July 2, 2013 8:12:04 AM UTC+2, Meikel Brandmeyer (kotarak) wrote: Hi, since 1.5 there is as-http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/as-%3E : (as- {} ctx (assoc ctx :a a) (assoc ctx :b (some-fn

Re: Domain Modelling

2010-01-25 Thread pmf
On Jan 25, 7:20 pm, Roman Roelofsen roman.roelof...@googlemail.com wrote: After playing around with clojureql I noticed how well the relational data model maps to a functional language. Processing lists (result sets), joining, filter, group by, etc. are ideas I found in both worlds. I am

Re: Case-insensitive map?

2010-01-18 Thread pmf
On Jan 18, 1:59 pm, Laurent PETIT laurent.pe...@gmail.com wrote: There's a library in clojure.contrib which allows to create your own getters / setters for maps : http://richhickey.github.com/clojure-contrib/fnmap-api.html Not wanting to interrupt this thread, but this is amazing! I could

Re: Clojure and c++ and a bit more

2009-12-21 Thread pmf
On Dec 20, 7:22 pm, nathaniel nathan...@photino.org wrote: Does anyone know of Clojure features which rely on Java features that would be prohibitively difficult to implement in C++? You might run into the problem than any C++ garbage collector you find will probably not be quite as efficient

Re: Handling XML

2009-12-02 Thread pmf
On Dec 2, 4:51 pm, Dennis shr3ks...@gmail.com wrote: The XML is of the form: ganglia   multiple clusters     multiple hosts       multiple metrics Use XPath. Seriously, I hate XML and XSLT, but XPath is simply the most concise way to extract things from a nested structure. Most XPath-

Re: Continuation monad tutorial

2009-11-30 Thread pmf
On Nov 30, 11:07 pm, jim jim.d...@gmail.com wrote: Just finished the tutorial explaining the continuation monad in clojure. Haven't even proofed it but I want to head to the gym. :) http://intensivesystems.net/tutorials/cont_m.html This is great stuff; thanks! -- You received this message

Re: Atomic reloads and snapshots of namespaces

2009-11-26 Thread pmf
On Nov 26, 7:39 pm, Richard Newman holyg...@gmail.com wrote: Re consistency: I seem to recall Pascal Costanza working on   activation of layers, so you can swap a whole set of stuff across your   program. He spoke about it at ILC2009, but I'm not sure I've found the   right paper. Common

Re: Using agents and blocking I/O.

2009-11-10 Thread pmf
On Nov 10, 7:07 am, David Brown cloj...@davidb.org wrote: Ok.  So, it's the existence of this future-like entity that blocks upon deref until filled is indeed somewhat missing.  It's not particularly difficult to implement. This thing could easily create a lazy sequence, in fact, the code

Re: Iterative collections.

2009-11-09 Thread pmf
On Nov 9, 5:39 pm, David Brown cloj...@davidb.org wrote:    (let-map [x [31 41 59 26]              y (iterate inc 1)]      (+ x y)) Probably not that interesting in the simple case. How is this different from using for? It's also lazy and supports destructuring. (for [x [31 41 59 26]

Re: Iterative collections.

2009-11-09 Thread pmf
On Nov 9, 6:42 pm, David Brown cloj...@davidb.org wrote: And gives very different results.  'for' iterates over it's sequences in a nested fasion.  For your particular example, it will return the sequence from (+ 31 1) (+ 31 2) and so on, and never get to the second element of the first

Re: Another closure available

2009-11-07 Thread pmf
On Nov 8, 6:08 am, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: Hmm, someone else has made another closure available :). http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html There's also Clozure Common Lisp [1], which is conceptually closer to Clojure. [1]

Re: Creating custom exceptions in clojure gen--class use?

2009-11-01 Thread pmf
On Nov 1, 8:47 pm, Teemu Antti-Poika antti...@gmail.com wrote: I want to use my own exceptions to control program flow. I want to catch my own exceptions and let the surrounding container worry about other exceptions. In order to do this, I must catch my exceptions selectively by type name,

Re: add-watch's functions' first argument

2009-10-26 Thread pmf
On Oct 26, 8:12 pm, samppi rbysam...@gmail.com wrote: According to the docs, the function passed into an add-watch call receives four arguments. Its first argument is a key. This key seems to be the same key as the key passed into the add-watch call, and so would always be the same, for the

Re: Dedicated thread for agent or creating thread pool for agent?

2009-10-18 Thread pmf
On Oct 18, 6:27 am, mbrodersen morten.broder...@gmail.com wrote: I don't know SWT well enough to answer that. I am new to the JVM platform (after 20+ years of writing native C++ code). However, the question is not SWT specific. There will be other cases (for example OpenGL) where something

Multimethods and dispatch function

2009-10-17 Thread pmf
Hi, I've run into the issue that when declaring a multimethod using defmulti, the dispatch-function has to be not only declared, but must actually be defined. I.e. the following does not work: (declare my-dispatch-fn) (defmulti my-multi my-dispatch-fn) ; throws exception due to unbound Var

Re: Multimethods and dispatch function

2009-10-17 Thread pmf
On Oct 18, 12:29 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: I think this is intentional, because the multifn doesn't call the dispatch function by name.  Common usage is to use an anonymous fn for the dispatch. Ok, wrapping it in an anonymous function solves the problem; thanks!

Re: Clojure Applets: Tutorial

2009-10-13 Thread pmf
In your article, you mention the problematic size of 1.4MB of clojure.jar. You might want to try clojure-slim.jar, which gets built alongside clojure.jar, and is about 500KB. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Strange nullpointer when seqing through an xml

2009-10-07 Thread pmf
On Oct 7, 10:50 am, Hans Sjunnesson hans.sjunnes...@gmail.com wrote: The following code works fine: (doseq [x (xml-seq foo)] (println x)) However when I want to do more things in the doseq body, or I simply add an extra set of parentheses around the println statement, I get a nullpointer.

swap! and dosync

2009-10-07 Thread pmf
IIRC, dispatching to agents (via send or send-off) during a dosync only happens if the transaction was successful (this was discussed in several places, though http://clojure.org/refs does not mention this; maybe this should be included there, if this is really something that is guaranteed). I'd

Re: Architecting a large multi-threaded process

2009-09-23 Thread pmf
You might want to look into the stuff from JSR166 (scheduled for Java 7, but already available as a library for Java 6), which has advanced, built-in workload-balancing which is vastly easier than trying to do this with the raw, naive j.u.c.Executors-package (and Clojure's agents, which are

Re: Applying Java methods.

2009-09-21 Thread pmf
On Sep 21, 11:22 pm, sross ros...@gmail.com wrote:  I'm looking for a bit of advice for calling a java method which has a few different signatures (such as Connection.prepareStatement).  Is there a cleaner way of passing a variable number of arguments to the method, such as (apply (memfn

How to define multiple methods at once

2009-09-10 Thread pmf
Hi, I'd like to know whether there is already something in clojure.contrib that installs a method with multiple dispatch-values, i.e. given a multimethod like: (defmulti some-multi identity) instead of installing several methods with different dispatch values that do the same thing:

Re: How to define multiple methods at once

2009-09-10 Thread pmf
The idiomatic Clojure way of doing what you want is to define *one*   method against something higher up in the hierarchy than both :a and :b. For example, if your two values are ::get and ::head, perhaps you   should be defining a handler for ::idempotent-http-method. Thanks; fits

Re: JSR 223

2009-08-01 Thread pmf
On Aug 1, 2:36 am, Niels Mayer nielsma...@gmail.com wrote: PS: I've always seen xwiki as the emacs of webapps (and wikis)... So I'm looking forward to having a real emacsish type language -- clojure -- to extend it via a more appropriate language for scripting. I'm the author of the JSR 223

Re: Approaching Clojure-Hibernate integration using hibernate.default_entity_mode = dynamic-map (Feedback Request)

2009-07-23 Thread pmf
I've also looked into the dynamic-map stuff, but found only rudimentary documentation, which caused me to give up. It's nice to see that you seem to have gotten further. For me personally, well-polished defmodel/hbm-property functionality would be much more important than a query-DSL (since you

Re: Compiling from command line (solved)

2009-06-22 Thread pmf
On Jun 23, 12:30 am, Thibaut Barrère thibaut.barr...@gmail.com wrote: btw - if there is a better way to achieve this, I'm ready to learn :) There's the main-proc in clojure.lang.Compile, which uses the system property clojure.compile.path to define the output directory and accepts a list of

Re: Loading ImageIcons from clojure code

2009-06-19 Thread pmf
On Jun 19, 12:52 pm, Tassilo Horn tass...@member.fsf.org wrote:   foo/bar/baz.clj   foo/bar/i1.png   foo/bar/i2.png I tried (ClassLoader/getSystemResource i1.png), but that looks somewhere in the clojure location, not my apps location... The right thought, but you need to use the full

Re: clojure.contrib.*

2009-06-19 Thread pmf
On Jun 19, 3:11 am, Justin jta...@gmail.com wrote: Is clojure.contrib.* not included with clojure? No; you need to get it from the git-repository at http://github.com/richhickey/clojure-contrib and build it yourself (and don't forget to include the built JAR in your classpath).

Re: How to use primitive array as dispatch value?

2009-06-19 Thread pmf
On Jun 19, 1:31 pm, Josip Gracin josip.gra...@gmail.com wrote: Hi! How do I dispatch on Java primitive array? I mean, my dispatch function is 'class' and I'd like to add method for byte arrays. A not very elegant way would be to simply use (class (make-array Byte/ TYPE 0)) as dispatch value,

Shouldn't c.l.Namespace implement c.l.Named?

2009-06-16 Thread pmf
I've noticed that clojure.lang.Namespace cannot be used with the name- function (like (name *ns*)) because it does not implement clojure.lang.Named. One has to use (.getName *ns*), which is a bit ugly. --~--~-~--~~~---~--~~ You received this message because you are

Re: macro issue

2009-05-20 Thread pmf
On May 20, 4:47 am, Per nondual...@gmail.com wrote: ;; The macro (defmacro def-fields [name  tgs]   `(defstruct ~name ~@(map #(symbol (str : %)) tgs)) ) If you replace the call to 'symbol' with a call to 'keyword', it works (I think this is what you intended).

Re: O-R mapping

2009-03-25 Thread pmf
On Mar 25, 11:35 pm, Raoul Duke rao...@gmail.com wrote: if one doesn't have to convert the db into objects, then is there less impedance mismatch? what is a nice setup in a functional language for working with a db schema? what is your experience/thought? Somewhat less, at least in my

Re: parallel iteration

2009-03-23 Thread pmf
On Mar 24, 12:01 am, Rowdy Rednose rowdy.redn...@gmx.net wrote: Hi group, say I have 2 sequences (def seq-a '(a1 a2 a3)) (def seq-b '(b1 b2 b3)) and want to iterate over them in parallel, like this (par-doseq [a seq-a b seq-b] (prn a b)) which should print a1 b1 a2 b2 a3 b3 A

Re: What's a convenient way of calling super.method()?

2009-03-22 Thread pmf
On Mar 22, 5:10 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: On Mar 21, 4:38 pm, CuppoJava patrickli_2...@hotmail.com wrote: For proxies, I haven't figured out a way yet. Proxies cannot call superclass methods.  Classes generated with gen- class can.  However, if you regularly need

Re: Promise for absense of side effects

2009-03-14 Thread pmf
On Mar 14, 1:08 pm, Meikel Brandmeyer m...@kotka.de wrote: I remember some presentation of someone doing this for, I think, Python. There you hint things, where the type is known and the compiler inferred the rest as far as possible. What cannot be inferred was cast to a special type called

Re: Dynamic loading of code (a la Python)?

2009-03-14 Thread pmf
On Mar 14, 12:44 pm, Rock rocco.ro...@gmail.com wrote: Hi all. I've been working on a piece of code (an xml-rpc server) in Python (actually Jython), and one of its features is the capability of loading modules (connectors in Java) during runtime. Not only are these modules dynamically loaded

Re: Dynamic loading of code (a la Python)?

2009-03-14 Thread pmf
On Mar 14, 5:06 pm, Rock rocco.ro...@gmail.com wrote: proxy = __import__(name) # where name is a string proxy.doOperation(*args) After leaving the method where the above two lines of code are located, the module stored in proxy is no longer accessible, and the resources are released.

Re: Some help for tool builders...

2009-03-13 Thread pmf
On Mar 13, 1:19 pm, Eric Thorsen ethor...@enclojure.org wrote: I come across some functions in clojure/core that are really useful in tool building but often are private. Is it possible to make these public? I'm using the following hack to access private functions (for example generate-class

Re: What profilers are you using?

2009-03-11 Thread pmf
On Mar 11, 4:41 am, Allen Rohner aroh...@gmail.com wrote: Replying to my own question because I figured it out. On the profiler tab, before you hit start profiling, click the settings checkbox. Edit the start from class field. Mine was set to jline.**. After changing it to the appropriate

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-11 Thread pmf
On Mar 11, 4:23 pm, quasar quasistellarli...@gmail.com wrote: It seems it makes Clojure source code to be in the order of lowest-to- highest abstraction. Naive mutual recursion based on top-level functions is impossible. I am curious, is it due to the current implementaiton of Reader or by

Re: Clojure creates lots of classloaders

2009-03-04 Thread pmf
Without dedicated classloaders, temporary (dynamically created) classes would leak (since there is no way to unload a class without letting its classloader be garbage collected). This might or might not be the reason why Clojure uses many classloaders.

Metadata for namespaces

2009-03-04 Thread pmf
Hi, is there a way to attach metadata (especially a docstring) to namespaces? The Namespace-class implements (via AReference - IReference - IMeta) the IMeta-interface, but the obvious way of using the reader-macro to attach metadata does not work and I don't know any other way. I.e. I would

Re: Metadata for namespaces

2009-03-04 Thread pmf
On Mar 4, 11:31 pm, Meikel Brandmeyer m...@kotka.de wrote: (ns foo.bar    docstring goes here    ...) Thanks a lot, this works for me. (Perhaps this should be mentioned in the documentation of the ns-form.) --~--~-~--~~~---~--~~ You received this message

Re: Adding strings

2009-02-26 Thread pmf
On Feb 26, 5:11 pm, Peter Wolf opus...@gmail.com wrote: What is the idiomatic way to concatenate strings?  Here are some things that I expected to work, but didn't     (+ foo bah)     (conj foo bah)     (into foo bah) For the moment I am doing     (.concat foo bah) (str foo bah)

Re: JDK Annotation support?

2009-02-25 Thread pmf
On Feb 26, 1:05 am, Mark Derricutt m...@talios.com wrote: Personally I'd probably find adding annotations at the method level more useful than at the gen-class level.  Although both would certainly be handy. Some examples I'm thinking of would be adding say the spring @Component annotation

*features*-var

2009-02-23 Thread pmf
Some (most, if not all) CL variants have a *features*-var available that contains information about what the implementation supports and what not. Seeing that the issue of determining the Clojure-version in use come up from time to time, maybe it would be useful to introduce something like this

Re: can't get watchers on Vars to work

2009-02-22 Thread pmf
(defn my-watcher-action [current-value reference]   (let [change-count-map current-value         old-count (change-count-map reference)         new-count (if old-count (inc old-count) 1)]   (assoc change-count-map reference new-count))) It seems to me that your problem is that you are not

Re: can't get watchers on Vars to work

2009-02-22 Thread pmf
On Feb 23, 1:55 am, pmf phil.fr...@gmx.de wrote: (defn my-watcher-action [current-value reference]   (let [change-count-map current-value         old-count (change-count-map reference)         new-count (if old-count (inc old-count) 1)]   (assoc change-count-map reference new-count

Re: Invoking Java method through method name as a String

2009-02-21 Thread pmf
On Feb 21, 8:31 am, Richard Lyman richard.ly...@gmail.com wrote: I have an instance of the Java class in a variable. I have the method arguments in a vector. I have the method name as a String. I've tried so many different ways to invoke that method on that class and pass those parameters.

Re: Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread pmf
On Feb 20, 11:40 am, Rowdy Rednose rowdy.redn...@gmx.net wrote: Any elegant ideas or examples on how to do this when the underlying data structure is (a ref to) one of clojure's (immutable) collections, so that a change to that structure will fire the appropriate event? You can use

Re: Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread pmf
Ok,here's a small example that propagates changes to a ref's vector to a watcher: ;; define your model (def model (ref [abc def ghi])) ;; define a watcher (def model-watcher (agent nil)) ;; connect your model to the watcher (add-watcher model :send model-watcher (fn [state source] (println

Re: (Classname/staticField) is not the same as Classname/staticField

2009-01-01 Thread pmf
On Jan 1, 10:19 pm, CuppoJava patrickli_2...@hotmail.com wrote: Hi, For some reason the Classname/staticField macro is not working properly for me. graphics= (AudioSystem/getSystem) #OpenALSystem com.jmex.audio.openal.openalsys...@ec6b00 graphics= AudioSystem/getSystem

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread pmf
On Dec 30, 10:29 pm, falcon shahb...@gmail.com wrote: (doc fn) gives me a description of the function, and information about function arity.  I assumed the description and arity were part of metadata but (meta fn) only returns nil (for a few functions I tried). Be sure to var-quote the

Re: metaprogramming: finding function arity and other information about the envrionment

2008-12-30 Thread pmf
On Dec 30, 11:08 pm, falcon shahb...@gmail.com wrote: Impressive, source file and line numbers are already included! I need to better understand reader macro (or where ever # comes from). You actually need to know two things regarding this issue. In function-definitions, the meta-data is

Re: Vector concatenation

2008-11-30 Thread pmf
On Nov 30, 10:00 am, puzzler [EMAIL PROTECTED] wrote: subvec is O(1) because it takes advantage of sharing.  This is quite useful. Is there a way to write concatvec in an O(1) way, taking advantage of sharing? I suspect that the obvious way to concatenate vectors, i.e., (into [] (concat v1

Re: Stuck with AOT + Classpath

2008-11-30 Thread pmf
On Nov 30, 11:04 am, Adrian Cuthbertson [EMAIL PROTECTED] wrote: Hmm, I tried your dirs and files off my dev directory and the same binding/compile form and it works fine or me - firstly on 1121, but then I checked out 1130 and also no problem. (I'm on jdk 1.5 on OSX). Sure you've created the

Re: Use of / to call static method in generated classes

2008-11-21 Thread pmf
On Nov 21, 10:20 pm, Craig McDaniel [EMAIL PROTECTED] wrote: I can compile and run the example, but it doesn't work with the / syntax for main, even though main is a static method: user (my.hello/main (into-array [Bizarro])) java.lang.Exception: No such var: my.hello/main The function is

Re: writing binary values (bytes) to a file

2008-11-19 Thread pmf
On Nov 19, 5:51 pm, prhlava [EMAIL PROTECTED] wrote: (. ofile write (str                                            (char (bit-shift-right pix 16))                                            (char (bit-shift-right pix 8))                                            (char pix)))                

Patch for gen-class's :exposes

2008-11-09 Thread pmf
Hi, as briefly mentioned on IRC, I've uploaded a patch to the files- section of the group (http://clojure.googlegroups.com/web/genclass-exposes- fix.patch) that fixes the behaviour of gen-class when a field to be exposed via :exposes is not declared in the immediate superclass, but somewhere in