Re: Clojure: Elegance vs. Performance?

2013-07-10 Thread MikeM
> > Clojure people say that jvm doesn't support tco, which it doesn't. So > they implemented a recur macro that turns the function into an > explicitly tcoable function. But, take a look at scala. It can do > (naive) tco optimization without any extra effort from the developer. > And on other

Re: core.async go - out of memory

2013-07-06 Thread MikeM
On Saturday, July 6, 2013 4:01:31 PM UTC-4, tbc++ wrote: > > Go blocks are GC'd but not until they complete running. The problem is > that you're creating go blocks faster than they can run. Creating go blocks > is very cheap, taking/putting into channels is also cheap but not quite as > cheap

Re: core.async go - out of memory

2013-07-06 Thread MikeM
On Saturday, July 6, 2013 11:46:51 AM UTC-4, David Nolen wrote: > > This isn't a bug, you're in a infinite loop constructing go blocks. You > should probably move the loops into the go blocks. > > I assumed go blocks are garbage collected when they go out of scope, but maybe I don't understan

core.async go - out of memory

2013-07-06 Thread MikeM
Got an out of memory when experimenting with core.async channels in go blocks. The following is a simple example. (defn go-loop [] (let [c0 (chan)] (while true (go (>! c0 1)) (go (println (http://groups.google.com/group/clojure?hl=en --- You received this message because you are su

nrepl timeout advice needed

2012-06-11 Thread MikeM
I'm using nrepl with a client created as described in the github readme (https://github.com/clojure/tools.nrepl). The nrepl server and client are on the same machine. Everything's working well, except when I try to eval a long-running bit of code. It seems that the timeout defined for the client is

Re: bug?? extend Object compilation order dependency?

2010-08-26 Thread MikeM
I may have misunderstood what I've read about protocols, so please set me straight if the following is wrong - On Aug 25, 11:08 pm, Stuart Halloway wrote: > I think the current behavior follows the principle of least surprise: > > (1) bar is a function, in whatever namespace the protocol Foo is d

Re: Datatypes and Protocols - early experience program

2009-11-13 Thread MikeM
> (deftype Foo [a b c]) > > (defprotocol P (bar [x] "bar docs")) > > (extend ::Foo P {:bar (fn [afoo] :foo-thing)}) > A common error may be to: (extend Foo P {:bar (fn [afoo] :foo-thing)}) when (extend ::Foo ... is intended. I notice that (extend Foo... doesn't throw - should extend check that

Re: What's the function that checks if an object is "sequence-able"?

2009-06-03 Thread MikeM
BDFL says: http://groups.google.com/group/clojure/browse_frm/thread/3826ba3a52ec8cf7/ea899cfd965744a8?lnk=gst&q=hickey+seqable#ea899cfd965744a8 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: Weird Issue Reading Socket

2009-06-01 Thread MikeM
I don't know if this is part of the problem, but you appear to be calling getInputStream repeatedly on the socket. I think more typically the socket connnection is established, input and output streams are obtained one time only, then the streams are used as needed for the duration of the connecti

Re: Question about building modular code in Clojure

2009-05-19 Thread MikeM
> > So how to do this?  As far as I can tell, these various modules are > all "hard-linked" to point at one another, and I don't see how to make > this linkage more dynamic.  To change one file, I'd have to create new > versions of ALL the files.  It would be great if each file could store > a va

Re: 3D Grapher in Clojure

2009-05-15 Thread MikeM
Nice! I had to learn a bit about jogl to get it to work - had to add - Djava.library.path={path to my jogl lib directory} to my shell script. The following is in model.clj: (defn update [ref val] (when (not (= @ref val)) (dosync (ref-set ref val I believe this is not right: the deref of

Re: The Path to 1.0

2009-04-17 Thread MikeM
> > What does 1.0 mean to you? Are we there yet? Any recommendations for > the organization of the release branches, patch policy etc? > I see 1.0 as indicating there will be a significant period (months) between breaking changes. It seems we are there, based on your comments on API stability. H

Re: Keeping a ref and a DB in sync

2009-04-03 Thread MikeM
In case you haven't seen this thread: http://groups.google.com/group/clojure/browse_frm/thread/aa22a709501a64ac/79b1c858c6d50497?lnk=gst&q=transaction+database#79b1c858c6d50497 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: speed question

2009-04-02 Thread MikeM
There is definline which seems appropriate in place of the constant macros. (definline my-const [] 1) (my-const) ;= 1 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: speed question

2009-04-02 Thread MikeM
Starting with your version, I got about a 2x improvement with the following: (defn check-bounds [x y] (let [f2 (float 2.0) f4 (float 4.0)] (loop [px (float x) py (float y) zx (float 0.0) zy (float 0.0) zx2 (float 0.0) zy2 (float 0.0

Re: Problem with SwingWorker and proxy-super

2009-03-19 Thread MikeM
> However the code (proxy-super publish m) throws this exception: > > # matching method found: publish for class > clojure.proxy.javax.swing.SwingWorker> > publish is a protected method, and I don't think proxy (even with proxy-super) lets you access it. Also, even if it was public, it is a var-

Re: Printing, Reading, and Serializing (+ bug?)

2009-03-17 Thread MikeM
I've used print-dup and read for saving and restoring data and it worked well for me once I defined the needed print-dup methods. Since you said it's ok for you to read your struct back in as a hash map, you can do the following: (defmethod print-dup clojure.lang.PersistentStructMap [o w] (print

Re: Proposal: remove auto-load of user.clj

2009-03-09 Thread MikeM
On Mar 9, 2:18 pm, Raffael Cavallaro wrote: > On Mar 9, 10:58 am, MikeM wrote: > > > Could you share what benefits you get by the auto-load of user.clj > > early in the launch process? > > It allows the automatic loading of development utilities with each > repl l

Re: Proposal: remove auto-load of user.clj

2009-03-09 Thread MikeM
> Every launch of Clojure has the opportunity to specify a classpath to   > use. Since user.clj is loaded from classpath, it seems to me that's a   > sufficient mechanism to avoid loading a given user.clj for a given   > launch of Clojure. Sure, I can definitely control the loading of user.clj

Re: Proposal: remove auto-load of user.clj

2009-03-06 Thread MikeM
> How about removing it from the RT static init and into the REPL function? > I think that would work and it would be transparent for repl users. A command line option to not load user.clj might be nice to have in this case. --~--~-~--~~~---~--~~ You received thi

Proposal: remove auto-load of user.clj

2009-03-06 Thread MikeM
Currently, user.clj is loaded automatically during Clojure boot (in RT static init). I think this is done as a convenience for repl usage, since other apps could easily include a 'load' 'require' or 'use' of whatever is needed. I am proposing that auto-loading of user.clj be removed. A command li

Re: Clojure's syntax design: macros vs functions

2009-03-04 Thread MikeM
>I think that a > shared syntax for both macros and functions calls is a flaw in the > syntax of Lisps, because you can't tell, just by looking at a form, > which expressions get evaluated and which don't, at least when you are > dealing with side effects. You might want to think about macros s

Re: Accessing ASM?

2009-03-04 Thread MikeM
On Mar 4, 5:39 pm, Robert Feldt wrote: > I meant if ASM is already coming with clojure since it is used by > clojure when generating bytecode. Maybe I am missing something... ;) > You can look at genclass.clj for an example of using the ASM that is bundled with Clojure. --~--~-~--~

Re: new Clojure article

2009-03-03 Thread MikeM
> > The only function I could find that takes a vector and returns a list > instead of a vector or a sequence is the reverse function. Are there > others? Map and other lazy functions currently return a LazySeq - (map #(+ %) [1 2 3]) => (2 3 4) cons currently returns a Cons type - (cons 0 [1 2

Re: new Clojure article

2009-03-02 Thread MikeM
> At the end of the Vectors section I say this: > "All the code examples provided above for lists also work for vectors." > > Do you think I should provide more detail than that? I missed that sentence. I think it's helpful to know that some functions return a list type when given a vector, o

Re: new Clojure article

2009-03-02 Thread MikeM
I read the part of your article (on lists and vectors) that you linked to in another thread - In the list section you show the function into and conj as applied to lists, but these can also be applied to vectors and will return vectors, (into [1 2 3] [4 5]) => [1 2 3 4 5] (conj [1 2 3] 4 5) => [

Re: Making agents able to temporarily yield place on thread pool

2009-03-01 Thread MikeM
Not sure if I understand what you need, but could you build on the existing capability to send to the current agent: (send *agent* ...) ? You could have the agent send to itself, then exit the function with some work left to do that would be restarted on the next go-around. --~--~-~--~

updated cfa

2009-03-01 Thread MikeM
I've updated cfa.clj (original thread: http://groups.google.com/group/clojure/browse_frm/thread/ce795dd1fb646df1/e211230f5e230bc5?lnk=gst&q=cfa#e211230f5e230bc5) in the user files for SVN 1315, also many changes to (hopefully) use more idiomatic code. Comments welcome. --~--~-~--~~---

Re: bug? ClassNotFoundException from macro

2009-02-25 Thread MikeM
Thanks very much for the help. Looks like quoting will work. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this grou

bug? ClassNotFoundException from macro

2009-02-24 Thread MikeM
Under SVN 1303, I'm getting a ClassNotFoundException from a macro. Here's a simplified example of the problem: (defn test1 [x] (+ x 1)) (defmacro test2 [form] (list 'list form {:a test1})) (test2 (+ 1 1)) => java.lang.ClassNotFoundException: user$test1__3765 Is this a bug? --~--~-~--~

Re: SVN branches

2009-02-04 Thread MikeM
> > (if [] true false) > > I'd hate to lose the ability to distinguish between an empty > collection and nothing. > As a trade-off to allow nil-punning, you could stipulate the use of coll? in the above situation: (if (coll? []) true false) => true This seems less burdensome - fewer cases where I

Re: SVN branches

2009-02-04 Thread MikeM
> > Other than that, there is just the general loss of nil-punning. This > was the theoretical problem that kept me from making this tradeoff > earlier. I'm very much interesting in hearing from those for whom the > lazy branch represents a real problem due to loss of nil punning. > To preserve n

Re: SVN branches

2009-02-03 Thread MikeM
Code written with the fully-lazy branch certainly looks cleaner than the streams branch equivalent, and having full laziness seems like a plus. The local-clearing mechanism seems like it will be straightforward to use. Seems like this is the way to go. Are there any drawbacks? --~--~-~

SVN branches

2009-02-02 Thread MikeM
There is a "lazy" branch in SVN. The "streams" branch has been discussed, but I haven't seen any discussion of the "lazy" branch - perhaps I missed it. Rich and/or other contributors if you have a little time - I'm curious what changes are being considered and when these might show up in trunk. Al

Re: Agent watchers on Refs

2009-01-27 Thread MikeM
On Jan 27, 10:08 am, Tom Ayerst wrote: > I thought the validator just set "Agent has errors" and you have to check it > explicitly. Vars, refs and agents can have validators. A validator on a ref can prevent the ref from taking on a new value by throwing an exception, which will cause a roll-b

Re: Agent watchers on Refs

2009-01-27 Thread MikeM
> Were watchers synchronous, they would have to run post-transaction > (else a watcher action failure could cause a transaction rollback, > leaving already notified watchers confused). Being post-transaction > would mean that the refs could have been changed by another > transaction in the interi

Re: A nil puzzle

2009-01-23 Thread MikeM
The power set function for lists should use () as the empty set. If you use nil, then it seems that you would have (powerset nil) => (nil) but this is wrong, since the only subset of an empty set is the empty set. You could try to fix this by making (powerset nil) => nil but then your functi

Re: JScrollPane + JTextPane trouble.

2009-01-19 Thread MikeM
This might be helpful: http://os-lists.sun.com/thread.jspa?messageID=457986 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscrib

Re: Observing namespace changes

2009-01-14 Thread MikeM
There's no event mechanism to monitor namespace changes. I accomplish this by taking a snapshot before and after any possible namespace- changing execution, using ns-map. Not as efficient as an event callback, but I haven't had any performance issues (map lookups are plenty fast for me). You can

Re: Newbie: Creating a macro that just calls a function but evaluates its arguments lazily

2009-01-12 Thread MikeM
> After a calling > of "alt" finishes, what happens to all those Delay objects and their > cached values? Are they garbage-collected, or will they remain > indefinitely? Should I worry? > I believe the references to the delays will be dropped as alt executes, so they'll be eligible for grabage c

Re: Newbie: Creating a macro that just calls a function but evaluates its arguments lazily

2009-01-12 Thread MikeM
Not a macro, but does what you want: (defn alt [& functions] (fn [tokens] (some #((force %) tokens) functions))) ;define sub-functions the same way (defn a-meta-meta-function [c] (alt (delay (sub-function1 c)) (delay (sub-function2 c)) (delay (sub- function3 c --~--~-~--~-

Re: Clojure blog post about laziness

2009-01-08 Thread MikeM
> > Do people want it now? > I would vote for 1.0 ahead of streams if adding streams now will delay 1.0. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Bugs in contains? (?)

2009-01-03 Thread MikeM
I believe the exception is expected here due to the implementation of sorted sets. See this thread for explanation of a similar exception thrown by a sorted map: http://groups.google.com/group/clojure/browse_frm/thread/34def2ec6342f40c/c87ee712482110ee#c87ee712482110ee --~--~-~--~~

Re: Agents & send-off

2008-12-24 Thread MikeM
With the addition of release-pending-sends, is it now possible to support await in an agent action? I see that await still throws if used in an agent action, but if a send is released, it seems reasonable to be able to use await. I suppose await could internally do a release-pending-sends to allow

YAREPL - GUI repl updated

2008-12-18 Thread MikeM
Yet Another REPL I uploaded a GUI repl to the group files earlier this year, and I've been updating it as Clojure has evolved. A new version has been uploaded (tested with SVN 1162) http://clojure.googlegroups.com/web/repl.clj , and I've also uploaded a couple of pictures, http://clojure.googlegr

Bug? sorted-map as fn behaves differently than hash-map as fn

2008-12-17 Thread MikeM
With SVN 1162, ((hash-map 'a 1 'b 2) "a") => nil ((sorted-map 'a 1 'b 2) "a") => ClassCastException I would think that sorted-maps and hash-maps should both give nil for this, but perhaps the sorted-map implementation requires a cast? --~--~-~--~~~---~--~~ You rec

Re: Microsoft SQL Server and the sql contrib

2008-12-16 Thread MikeM
To make sure your driver is really on the classpath, try this from the REPL: (. Class (forName "com.microsoft.sqlserver.jdbc.SQLServerDriver")) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To p

Re: Best Way to Ensure a Call to (shutdown-agents)?

2008-12-16 Thread MikeM
You can try this: (let [t (new Thread (fn[] (shutdown-agents)))] (.. java.lang.Runtime (getRuntime) (addShutdownHook t))) It works for me, but seems to take a long time to complete the shutdown. Your question made me wonder if the agent thread pools should use daemon threads - then this woul

Re: Running out of memory when using filter?

2008-12-08 Thread MikeM
I share your concern about the LazyCons problem - hopefully Rich and others are looking into this. I have continued to experiment to see if I can gain some understanding that might help with a solution. The following is something I thought of today, and I'd like to see if others get the same res

Re: Running out of memory when using filter?

2008-12-06 Thread MikeM
Some more experimentation: (defn splode3 [n] (with-local-vars [doc-count 0] (doseq [document (filter #(= % (- n 1)) (map inc (range n)))] (var-set doc-count (inc @doc-count))) 'done)) which does not blow up with (splode3 10). --~--~-~--~~~---~-

Re: Running out of memory when using filter?

2008-12-06 Thread MikeM
I think I've been able to duplicate your results with a simpler example. I first tried this: (defn splode [n] (with-local-vars [doc-count 0] (doseq [document (filter #(= % 1) (range n))] (var-set doc-count (inc @doc-count))) 'done)) and it doesn't blow up with (splode 10

Re: Running out of memory when using filter?

2008-12-06 Thread MikeM
A while back I posted an experimental patch to capture each form that is compiled into a fn. This might be useful in your case, where you have identified a function but don't have details on it. Here's the thread: http://groups.google.com/group/clojure/browse_frm/thread/e63e48a71935e31a?q= Also,

Re: Adding boolean?

2008-12-05 Thread MikeM
Perhaps the reason to not include it is that the utility of the boolean? function is limited. Any value can be used where a clojure boolean is expected - any non-nil value is true and nil is false. --~--~-~--~~~---~--~~ You received this message because you are subs

Re: Eclipse Plugin- any plans for this?

2008-11-21 Thread MikeM
This came up on the list not long ago, don't know what the status is: http://code.google.com/p/clojure-dev/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloju

Re: Changes for AOT compilation

2008-11-14 Thread MikeM
> Just lift your files up a directory to accommodate this change. Note > that this implies that all namespaces should have at least 2 segments, > and following the Java package name guidelines, e.g. > com.mydomain.mylib, is recommended. > I notice that the user namespace is still one segment "us

Re: Java API vs. Special Forms, was Re: "Can't create defs outside of current namespace"

2008-11-13 Thread MikeM
> When (if ever) is it good form to call the underlying Java APIs used   > by Clojure's special forms? I was thinking Rich might reply and weigh in on my suggestion to use an RT method. I'd also like to know if this should be avoided. It seems like it might be ok, since the var method is publi

Re: "Can't create defs outside of current namespace"

2008-11-11 Thread MikeM
This may be a horrible hack, but you can do something like this in your macro: (clojure.lang.RT/var "my-namespace" "hack-fn" (fn[x] (+ 1 x)) This defines a var (creates the namespace if it doesn't exist) and sets its value to a function, and then you can (in-ns 'my-namespace) (hack-fn 1) etc.

Re: prefer-method print-method problem

2008-11-06 Thread MikeM
> > Now *I'm* confused. It's your code that's printing "#=(sorted-map ..." > for me, without any call to "prefer-method" required. > > --Chouser Well, you're not the only one confused. I thought the "#=(sorted- map ..." came from boot.clj somehow, but I now realize my local REPL pulled in user.c

Re: prefer-method print-method problem

2008-11-06 Thread MikeM
I can reproduce what you did in a fresh local REPL (SVN 1075), but my server (also at SVN 1075) doesn't do this. I'm trying to find out how this can be. Any idea where I can find the code that generates the "#=(sorted-map ..." printing? I've looked but can't find it in boot.clj. Thanks for your h

prefer-method print-method problem

2008-11-06 Thread MikeM
I would like to print sorted maps readably (otherwise my sorted maps when printed and read back get turned into the default map), so I tried this: (defmethod print-method clojure.lang.PersistentTreeMap [o, #^java.io.Writer w] (let [eprint (fn eprint [e sep?] (do (print-method (key e) w)

Re: Swing GUI Builder and Clojure

2008-11-04 Thread MikeM
> For the book would people rather see Swing or Qt Jambi examples? I use Swing occasionally, and have never used Qt, but I'd vote for Qt examples to see how it compares. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: A newb question about macros

2008-11-03 Thread MikeM
On Nov 3, 9:57 am, David Nolen <[EMAIL PROTECTED]> wrote: > (defmacro foobar [] >   `'(+ a b)) > > (let >     [a 5 >      b 6] >   (eval (foobar))) > > I know that the above is completely useless but I'm just trying to get > an intuitive understanding of how macros work under Clojure.  At the >

Re: Ants and agents

2008-10-30 Thread MikeM
> My understanding of send and send-off, is that with send-off a new > thread outside the thread pool is used to run the agent action. Actually a different kind of thread pool is used for send-off. It is a cached thread pool obtained from Executors.newCachedThreadPool(), while send uses a thread

Re: BUG? Can't bind a macro

2008-10-24 Thread MikeM
On Oct 23, 9:02 pm, "Mike Hinchey" <[EMAIL PROTECTED]> wrote: > Binding isn't suppose to work for macros.  Macros expand during > compile-time, and binding only affects vars at runtime.   Binding works on vars, and a macro is a function in a var, so binding does work on macros. But you hit the

BUG? Can't bind a macro

2008-10-23 Thread MikeM
In SVN 1075, binding doesn't seem to work for macros: ;defined as fn to avoid "can't take value of a macro" exception (defn bind-test [& args] `(println "bind-test" [EMAIL PROTECTED])) (binding [and bind-test] (and 1)) I recall this used to work (from some experiments I ran in May of this ye

interpose enhancement

2008-10-16 Thread MikeM
I'd like to offer the following version of interpose as a replacement for the current interpose in boot.clj. It's been useful for me and I think it may be for others. (defn intpose "(intpose n sep coll) Returns a lazy seq of the elements of coll separated by sep, with sep inserted after every

read NPE

2008-10-15 Thread MikeM
In SVN 1067, the following throws an NPE: (let [frdr (new java.io.StringReader "{:a 1}") prdr (new java.io.PushbackReader frdr) eof (new Object)] (read prdr nil eof) ) Using false instead of nil works: (let [frdr (new java.io.StringReader "{:a 1}") prdr (new java.io.Pushb

Re: Transitioning from Java to Clojure

2008-10-08 Thread MikeM
> What project types lend themselves to using Java over Clojure, vice > versa, or in combination? > A project where a GUI-building tool (such as Matisse in Netbeans) is needed would be a case where Java may still be required. Anything done in Java can be done in Clojure quite readily, with proxy

(gensym "1")

2008-09-30 Thread MikeM
This may fall into the category of "well, don't do that", but it seems that gensym shouldn't return an invalid symbol. (gensym "1") ;=> 15459 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post t

Re: Cells in Clojure

2008-09-22 Thread MikeM
> "If during the function execution any other dispatches are made > (directly or indirectly), they will be held until after the state of > the Agent has been changed." > > That means that if, as a result of an update, some agent sends > messages to others, they will definitely arrive after the or

Re: Cells in Clojure

2008-09-22 Thread MikeM
> On second thought, maybe Agents will work, if one can enforce the > ordering of updates.   "Actions dispatched to an agent from another single agent or thread will occur in the order they were sent" (from clojure.org/agents) - seems like this may be helpful, but since updates can occur from mu

Re: Cells in Clojure

2008-09-21 Thread MikeM
Thanks for doing this. I've been curious about cells for a while, and wondered how it could be done in Clojure. Your comment (in the other thread) about using agents inspired me to see how this would work. I've uploaded acells.clj to the group, which is my attempt at converting your cells impleme

Re: Observations and questions regarding long-running, adaptable, transparent software

2008-09-19 Thread MikeM
Someone's been working on cells for clojure: http://paste.lisp.org/display/66688 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsu

PermGen issue

2008-09-14 Thread MikeM
If you haven't already seen it, an interesting post from Charles Nutter on implementing dynamic languages on the JVM: http://blog.headius.com/2008/09/first-taste-of-invokedynamic.html Nutter mentions a possible OutOfMemory condition that can occur due to filling the PermGen part of the heap with

LazyCons NPE

2008-09-12 Thread MikeM
Adding meta data to a lazy cons throws an NPE in line 44 of LazyCons.java: (let [lazycons (map identity (range 10))] (with-meta lazycons {:a 1})) It appears that when the LazyCons(IPersistentMap meta, Object first, ISeq rest) constructor is used, the supplied first and rest are ignored, and

Re: Threads and Functions Question

2008-09-08 Thread MikeM
You can try the following: (defn trd[] (let [f #(binding [*ns* *ns*] (in-ns 'user) (eval '(tst)))] (. (Thread. f) start) )) This sets the namespace for your new thread before it evals. You also might want to take a look at clojure.lang.Repl for an example of how to create a REPL, also repl