Re: clojure-clr - getting started on Windows WPF

2011-04-14 Thread Marius Kjeldahl

On 04/14/2011 05:52 AM, dmiller wrote:
> Reloading will definitely cause a problem.
> ...
> I don't know why you'd need the app atom since you can just use
> Application/Current.  Similarly, you could check Application/Current
> before doing (Application.)

In theory, that all sounds easy, but I haven't managed to pull it off. 
That may very well be due to the challenge of juggling threads and 
dispatchers, and other .Net specific abstractions I've only scratched 
the surface off yet.


I replaced the app atom with code that creates an instance of 
Application only when needed (reusing Application/Current instead when 
not needed), but it still does not work. Maybe there's stuff I need to 
do to the threads and dispatchers as well.


Thanks anyway,

Marius K.

--
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-14 Thread Meikel Brandmeyer
And more numbers. d-small does not contain vectors with more than 50
elements, so the unrolled version should always hit a special case in
this run. However it's still twice as slow as the eager versions. The
lazy version is still the fastest.

user=> (bench (doall (flatten-maps d-small)))
Evaluation count : 178800
Execution time mean  : 339,323714 us  95,0% CI: (339,289416
us, 339,355491 us)
Execution time std-deviation : 230,980191 us  95,0% CI: (227,899625
us, 233,485542 us)

Found 4 outliers in 60 samples (6,6667 %)
low-severe   1 (1,6667 %)
low-mild 3 (5, %)
 Variance from outliers : 1,6389 % Variance is slightly inflated by
outliers
nil
user=> (bench (doall (flatten-maps-lazy d-small)))
Evaluation count : 566940
Execution time mean  : 107,110779 us  95,0% CI: (107,091586
us, 107,128627 us)
Execution time std-deviation : 191,129374 us  95,0% CI: (188,661708
us, 194,471356 us)

Found 6 outliers in 60 samples (10, %)
low-severe   3 (5, %)
low-mild 3 (5, %)
 Variance from outliers : 7,7967 % Variance is slightly inflated by
outliers
nil
user=> (bench (flatten-maps-eager d-small))
Evaluation count : 300180
Execution time mean  : 200,602507 us  95,0% CI: (200,593358
us, 200,612076 us)
Execution time std-deviation : 74,282029 us  95,0% CI: (73,775380 us,
74,737722 us)

Found 5 outliers in 60 samples (8, %)
low-severe   5 (8, %)
 Variance from outliers : 1,6389 % Variance is slightly inflated by
outliers
nil
user=> (bench (flatten-maps-eager2 d-small))
Evaluation count : 378240
Execution time mean  : 160,993940 us  95,0% CI: (160,986922
us, 161,004688 us)
Execution time std-deviation : 92,671071 us  95,0% CI: (92,092872 us,
93,203776 us)

Found 2 outliers in 60 samples (3, %)
low-severe   2 (3, %)
 Variance from outliers : 1,6389 % Variance is slightly inflated by
outliers
nil
user=> (bench (flatten-maps-recur d-small))
Evaluation count : 414120
Execution time mean  : 144,263391 us  95,0% CI: (144,256078
us, 144,274633 us)
Execution time std-deviation : 93,741441 us  95,0% CI: (92,933787 us,
94,772247 us)

Found 2 outliers in 60 samples (3, %)
low-severe   2 (3, %)
 Variance from outliers : 1,6389 % Variance is slightly inflated by
outliers
nil
user=> (bench (doall (flatten-maps-unrolled {:a 1 :b 2 :c d-small})))
Evaluation count : 199980
Execution time mean  : 305,349926 us  95,0% CI: (305,318154
us, 305,379684 us)
Execution time std-deviation : 207,748680 us  95,0% CI: (206,662722
us, 208,693183 us)

Found 1 outliers in 60 samples (1,6667 %)
low-severe   1 (1,6667 %)
 Variance from outliers : 1,6389 % Variance is slightly inflated by
outliers
nil

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-14 Thread Meikel Brandmeyer
Hi Laurent,

On 14 Apr., 09:42, Laurent PETIT  wrote:

> Doesn't it seem counter intuitive to you that the lazy version is the
> fastest ?
>
> What could explain the result of your tests ? (I'm really curious !)

This is exactly the question I had earlier in this thread. :) I was
also surprised by the result. Hence my confusion about the gist of
Kevin. I thought it was trying to explain something rather than being
just a different implementation.

One difference between the original version and the lazy-version, is
that the original version builds a higher stack of concats while the
lazy version just builds a simple sequence, which could a reason for
its better performance. But the doesn't explain the other results.

Please show me my mistake. :)

Sincerely
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: 1.3.0alpha5: gen-class, java.io.Serializable, readObject, writeObject....

2011-04-14 Thread Jules
I could :-)

At the moment I have a hack() method which I call explicitly 
post-deserialisation. This allows me to remain pure-Clojure. I'm not sure 
that the necessary complexity required to do it right is worthwhile in my 
particualr usecase - but thanks for all your suggestions.

Jules

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-14 Thread Meikel Brandmeyer
Hi again,

On 14 Apr., 09:42, Laurent PETIT  wrote:

> What could explain the result of your tests ? (I'm really curious !)

On the other hand the lazy version really just creates a simple linked
list with some fast boilerplate concerning the laziness. The vectors
however *are* more involved to construct. Their strength is their
performance later on when actually *accessing* the elements. This is
not what we do here. So maybe there is some sense in the results?
However I don't understand the perfomance of the recur solution in
this light.

Sincerely
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which classloader is used by the compiler for new forms?

2011-04-14 Thread Konrad Hinsen
On 13 Apr, 2011, at 17:16 , Aaron Cohen wrote:

> Do you need to bind *use-context-classloader* to true?

I considered this, not so much because I understand what this setting is good 
for, but because its name suggests it might be relevant. But then I looked at 
the source code to figure what what actually does, and my conclusion is: 
nothing. The var *use-context-classloader* is created with the default binding 
"true", and the only place where it is modified pushes a thread binding to 
"true" as well. So as long as nothing outside Clojure itself binds this to 
"false", it should always be "true".

On the other hand, the function baseLoader() in RT.java does suggest that this 
setting is of relevance. I just don't understand how it is support to work.

Konrad.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-14 Thread Laurent PETIT
2011/4/14 Meikel Brandmeyer :
> Hi again,
>
> On 14 Apr., 09:42, Laurent PETIT  wrote:
>
>> What could explain the result of your tests ? (I'm really curious !)
>
> On the other hand the lazy version really just creates a simple linked
> list with some fast boilerplate concerning the laziness. The vectors
> however *are* more involved to construct. Their strength is their
> performance later on when actually *accessing* the elements. This is
> not what we do here. So maybe there is some sense in the results?
> However I don't understand the perfomance of the recur solution in
> this light.

I don't understand either.
Anyway, if there is no flaw in the tests, this could end as a good
example of where premature optimization (of CPU at least) via recur
does not get the expected result !

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which classloader is used by the compiler for new forms?

2011-04-14 Thread Laurent PETIT
Hi,

2011/4/14 Konrad Hinsen :
> On 13 Apr, 2011, at 17:16 , Aaron Cohen wrote:
>
>> Do you need to bind *use-context-classloader* to true?
>
> I considered this, not so much because I understand what this setting is good 
> for, but because its name suggests it might be relevant. But then I looked at 
> the source code to figure what what actually does, and my conclusion is: 
> nothing. The var *use-context-classloader* is created with the default 
> binding "true", and the only place where it is modified pushes a thread 
> binding to "true" as well. So as long as nothing outside Clojure itself binds 
> this to "false", it should always be "true".
>
> On the other hand, the function baseLoader() in RT.java does suggest that 
> this setting is of relevance. I just don't understand how it is support to 
> work.

I won't pretend I understand how all this works, especially wrt to
subtleties between loading from clojure, auto-loading of AOT compiled
gen-classes, etc., but what has worked great so far for clojure.osgi
and indirectly for CCW in a complex classloader hell context (OSGi)
was the following:

* set the context class loader via
Thread.currentThread().setContextClassLoader(loader)
* rebind Compiler.LOADER with loader

Note: I do not pretend this works in all situations, nor do I pretend
that one of the two above is redundant, nor that there could be a
simpler (cleaner !) solution.

But better check the source by yourself : (we're using clojure.osgi
version 1.2.10 for ccw, so check this tag to be certain we're talking
about the same thing) :

https://github.com/aav/clojure.osgi/blob/1.2.10/clojure.osgi/src/clojure/osgi/ClojureOSGi.java

Cheers,

-- 
Laurent

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-14 Thread Meikel Brandmeyer
Hi,

On 14 Apr., 11:35, Laurent PETIT  wrote:

> I don't understand either.
> Anyway, if there is no flaw in the tests, this could end as a good
> example of where premature optimization (of CPU at least) via recur
> does not get the expected result !

Always prove your assumptions. But I'm still suspicious of a test
flaw. I use criterium to ensure that at least someone had some
(hopefully) clever ideas about this micro-benchmarking stuff in the
light of JIT and such (dead code elimination, warm-up runs, etc.). But
still there are a lot of opportunities for things to go wrong or be
mis-interpreted.

Maybe the results are correct, maybe not. Either way I'd like to
understand why they are the way they are.

Sincerely
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Which classloader is used by the compiler for new forms?

2011-04-14 Thread Konrad Hinsen
On 14 Apr, 2011, at 11:43 , Laurent PETIT wrote:

> I won't pretend I understand how all this works, especially wrt to
> subtleties between loading from clojure, auto-loading of AOT compiled
> gen-classes, etc., but what has worked great so far for clojure.osgi
> and indirectly for CCW in a complex classloader hell context (OSGi)
> was the following:
> 
> * set the context class loader via
> Thread.currentThread().setContextClassLoader(loader)
> * rebind Compiler.LOADER with loader

That works for me as well, thanks!

Konrad.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-14 Thread Laurent PETIT
2011/4/14 Meikel Brandmeyer :
> Hi,
>
> On 14 Apr., 11:35, Laurent PETIT  wrote:
>
>> I don't understand either.
>> Anyway, if there is no flaw in the tests, this could end as a good
>> example of where premature optimization (of CPU at least) via recur
>> does not get the expected result !
>
> Always prove your assumptions. But I'm still suspicious of a test
> flaw. I use criterium to ensure that at least someone had some
> (hopefully) clever ideas about this micro-benchmarking stuff in the
> light of JIT and such (dead code elimination, warm-up runs, etc.). But
> still there are a lot of opportunities for things to go wrong or be
> mis-interpreted.
>
> Maybe the results are correct, maybe not. Either way I'd like to
> understand why they are the way they are.
>

Yes, we'll have to wait for more hard-core clojurers than the two of
us to explain either where the flaw is, either the explanation to this
! :-)

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: fnparse: alt over matches ?

2011-04-14 Thread LordGeoffrey
Thanks, I don't know how it got in my head but i thought it was supposed 
to have side-effects.


On 12/04/11 01:56, Alan wrote:

Your "semantics" have side effects. The parser shouldn't be printing
to stdout, because it's still in the middle of backtracking and
deciding what matches. Instead the semantics should be more like (fn
[x] (str "ANY: " x)); then you won't see any results unless a complete
parse happens.

On Apr 11, 3:54 am, LordGeoffrey  wrote:

Exercising the code below with (f "ab") produces:
A: a
ANY: a
ANY: b

Which implies (at least to me) that - alt seems to match "a" twice once
against the lit and once against anything. Any suggestions would be
appreciated.

fnparse v: 2.2.7
clojure v: 1.2.0
---
(use 'name.choi.joshua.fnparse)

(defn run-p
[parser input]
(let [result (rule-match parser
 #(prn "fail:" %&)
 #(prn "incomplete:" %&)
 {:remainder input})]
  (cond (nil? result) nil
(vector? result) (apply str result)
:else (str result

(defn f [str]
(run-p
 (rep*
  (alt (semantics (lit \a) (fn [x] (println "A:" x)))
   (semantics anything (fn [x] (println "ANY:" x)
 str) )


--
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Cyber Dungeon Quest Alpha 1

2011-04-14 Thread msappler
My RPG Game in clojure!

Play it here via Java Web Start:

http://resatori.com/cyber-dungeon-quest-alpha-1

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread Alfredo
Very cool!
But how to play with it? With Chrome, it downloads the .jnlp file but
if I click on it, an error raises:


com.sun.deploy.net.FailedDownloadException: Unable to load resource:
http://sappler.ls4.allbytes.de/cdq/cdq.jnlp
at
com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
1372)
at
com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
1525)
at
com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
1503)
at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
1609)
at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
1534)
at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
217)
at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
201)
at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:477)
at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:256)
at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:207)
at com.sun.javaws.Launcher.launch(Launcher.java:124)
at com.sun.javaws.Main.launchApp(Main.java:446)
at com.sun.javaws.Main.continueInSecureThread(Main.java:278)
at com.sun.javaws.Main$1.run(Main.java:116)
at java.lang.Thread.run(Thread.java:680)

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread msappler
Thanks. That was a last minute change of the jnlp file location.

Should work now.

On 14 Apr., 13:39, Alfredo  wrote:
> Very cool!
> But how to play with it? With Chrome, it downloads the .jnlp file but
> if I click on it, an error raises:
>
> com.sun.deploy.net.FailedDownloadException: Unable to load 
> resource:http://sappler.ls4.allbytes.de/cdq/cdq.jnlp
>         at
> com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
> 1372)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1525)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1503)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1609)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1534)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 217)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 201)
>         at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:477)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:256)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:207)
>         at com.sun.javaws.Launcher.launch(Launcher.java:124)
>         at com.sun.javaws.Main.launchApp(Main.java:446)
>         at com.sun.javaws.Main.continueInSecureThread(Main.java:278)
>         at com.sun.javaws.Main$1.run(Main.java:116)
>         at java.lang.Thread.run(Thread.java:680)

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread msappler
Thanks. That was a last minute change of the jnlp file location.

Should work now.

On 14 Apr., 13:39, Alfredo  wrote:
> Very cool!
> But how to play with it? With Chrome, it downloads the .jnlp file but
> if I click on it, an error raises:
>
> com.sun.deploy.net.FailedDownloadException: Unable to load 
> resource:http://sappler.ls4.allbytes.de/cdq/cdq.jnlp
>         at
> com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
> 1372)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1525)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1503)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1609)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1534)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 217)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 201)
>         at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:477)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:256)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:207)
>         at com.sun.javaws.Launcher.launch(Launcher.java:124)
>         at com.sun.javaws.Main.launchApp(Main.java:446)
>         at com.sun.javaws.Main.continueInSecureThread(Main.java:278)
>         at com.sun.javaws.Main$1.run(Main.java:116)
>         at java.lang.Thread.run(Thread.java:680)

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread Walter Chang
failed to run on mbp osx 10.6.7 (java version "1.6.0_24").  here is the
stack trace:

java.lang.NullPointerException
at
org.lwjgl.opengl.MacOSXContextImplementation.setSwapInterval(MacOSXContextImplementation.java:121)
at org.lwjgl.opengl.Context.setSwapInterval(Context.java:231)
at org.lwjgl.opengl.Display.setSwapInterval(Display.java:993)
at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:1005)
at org.newdawn.slick.GameContainer.setVSync(GameContainer.java:805)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:90)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at game.start$fn__3815$start__3816.invoke(start.clj:33)
at game.start$_main.invoke(start.clj:37)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at game.start.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:1909)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
at com.sun.javaws.Launcher.run(Launcher.java:138)
at java.lang.Thread.run(Thread.java:680)


On Thu, Apr 14, 2011 at 8:09 PM, msappler  wrote:

> Thanks. That was a last minute change of the jnlp file location.
>
> Should work now.
>
> On 14 Apr., 13:39, Alfredo  wrote:
> > Very cool!
> > But how to play with it? With Chrome, it downloads the .jnlp file but
> > if I click on it, an error raises:
> >
> > com.sun.deploy.net.FailedDownloadException: Unable to load resource:
> http://sappler.ls4.allbytes.de/cdq/cdq.jnlp
> > at
> > com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
> > 1372)
> > at
> > com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> > 1525)
> > at
> > com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> > 1503)
> > at
> >
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> > 1609)
> > at
> >
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> > 1534)
> > at
> com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> > 217)
> > at
> com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> > 201)
> > at
> com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:477)
> > at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:256)
> > at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:207)
> > at com.sun.javaws.Launcher.launch(Launcher.java:124)
> > at com.sun.javaws.Main.launchApp(Main.java:446)
> > at com.sun.javaws.Main.continueInSecureThread(Main.java:278)
> > at com.sun.javaws.Main$1.run(Main.java:116)
> > at java.lang.Thread.run(Thread.java:680)
>
> --
> 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 be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
...__o
...\<,
( )/ ( )...

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread msappler
Hmm I updated the natives-mac.jar.
But dont know this error I dont have a mac..

On 14 Apr., 14:16, Walter Chang  wrote:
> failed to run on mbp osx 10.6.7 (java version "1.6.0_24").  here is the
> stack trace:
>
> java.lang.NullPointerException
> at
> org.lwjgl.opengl.MacOSXContextImplementation.setSwapInterval(MacOSXContextImplementation.java:121)
> at org.lwjgl.opengl.Context.setSwapInterval(Context.java:231)
> at org.lwjgl.opengl.Display.setSwapInterval(Display.java:993)
> at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:1005)
> at org.newdawn.slick.GameContainer.setVSync(GameContainer.java:805)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:90)
> at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
> at game.start$fn__3815$start__3816.invoke(start.clj:33)
> at game.start$_main.invoke(start.clj:37)
> at clojure.lang.AFn.applyToHelper(AFn.java:159)
> at clojure.lang.AFn.applyTo(AFn.java:151)
> at game.start.main(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at com.sun.javaws.Launcher.executeApplication(Launcher.java:1909)
> at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
> at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
> at com.sun.javaws.Launcher.run(Launcher.java:138)
> at java.lang.Thread.run(Thread.java:680)
>
>
>
> On Thu, Apr 14, 2011 at 8:09 PM, msappler  wrote:
> > Thanks. That was a last minute change of the jnlp file location.
>
> > Should work now.
>
> > On 14 Apr., 13:39, Alfredo  wrote:
> > > Very cool!
> > > But how to play with it? With Chrome, it downloads the .jnlp file but
> > > if I click on it, an error raises:
>
> > > com.sun.deploy.net.FailedDownloadException: Unable to load resource:
> >http://sappler.ls4.allbytes.de/cdq/cdq.jnlp
> > >         at
> > > com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
> > > 1372)
> > >         at
> > > com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> > > 1525)
> > >         at
> > > com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> > > 1503)
> > >         at
>
> > com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> > > 1609)
> > >         at
>
> > com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> > > 1534)
> > >         at
> > com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> > > 217)
> > >         at
> > com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> > > 201)
> > >         at
> > com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:477)
> > >         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:256)
> > >         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:207)
> > >         at com.sun.javaws.Launcher.launch(Launcher.java:124)
> > >         at com.sun.javaws.Main.launchApp(Main.java:446)
> > >         at com.sun.javaws.Main.continueInSecureThread(Main.java:278)
> > >         at com.sun.javaws.Main$1.run(Main.java:116)
> > >         at java.lang.Thread.run(Thread.java:680)
>
> > --
> > 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 be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
> --
> ...__o
> ...\<,
> ( )/ ( )...

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure-clr - getting started on Windows WPF

2011-04-14 Thread Marius Kjeldahl

FWIW, I did a small writeup of my first encounter with clojure-clr at:

http://kjeldahl.net/d7/clojure-clr-first-encounter

Thanks,

Marius K.

On 04/14/2011 09:04 AM, Marius Kjeldahl wrote:

On 04/14/2011 05:52 AM, dmiller wrote:
 > Reloading will definitely cause a problem.
 > ...
 > I don't know why you'd need the app atom since you can just use
 > Application/Current. Similarly, you could check Application/Current
 > before doing (Application.)

In theory, that all sounds easy, but I haven't managed to pull it off.
That may very well be due to the challenge of juggling threads and
dispatchers, and other .Net specific abstractions I've only scratched
the surface off yet.

I replaced the app atom with code that creates an instance of
Application only when needed (reusing Application/Current instead when
not needed), but it still does not work. Maybe there's stuff I need to
do to the threads and dispatchers as well.

Thanks anyway,

Marius K.



--
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Announcement: pretzel - a predicate library + call for suggestions

2011-04-14 Thread gaz jones
coincidentally, me and my brother wrote this while on the train to
rubyconf last year:

https://github.com/mikejones/mississippi

havent put any docs or anything on there (its only a couple of
functions), but is essentially a validation function that take a map
(the thing to validate) and another map (the validations to apply) and
returns the original map with an :errors map assoc'd to it. comes with
a couple of pre-baked  validation functions, but not many.

works pretty well for the use cases i currently have... *shrug*

On Tue, Apr 12, 2011 at 7:53 PM, James Reeves  wrote:
> On 12 April 2011 22:04, Joost  wrote:
>> For now, I think of the pretzel library as the lowest useful level of
>> abstraction for input tests. And for low level abstractions, I prefer
>> to place a higher value on correctness, extensibility, consistency and
>> possibly even performance (in roughly that order) than ease of use
>> from a direct programmer's stand point.
>
> I think I agree.
>
>> It might be better to put those predicates in a numeric
>> namespace or library that doesn't address strings at all, maybe
>> relying on a conversion layer somewhere if your input is really string-
>> based, or maybe to have string-based counterparts relying on the
>> numeric tests.
>
> That's a good idea. Perhaps something like:
>
>  (defn from-string [f]
>    (comp f parse-number))
>
>  (from-string (in-range 1 10))
>
> But with a better name than "from-string".
>
> - James
>
> --
> 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 be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


CFP: Commercial Users of Functional Programming 2011

2011-04-14 Thread Anil Madhavapeddy
Commercial Users of Functional Programming Workshop (CUFP) 2011
Call for Presentations: http://cufp.org/2011-call-presentations

Sponsored by SIGPLAN
Co-located with ICFP 2011

Tokyo, Japan
Sep 22-24

Proposal Submission Deadline 15 June 2011

Functional programming languages have been a hot topic of academic
research for over 35 years, and they have seen an ever larger
practical impact in settings ranging from tech startups to financial
firms to biomedical research labs. At the same time, a vigorous
community of programmers employing functional languages has come
into existence.

CUFP is designed to serve this community. The annual CUFP workshop
is a place where people can see how others are using functional
programming to solve real world problems; where practitioners meet
and collaborate; where language designers and users can share ideas
about the future of their favorite language; and where one can learn
practical techniques and approaches for putting functional programming
to work.

# Giving a CUFP Talk

If you have experience using functional languages in a practical
setting, we invite you to submit a proposal to give a talk at the
workshop. We're looking for two kinds of talks:

*Experience reports* are typically 25 minutes long, and aim to
inform participants about how functional programming plays out in
real-world applications, focusing especially on lessons learned and
insights gained. Experience reports don't need to be highly technical;
reflections on the commercial, management, or software engineering
aspects are, if anything, more important.

*Technical talks* are also 25 minutes long, and should focus on
teaching the audience something about a particular technique or
methodology, from the point of view of someone who has seen it play
out in practice. These talks could cover anything from techniques
for building functional concurrent applications, to managing dynamic
reconfigurations, to design recipes for using types effectively in
large-scale applications. While these talks will often be based on
a particular language, they should be accessible to a broad range
of programmers.

If you are interested in offering a talk, or nominating someone to
do so, send an e-mail to avsm2(at)cl(dot)cam(dot)ac(dot)uk or
yminsky(at)janestreet(dot)com by 15 June 2011 with a short description
of what you'd like to talk about or what you think your nominee
should give a talk about. Such descriptions should be about one
page long.

There will be a short scribes report of the presentations and
discussions but not of the details of individual talks, as the
meeting is intended to be more a discussion forum than a technical
interchange. You do not need to submit a paper, just a proposal for
your talk!


# Program Committee

* Anil Madhavapeddy (University of Cambridge)
* Yaron Minsky (Jane Street)
* Jun Furuse (Standard Chartered)
* Marius Eriksen (Twitter Inc.)
* Michael Williams (Ericsson)
* Mike McClurg (Citrix Systems R&D)
* R. Kent Dybvig (Indiana University)
* Richard Minerich (Bayard Rock)
* Sally Browning (Galois)
* Shankar Natarajan (SRI Inc.)

# Tutorials and BOFs

* Michael Sperber (DeinProgramm)
* Duncan Coutts (Well Typed Inc.)
* Ashish Agarwal (NYU)

More information

For more information on CUFP, including videos of presentations
from previous years, take a look at the CUFP website at http://cufp.org
and this call for papers at http://cufp.org/2011-call-presentations

Note that presenters, like other attendees, will need to register
for the event. Presentations will be video taped and presenters
will be expected to sign an ACM copyright release form. Acceptance
and rejection letters will be sent out by July 15th.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Weening myself off of global state - what's the idiomatic way to solve this?

2011-04-14 Thread Brandon Ferguson
I'm not sure if this is the place to ask this but I've been struggling
with a few things in the world of Clojure. I've been using Processing
to learn Clojure (since I'm somewhat familiar with Processing) but the
tough part has been dealing with things like x, y positions of objects
without keeping some global state (I'm not sure if it's even
possible).

The code in question is: https://gist.github.com/887256

All this does is bounce a ball around a screen, for every frame
Processing calls draw which moves the ball one frame. Since I'm not
the one driving the loop I ended up using atoms to update some bits of
global state but that feels really dirty.

If I could drive the frames it would be easy to use recur or some
other bit of state passing as I render each successive frame. I've
considered using sequences and passing a frame number (which would be
stored in a global as well) in but then it'd (I assume) have to run
through every number up to that the one I passed it. Seems like
performance would degrade the longer it ran. There's also this idea
rattling around in my head where I'd just rewrite the function
everytime with the new state - but seems like you couldn't scale that
to multiple balls bouncing around (which is the next step) - and God
knows what, if any, performance implications that would have.

So I'm not sure where that leaves me - learning functional stuff can
be wonderfully mind breaking but sometimes I feel like I don't even
have the tools in my head to work some things out. Is there some
technique I'm missing for dealing with state between successive calls
of a function?

How would you solve something like this?
-Brandon

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure group in DFW area

2011-04-14 Thread J.R. Garcia
I live in Fort Worth and work in Addison. I'd love to get together
sometime. If there is any interest in getting a user group together, I
have the perfect place to host it.

On Mar 10, 8:28 am, Alex Robbins 
wrote:
> Anyone else in the north Dallas area using/interested in Clojure? I'd
> love to get together.
>
> Alex

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


[ANN] Tikkba v.0.1 a Clojure library for the creation and the dynamic modification of SVG documents

2011-04-14 Thread Pierre Allix
Hello,

I would like to announce the version 0.1 of the Tikkba library, a
library for the creation and the dynamic modification of SVG
documents.

I would be really happy with any feedbacks and comments, on the code
or the architecture.

While the library is not complete it is already extremely usable and
useful.


>From the README file:

Tikkba is a Clojure library for the creation and the dynamic
modification of SVG documents. It wraps the Apache Batik library and
provides functions to create SVG images with the Clojure-based SVG DSL
of the Analemma library.

Batik is a Java-based toolkit for applications or applets that want to
use images in the Scalable Vector Graphics (SVG) format for various
purposes, such as display, generation or manipulation.

http://xmlgraphics.apache.org/batik/index.html

http://liebke.github.com/analemma/


The library is available on GitHub:

https://github.com/pallix/tikkba

and on Clojars:

http://clojars.org/tikkba

This library is being developed as part of the Carneades project:

http://carneades.berlios.de/

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Speakers for April 20th meeting of the NYC Clojure Users group

2011-04-14 Thread Eric Thorsen
We are looking for speakers for our next meeting (and future
meetings).
If you are ever traveling to the big apple and would like to speak to
a group of enthusiastic Clojurians, please let me know.
We meet at the google campus in Manhattan every month and are always
looking for interesting speakers to discuss anything related to
Clojure development.

Thanks,
Eric

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: better error messages > smaller stack traces

2011-04-14 Thread Sam Aaron
Here's something that could be clearer (it wasn't obvious to me that something 
like addition would cause a null pointer exception):

user=> (+ 1 nil)
java.lang.NullPointerException (NO_SOURCE_FILE:0)

Sam

---
http://sam.aaron.name

On 8 Feb 2011, at 14:01, Stuart Halloway wrote:

> This conversation began on Twitter [1] but I want to continue it on the 
> mailing list as it may be of broader interest.
> 
> The core team is very interested in improving error messages, and relatively 
> less interested in more code to manipulate stack traces, for the following 
> reasons:
> 
> (1) The language sits at the bottom, and must solve the problems nobody 
> higher up can solve. Error messages are created at the point of an error, and 
> if the language gets it wrong you may not have the information to fix it 
> later. OTOH, any old library code can reduce a stacktrace.
> 
> (2) Better error messages are easy to implement [2]. Most oddball errors are 
> in macroexpansion, so there is no runtime cost to doing extra work to improve 
> error messages. These can be implemented as pure functions, so even a 
> relative beginner could contribute a patch.
> 
> (3) The clojure.repl/pst macro in 1.3 already provides better control of 
> stack trace spewage at the REPL.
> 
> Please let us know when you get a misleading error message from a 
> macroexpansion, so we can make it better. Or contribute a patch along the 
> lines of [2].
> 
> Thanks,
> Stu
> 
> Stuart Halloway
> Clojure/core
> http://clojure.com
> 
> [1] http://twitter.com/marick/statuses/33760838540070912
> [2] 
> https://github.com/clojure/clojure/commit/d694d6d45fb46195ae4de01aab9a2b9f9c06355f
> 
> -- 
> 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 be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


partial vs anonymous function?

2011-04-14 Thread David McNeil
I am puzzled by the results below. Can anyone explain the difference
in behavior?

-David



(defn mapper [f stream]
  `(map ~f ~stream))

(eval (mapper #(+ 1 %) [10 11 12]))
;; -> (11 12 13)

(eval (mapper (partial + 1) [10 11 12]))
;; -> No matching ctor found for class clojure.core$partial...

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread Mark Rathwell
Try this:

(eval (mapper `(partial + 1) [10 11 12]))


On Thu, Apr 14, 2011 at 9:46 AM, David McNeil wrote:

> I am puzzled by the results below. Can anyone explain the difference
> in behavior?
>
> -David
>
> 
>
> (defn mapper [f stream]
>  `(map ~f ~stream))
>
> (eval (mapper #(+ 1 %) [10 11 12]))
> ;; -> (11 12 13)
>
> (eval (mapper (partial + 1) [10 11 12]))
> ;; -> No matching ctor found for class clojure.core$partial...
>
> --
> 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 be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: partial vs anonymous function?

2011-04-14 Thread David McNeil
Mark - Thanks. I am able to permute it to make it work. However, I
cannot explain why the original code fails.

-David

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread Mark Rathwell
I think it has to do with partial's use of apply, but you would need someone
smarter than me to tell you for sure ;)


On Thu, Apr 14, 2011 at 9:58 AM, David McNeil wrote:

> Mark - Thanks. I am able to permute it to make it work. However, I
> cannot explain why the original code fails.
>
> -David
>
> --
> 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 be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure group in DFW area

2011-04-14 Thread Alex Robbins
Glad to hear from you. I live and work a little south of the
intersection of 121 and the Dallas North Tollway, so any meeting place
along the DNT would be great for me (Addison included).

Hopefully there are more than two clojure users in Dallas.

On Wed, Apr 13, 2011 at 3:44 PM, J.R. Garcia  wrote:
> I live in Fort Worth and work in Addison. I'd love to get together
> sometime. If there is any interest in getting a user group together, I
> have the perfect place to host it.
>
> On Mar 10, 8:28 am, Alex Robbins 
> wrote:
>> Anyone else in the north Dallas area using/interested in Clojure? I'd
>> love to get together.
>>
>> Alex
>
> --
> 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 be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread Mark Rathwell
Actually, that doesn't seem to be the case, seems to have something to do
with the closure affecting macro expansion, but again, need someone smarter
to explain:

user> (defn plus-x [x] (fn [y] (+ x y)))
#'user/plus-x

user> (eval (mapper (plus-x 1) [1 2 3]))
; Evaluation aborted.

user> (eval (mapper (fn [x] (+ 1 x)) [1 2 3]))
(2 3 4)


On Thu, Apr 14, 2011 at 10:17 AM, Mark Rathwell wrote:

>
> I think it has to do with partial's use of apply, but you would need
> someone smarter than me to tell you for sure ;)
>
>
> On Thu, Apr 14, 2011 at 9:58 AM, David McNeil wrote:
>
>> Mark - Thanks. I am able to permute it to make it work. However, I
>> cannot explain why the original code fails.
>>
>> -David
>>
>> --
>> 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 be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Weening myself off of global state - what's the idiomatic way to solve this?

2011-04-14 Thread jweiss
I'd start by making functions that take arguments.  For instance (defn
draw-ball [ball] ...)


On Apr 13, 1:22 pm, Brandon Ferguson  wrote:
> I'm not sure if this is the place to ask this but I've been struggling
> with a few things in the world of Clojure. I've been using Processing
> to learn Clojure (since I'm somewhat familiar with Processing) but the
> tough part has been dealing with things like x, y positions of objects
> without keeping some global state (I'm not sure if it's even
> possible).
>
> The code in question is:https://gist.github.com/887256
>
> All this does is bounce a ball around a screen, for every frame
> Processing calls draw which moves the ball one frame. Since I'm not
> the one driving the loop I ended up using atoms to update some bits of
> global state but that feels really dirty.
>
> If I could drive the frames it would be easy to use recur or some
> other bit of state passing as I render each successive frame. I've
> considered using sequences and passing a frame number (which would be
> stored in a global as well) in but then it'd (I assume) have to run
> through every number up to that the one I passed it. Seems like
> performance would degrade the longer it ran. There's also this idea
> rattling around in my head where I'd just rewrite the function
> everytime with the new state - but seems like you couldn't scale that
> to multiple balls bouncing around (which is the next step) - and God
> knows what, if any, performance implications that would have.
>
> So I'm not sure where that leaves me - learning functional stuff can
> be wonderfully mind breaking but sometimes I feel like I don't even
> have the tools in my head to work some things out. Is there some
> technique I'm missing for dealing with state between successive calls
> of a function?
>
> How would you solve something like this?
> -Brandon

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: [ANN] Tikkba v.0.1 a Clojure library for the creation and the dynamic modification of SVG documents

2011-04-14 Thread David Nolen
This is great!

On Thu, Apr 14, 2011 at 6:23 AM, Pierre Allix <
pierre.allix.w...@googlemail.com> wrote:

> Hello,
>
> I would like to announce the version 0.1 of the Tikkba library, a
> library for the creation and the dynamic modification of SVG
> documents.
>
> I would be really happy with any feedbacks and comments, on the code
> or the architecture.
>
> While the library is not complete it is already extremely usable and
> useful.
>
>
> From the README file:
>
> Tikkba is a Clojure library for the creation and the dynamic
> modification of SVG documents. It wraps the Apache Batik library and
> provides functions to create SVG images with the Clojure-based SVG DSL
> of the Analemma library.
>
> Batik is a Java-based toolkit for applications or applets that want to
> use images in the Scalable Vector Graphics (SVG) format for various
> purposes, such as display, generation or manipulation.
>
> http://xmlgraphics.apache.org/batik/index.html
>
> http://liebke.github.com/analemma/
>
>
> The library is available on GitHub:
>
> https://github.com/pallix/tikkba
>
> and on Clojars:
>
> http://clojars.org/tikkba
>
> This library is being developed as part of the Carneades project:
>
> http://carneades.berlios.de/
>
> --
> 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 be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

eval'ing records

2011-04-14 Thread David McNeil
I have learned that instances of records do not eval to themselves.
This seems inconsistent to me. I am curious if this is intentional or
if it is a gap in the current record implementation in Clojure.

Thanks.
-David



(defn eval-type [x]
  (class (eval x)))

;; instances of structural types evaluate to themselves

(eval-type {:a 100})
;; -> clojure.lang.PersistentArrayMap

(eval-type [100])
;; -> clojure.lang.PersistentVector

;; instances of java objects evaluate to themselves

(eval-type "hello")
;; -> java.lang.String

(eval-type (java.util.Date.))
;; -> java.util.Date

(eval-type (java.util.Locale. "en" "US"))
;; -> java.util.Locale

;; but instances of records...

(defrecord Foo [a])

(eval-type (Foo. 100))
;; -> clojure.lang.PersistentArrayMap

;; .. evaluate to maps not instances of the record class?

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Efficient Predicate Dispatch [was ANN: Logos v0.6]

2011-04-14 Thread David Nolen
When things begin to get recursive you may be on the right track :D

Initially I was going to implement Nominal Logic Programming for Logos a la
William Byrd's dissertation, but I realized that his implementation requires
pattern matching. All the pattern matching libs I've seen thus far for
Clojure are too naive and too slow. Even more importantly pattern matching
is subsumed by predicate dispatch (CiteSeerX — Efficient Predicate
Dispatching
).

Rich Hickey mentioned many moons ago that he'd like to see a predicate
dispatch implementation for Clojure that didn't have the kind of hardwiring
found in the Chambers/Chen paper. He suggested investigating Datalog. After
much reading, I've decided that a runtime in-memory Datalog that handles
dispatching is going to be too slow for many useful scenarios (an efficient
Datalog based on Binary Decision Diagrams might be possible, but this is an
incredibly complex undertaking in itself, meh).

What we want is Standard MLs efficient compilation from decision diagrams to
switch statements (CiteSeerX — Optimizing Pattern
Matching).
However Standard ML (Haskell, OCaml, Scala as well) pattern-matching has
issues with order among other things (Programming in Standard
ML
).

What if we allow a logic engine to drive the compilation of the decision
diagram? This would be done by users mapping logic predicates to Clojure
predicate functions. Relationships between predicates can be added to the
logic engine allowing compilation to produce a very efficient decision
diagram. Nothing is hard coded, everything is driven by the kinds of
predicates and relationships between predicates that a user actually cares
about.

All this is to say that this means Logos needs the ability to load database
of facts, index those facts, and to accept new facts and relationships and
update accordingly. So this going to happen sooner rather then later.

I welcome any feedback from anyone who has thoughts on this approach to
implementing predicate dispatch efficiently!

Some thoughts on what this might look like is evolving here,
https://github.com/swannodette/match/wiki/Crazy-Ideas.

David

On Mon, Apr 11, 2011 at 3:08 PM, David Nolen  wrote:

> On Mon, Apr 11, 2011 at 2:01 PM, Vagif Verdi wrote:
>
>> Can it be used as an inference (rule) engine ?
>
>
> If you mean in the same way that you can build inference (rule) engines in
> Prolog - I don't see why not.
>
> However there is a bit of work to be done in order to make building
> efficient rule engines easier:
>
> * Be able to load a database (aka Clojure collection) of facts
> * Indexing of facts
> * Intelligently use indexed facts
>
> Currently I'm a bit more interested in exploring type inference (via
> nominal logic) so I'm not sure when exactly I'll get to these, tho I'll
> gladly take patches from people who want such features sooner rather than
> later :)
>
> David
>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: partial vs anonymous function?

2011-04-14 Thread Ken Wesson
On Thu, Apr 14, 2011 at 10:42 AM, Mark Rathwell  wrote:
>
> Actually, that doesn't seem to be the case, seems to have something to do
> with the closure affecting macro expansion, but again, need someone smarter
> to explain:
> user> (defn plus-x [x] (fn [y] (+ x y)))
> #'user/plus-x
> user> (eval (mapper (plus-x 1) [1 2 3]))
> ; Evaluation aborted.
> user> (eval (mapper (fn [x] (+ 1 x)) [1 2 3]))
> (2 3 4)

This is that weird bug/glitch/unsupported feature when an actual
function object (as opposed to a symbol referring to a local or a var
holding one) is eval'd. It seems that this works for non-closure fns
but fails when the fn closes over a value from its context. I assume
that eval of sexps with embedded function objects is not supported,
and that it works even for some function objects is more or less
accidental.

Embed the quoted function code, e.g. (mapper `(partial + ~x) ...)
rather than (mapper (partial + x) ...), or make a defn out of the
function and call it by name, e.g. (defn foo ...) ... (mapper foo
...).

Note that the former only works if x is something eval'able itself,
such as a number or a string or something similar, or a Clojure data
structure composed ultimately of same. If it is, or contains, some
other kind of Java object, you've got trouble again.

The problem with generic objects in eval is partially solvable:

1. If the sexp is constructed and then eval'd in the same session, a
constant reference to the object could simply be embedded in the
generated bytecode as a class constant of reference type.

2. If the code is being AOT compiled, and the object implements
Serializable, it could be serialized as some sort of resource, and the
AOT output could include a static initializer that loads that resource
and stores a reference in a class constant.

Currently, neither of the above is implemented. The case that would
remain if they were would be:

3. The code is being AOT compiled and the object does not implement
Serializable.

That case subdivides as follows:

3a. The object cannot even in principle usefully be preserved across
sessions or moved between JVMs, e.g. because it contains file handles
or other native resources (ex.: FileInputStream).

3b. The object can in principle be preserved, and fairly simply; case
2 above would Just Work(tm) if you just slapped "implements
Serializable" on the thing's class.

3c. The object can in principle be preserved, but not simply; e.g.
WeakReference, which hooks into the GC; you'd need to first preserve
the referent (if not null) and then a) load that and then b) construct
a WeakReference to it in the target JVM instance. ReferenceQueues add
more complication in that instance. 3c could reduce to 3b in the case
of a proper writeObject/readResolve method pair.

However, for Clojure to support case 3b requires some kind of heap
introspection capability (likely involving native code) that allows it
to directly copy the bytes of an object's in-memory representation.
That prevents making 3c work via the writeObject/readResolve method,
and would presumably not work in sandboxed JVMs. I doubt it's
particularly practical to attempt to support case 3, just 1 and 2.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Clojure interest in Zurich

2011-04-14 Thread Brian Marick
I'll be working in Zurich from 16 May through 3 June. Anyone interested in 
weekend or evening Clojure hacking? Clojure user's group?

-
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, www.twitter.com/marick

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread Armando Blancas
I wonder in which cases this code is a good choice: a function that
returns uneval'ed code. Something about macros not being an option
where a function is expected, or a kind of lazy eval? Will this be any
better or worse: (defn m [f s] (fn [] (map f s))) then doing (foo)
instead of (eval foo)?

On Apr 14, 6:46 am, David McNeil  wrote:
> I am puzzled by the results below. Can anyone explain the difference
> in behavior?
>
> -David
>
> 
>
> (defn mapper [f stream]
>   `(map ~f ~stream))
>
> (eval (mapper #(+ 1 %) [10 11 12]))
> ;; -> (11 12 13)
>
> (eval (mapper (partial + 1) [10 11 12]))
> ;; -> No matching ctor found for class clojure.core$partial...

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread David McNeil
> Will this be any
> better or worse: (defn m [f s] (fn [] (map f s))) then doing (foo)
> instead of (eval foo)?

Armando - Generally I agree that the "m" function you defined is
clearly preferred over a solution based on eval. However, this is a
special case (too much to relate) where I needed a function to produce
an s-expression.

Thanks.
-David

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Weening myself off of global state - what's the idiomatic way to solve this?

2011-04-14 Thread Ken Wesson
On Wed, Apr 13, 2011 at 1:22 PM, Brandon Ferguson  wrote:
> I'm not sure if this is the place to ask this but I've been struggling
> with a few things in the world of Clojure. I've been using Processing
> to learn Clojure (since I'm somewhat familiar with Processing) but the
> tough part has been dealing with things like x, y positions of objects
> without keeping some global state (I'm not sure if it's even
> possible).

If you're currently using atoms, you already have a function to
compute the new position from the old, say, next-position, which you
use with something like (swap! ball-pos next-position).

Now consider this: (iterate next-position initial-ball-pos). That
evaluates to an (infinite!) sequence of ball positions. You could have
an animation loop step along this sequence, render a frame, wait,
step, render, wait, etc. until the ESC key is hit (or whatever).

For multiple balls that might interact with one another, a given
ball's next position becomes a function of the other ball positions
and not just its own. So you end up with:

(iterate next-world-state initial-world-state)

with world states being e.g. maps of ball-IDs to ball-positions or
something. Obviously, other kinds of changeable world state can be
included, too, e.g. Pong paddle positions, or the locations and amount
of damage taken by Arkanoid bricks.

This works until you get interactive (e.g. letting a human player
control a paddle or something). At that point, iterate becomes a bit
icky because the function becomes impure (as it polls the input
devices).

Then you probably just want two components:

1. A Swing GUI that captures mouse and keyboard events in the game's
JPanel as well as rendering the frames there.
2. A game loop.

The simplest case uses the Swing EDT as the game loop, with a Timer
triggering game updates. But that requires mutable state for the game
state to persist between Timer events.

The other case keeps most of the game state immutable, but requires a
bit of mutability to pass input to the game from the GUI:

1. The Swing event handlers post input messages to a
LinkedBlockingQueue, or update atoms or refs holding the current
position of the mouse and state (down or up) of relevant mouse buttons
and keyboard keys.

2. The game loop runs in its own thread and looks something like this:

(loop [foo bar other game state variables]
  ...
(recur new-foo new-bar new-other ...)...)

The game checks the input state, or drains the LinkedBlockingQueue, or
whatever when it comes around to updating the player's position.

One way to do it is just to have a set of game world objects:

(loop [time (System/currentTimeMillis)
   world (hash-set (cons (new-player) (generate-initial-world-state)))]
  (let [world (map (partial update-position world) world)
new-objects (mapcat new-things world)
damages (reduce (partial merge-with +) {} (map do-damage world))
world (concat
new-objects
(remove dead?
  (map (partial apply-damages damages) world)))]
(SwingUtilities/invokeAndWait
  (fn []
(let [g (get-the-jpanel's-double-buffer-graphics)]
  (doseq [obj world] (draw-on! obj g)))
(flip-the-jpanel's-double-buffer!)))
(if (some is-player? world)
  (let [elapsed (- (System/currentTimeMillis) time)
sl (- *ms-per-frame* elapsed)]
(if (> sl 0) (Thread/sleep sl))
(recur (System/currentTimeMillis) world))
  world)))

Here, new-player generates a new player object and
generate-initial-world-state generates a seq of other objects for the
initial world-state. The update-position function takes the world and
a game object and runs the latter's ai, returning a new game object
representing the old one's changed position (and possibly other state
changes). The world is passed in so that collision checks can be done
when needed.

The new-things function allows some game objects to potentially
generate more (e.g. shooting projectiles); it can return nil if the
object hasn't spawned anything, or a seq of new things. For instance,
if the player shoots a rocket, it may return [(new-rocket player-x
player-y player-dx player-dy)]; when the rocket hits something and
explodes, it may itself return (repeatedly *num-shards*
#(generate-shrapnel rocket-x rocket-y)).

The do-damage function takes a game object and returns a map of zero
or more other game objects that are damaged by that game object. This
usually involves collision, which is handled in update-position, so
update-position needs to cache the damage information for do-damage to
retrieve. For instance, that rocket's update-position can discover
that it has collided with something and set the rocket's health to
zero as well as store a map of things within the blast radius and the
damage they should take. The new-things function sees the rocket's
health at zero and spawns decorative shrapnel objects, since it just
exploded; these will draw themselves an

Re: Clojure interest in Zurich

2011-04-14 Thread Nick Zbinden
Hi im not from zurich but I life near enough. There is no clojure user
group (sadly). I acctualy don't know of anybody else using clojure in
Switzerland.

There is however a new "Lisp and Stuff"-Meeting more or less every
month. It get hosted by a Startup that uses CL. The first to Meetings
were quite intressting.
http://zslug.wordpress.com/

Would be great if there were enough people for a actual clojure user
group.






On Apr 14, 6:06 pm, Brian Marick  wrote:
> I'll be working in Zurich from 16 May through 3 June. Anyone interested in 
> weekend or evening Clojure hacking? Clojure user's group?
>
> -
> Brian Marick, Artisanal Labrador
> Contract programming in Ruby and Clojure
> Occasional consulting on Agilewww.exampler.com,www.twitter.com/marick

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread Armando Blancas
I copy that. FWIW, I'm not in the eval-is-evil camp, so didn't have an
opinion one way or the other. I've seen code like that in posted
samples and wanted to know if that's a technique useful to have
around.

On Apr 14, 9:34 am, David McNeil  wrote:
> > Will this be any
> > better or worse: (defn m [f s] (fn [] (map f s))) then doing (foo)
> > instead of (eval foo)?
>
> Armando - Generally I agree that the "m" function you defined is
> clearly preferred over a solution based on eval. However, this is a
> special case (too much to relate) where I needed a function to produce
> an s-expression.
>
> Thanks.
> -David

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread Ken Wesson
On Thu, Apr 14, 2011 at 12:26 PM, Armando Blancas
 wrote:
> I wonder in which cases this code is a good choice: a function that
> returns uneval'ed code. Something about macros not being an option
> where a function is expected, or a kind of lazy eval? Will this be any
> better or worse: (defn m [f s] (fn [] (map f s))) then doing (foo)
> instead of (eval foo)?

It is quite common to write functions that return sexps to simplify
writing macros; macros can call other functions to build parts of
their output.

The OP may also have been debugging a macro and reduced his problem to
a simple, reproducible example using such a function to generate the
problem part of the macro output and eval to trigger it.

There are also cases where eval is needed at run-time, such as dynamic
on-the-fly runtime function creation. Some of the most sophisticated
optimizations involve exploiting patterns in the input not discovered
until runtime, or compiling on the fly a version of an algorithm
specialized to a particular input; e.g. if you're going to try to
factor a big number, you might have code actually generate and compile
code to search for a factor for *that specific* number and then
execute it, and it might run faster than if that number were an
in-theory variable in the code, especially if the algorithm can be
changed depending on properties of the number.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: partial vs anonymous function?

2011-04-14 Thread Armando Blancas
Interesting. Thanks for your response.

On Apr 14, 10:06 am, Ken Wesson  wrote:
> On Thu, Apr 14, 2011 at 12:26 PM, Armando Blancas
>
>  wrote:
> > I wonder in which cases this code is a good choice: a function that
> > returns uneval'ed code. Something about macros not being an option
> > where a function is expected, or a kind of lazy eval? Will this be any
> > better or worse: (defn m [f s] (fn [] (map f s))) then doing (foo)
> > instead of (eval foo)?
>
> It is quite common to write functions that return sexps to simplify
> writing macros; macros can call other functions to build parts of
> their output.
>
> The OP may also have been debugging a macro and reduced his problem to
> a simple, reproducible example using such a function to generate the
> problem part of the macro output and eval to trigger it.
>
> There are also cases where eval is needed at run-time, such as dynamic
> on-the-fly runtime function creation. Some of the most sophisticated
> optimizations involve exploiting patterns in the input not discovered
> until runtime, or compiling on the fly a version of an algorithm
> specialized to a particular input; e.g. if you're going to try to
> factor a big number, you might have code actually generate and compile
> code to search for a factor for *that specific* number and then
> execute it, and it might run faster than if that number were an
> in-theory variable in the code, especially if the algorithm can be
> changed depending on properties of the number.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread mark skilbeck
Still doesn't work for me. Same error as Alfredo.

On Thu, Apr 14, 2011 at 1:26 PM, msappler  wrote:
> Hmm I updated the natives-mac.jar.
> But dont know this error I dont have a mac..
>
> On 14 Apr., 14:16, Walter Chang  wrote:
>> failed to run on mbp osx 10.6.7 (java version "1.6.0_24").  here is the
>> stack trace:
>>
>> java.lang.NullPointerException
>> at
>> org.lwjgl.opengl.MacOSXContextImplementation.setSwapInterval(MacOSXContextImplementation.java:121)
>> at org.lwjgl.opengl.Context.setSwapInterval(Context.java:231)
>> at org.lwjgl.opengl.Display.setSwapInterval(Display.java:993)
>> at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:1005)
>> at org.newdawn.slick.GameContainer.setVSync(GameContainer.java:805)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:90)
>> at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
>> at game.start$fn__3815$start__3816.invoke(start.clj:33)
>> at game.start$_main.invoke(start.clj:37)
>> at clojure.lang.AFn.applyToHelper(AFn.java:159)
>> at clojure.lang.AFn.applyTo(AFn.java:151)
>> at game.start.main(Unknown Source)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at com.sun.javaws.Launcher.executeApplication(Launcher.java:1909)
>> at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
>> at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
>> at com.sun.javaws.Launcher.run(Launcher.java:138)
>> at java.lang.Thread.run(Thread.java:680)
>>
>>
>>
>> On Thu, Apr 14, 2011 at 8:09 PM, msappler  wrote:
>> > Thanks. That was a last minute change of the jnlp file location.
>>
>> > Should work now.
>>
>> > On 14 Apr., 13:39, Alfredo  wrote:
>> > > Very cool!
>> > > But how to play with it? With Chrome, it downloads the .jnlp file but
>> > > if I click on it, an error raises:
>>
>> > > com.sun.deploy.net.FailedDownloadException: Unable to load resource:
>> >http://sappler.ls4.allbytes.de/cdq/cdq.jnlp
>> > >         at
>> > > com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
>> > > 1372)
>> > >         at
>> > > com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
>> > > 1525)
>> > >         at
>> > > com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
>> > > 1503)
>> > >         at
>>
>> > com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
>> > > 1609)
>> > >         at
>>
>> > com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
>> > > 1534)
>> > >         at
>> > com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
>> > > 217)
>> > >         at
>> > com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
>> > > 201)
>> > >         at
>> > com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:477)
>> > >         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:256)
>> > >         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:207)
>> > >         at com.sun.javaws.Launcher.launch(Launcher.java:124)
>> > >         at com.sun.javaws.Main.launchApp(Main.java:446)
>> > >         at com.sun.javaws.Main.continueInSecureThread(Main.java:278)
>> > >         at com.sun.javaws.Main$1.run(Main.java:116)
>> > >         at java.lang.Thread.run(Thread.java:680)
>>
>> > --
>> > 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 be patient with
>> > your first post.
>> > To unsubscribe from this group, send email to
>> > clojure+unsubscr...@googlegroups.com
>> > For more options, visit this group at
>> >http://groups.google.com/group/clojure?hl=en
>>
>> --
>> ...__o
>> ...\<,
>> ( )/ ( )...
>
> --
> 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 be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To u

Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread Timothy Baldridge
On Thu, Apr 14, 2011 at 2:03 PM, mark skilbeck
 wrote:
> Still doesn't work for me. Same error as Alfredo.

Worked great for me with Win 7, FF4

Want to highlight anything you did in the game? I'm interested in any
use of agents, etc that you used.

Timothy
-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread Joop Kiefte
Doesn't work for me (Ubuntu x86)

2011/4/14 Timothy Baldridge :
> On Thu, Apr 14, 2011 at 2:03 PM, mark skilbeck
>  wrote:
>> Still doesn't work for me. Same error as Alfredo.
>
> Worked great for me with Win 7, FF4
>
> Want to highlight anything you did in the game? I'm interested in any
> use of agents, etc that you used.
>
> Timothy
> --
> “One of the main causes of the fall of the Roman Empire was
> that–lacking zero–they had no way to indicate successful termination
> of their C programs.”
> (Robert Firth)
>
> --
> 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 be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread Alan
Similar error for me, on Ubuntu. Exception and "wrapped exception"
follow. Looks like you may need permissions set better? 403 is
Forbidden.

com.sun.deploy.net.FailedDownloadException: Unable to load resource:
http://sappler.ls4.allbytes.de/resatori/webstart/cdq.jnlp
at
com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
1372)
at
com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
1525)
at
com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
1503)
at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
1609)
at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
1534)
at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
217)
at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
201)
at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:469)
at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:248)
at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:199)
at com.sun.javaws.Launcher.launch(Launcher.java:116)
at com.sun.javaws.Main.launchApp(Main.java:416)
at com.sun.javaws.Main.continueInSecureThread(Main.java:248)
at com.sun.javaws.Main$1.run(Main.java:110)
at java.lang.Thread.run(Thread.java:662)


java.io.IOException: Server returned HTTP response code: 403 for URL:
http://sappler.ls4.allbytes.de/resatori/webstart/cdq.jnlp
at sun.reflect.GeneratedConstructorAccessor1.newInstance(Unknown
Source)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at sun.net.www.protocol.http.HttpURLConnection
$6.run(HttpURLConnection.java:1491)
at java.security.AccessController.doPrivileged(Native Method)
at
sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:
1485)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:
1139)
at
com.sun.deploy.net.BasicHttpRequest.doRequest(BasicHttpRequest.java:
229)
at
com.sun.deploy.net.BasicHttpRequest.doRequest(BasicHttpRequest.java:
113)
at
com.sun.deploy.net.BasicHttpRequest.doGetRequest(BasicHttpRequest.java:
78)
at
com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
1182)
at
com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
1525)
at
com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
1503)
at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
1609)
at
com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
1534)
at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
217)
at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
201)
at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:469)
at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:248)
at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:199)
at com.sun.javaws.Launcher.launch(Launcher.java:116)
at com.sun.javaws.Main.launchApp(Main.java:416)
at com.sun.javaws.Main.continueInSecureThread(Main.java:248)
at com.sun.javaws.Main$1.run(Main.java:110)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: Server returned HTTP response code:
403 for URL: http://sappler.ls4.allbytes.de/resatori/webstart/cdq.jnlp
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:
1436)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:
379)
at
com.sun.deploy.net.BasicHttpRequest.doRequest(BasicHttpRequest.java:
190)
... 17 more


On Apr 14, 12:03 pm, mark skilbeck 
wrote:
> Still doesn't work for me. Same error as Alfredo.
>
>
>
>
>
>
>
> On Thu, Apr 14, 2011 at 1:26 PM, msappler  wrote:
> > Hmm I updated the natives-mac.jar.
> > But dont know this error I dont have a mac..
>
> > On 14 Apr., 14:16, Walter Chang  wrote:
> >> failed to run on mbp osx 10.6.7 (java version "1.6.0_24").  here is the
> >> stack trace:
>
> >> java.lang.NullPointerException
> >> at
> >> org.lwjgl.opengl.MacOSXContextImplementation.setSwapInterval(MacOSXContextI
> >>  mplementation.java:121)
> >> at org.lwjgl.opengl.Context.setSwapInterval(Context.java:231)
> >> at org.lwjgl.opengl.Display.setSwapInterval(Display.java:993)
> >> at org.lwjgl.opengl.Display.setVSyncEnabled(Display.java:1005)
> >> at org.newdawn.slick.GameContainer.setVSync(GameContainer.java:805)
> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
> >>  9)
> >> at
> >> sun.reflect.DelegatingMethodAccessorImpl.invok

Re: eval'ing records

2011-04-14 Thread David McNeil
> I remember reading about it in the Joy of Clojure. It may be fixed in the
> future versions of Clojure.


Ivan - Thanks for the response. I checked Joy of Clojure and I see a
reference at the top of page 191 to the fact that records cannot be
printed and then eval'd. I was aware of this, however the issue I
identified in this discussion is that record instances _themselves_ do
not eval to themselves. This is a bit different than printing them and
eval'ing them.

-David

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure interest in Zurich

2011-04-14 Thread Ivan Koblik
Hello,

I'll be the third guy from Switzerland :) I live in Geneva... Any Clojurians
from Suisse romande?

Cheers,
Ivan.


On 14 April 2011 18:39, Nick Zbinden  wrote:

> Hi im not from zurich but I life near enough. There is no clojure user
> group (sadly). I acctualy don't know of anybody else using clojure in
> Switzerland.
>
> There is however a new "Lisp and Stuff"-Meeting more or less every
> month. It get hosted by a Startup that uses CL. The first to Meetings
> were quite intressting.
> http://zslug.wordpress.com/
>
> Would be great if there were enough people for a actual clojure user
> group.
>
>
>
>
>
>
> On Apr 14, 6:06 pm, Brian Marick  wrote:
> > I'll be working in Zurich from 16 May through 3 June. Anyone interested
> in weekend or evening Clojure hacking? Clojure user's group?
> >
> > -
> > Brian Marick, Artisanal Labrador
> > Contract programming in Ruby and Clojure
> > Occasional consulting on Agilewww.exampler.com,www.twitter.com/marick
>
> --
> 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 be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: eval'ing records

2011-04-14 Thread Ivan Koblik
David,

Sorry, I misunderstood your question at first. There was actually a
discussion on it a couple of days ago:
http://groups.google.com/group/clojure/browse_thread/thread/abb87a73330fdc01

Cheers,
Ivan.


On 14 April 2011 22:07, David McNeil  wrote:

> > I remember reading about it in the Joy of Clojure. It may be fixed in the
> > future versions of Clojure.
>
>
> Ivan - Thanks for the response. I checked Joy of Clojure and I see a
> reference at the top of page 191 to the fact that records cannot be
> printed and then eval'd. I was aware of this, however the issue I
> identified in this discussion is that record instances _themselves_ do
> not eval to themselves. This is a bit different than printing them and
> eval'ing them.
>
> -David
>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure group in DFW area

2011-04-14 Thread Sean Allen
I dont live in the DFW area but come down 1 to 2 times a year to see family,
so I'm interested in what you cook up.

On Thu, Apr 14, 2011 at 10:33 AM, Alex Robbins
 wrote:
> Glad to hear from you. I live and work a little south of the
> intersection of 121 and the Dallas North Tollway, so any meeting place
> along the DNT would be great for me (Addison included).
>
> Hopefully there are more than two clojure users in Dallas.
>
> On Wed, Apr 13, 2011 at 3:44 PM, J.R. Garcia  wrote:
>> I live in Fort Worth and work in Addison. I'd love to get together
>> sometime. If there is any interest in getting a user group together, I
>> have the perfect place to host it.
>>
>> On Mar 10, 8:28 am, Alex Robbins 
>> wrote:
>>> Anyone else in the north Dallas area using/interested in Clojure? I'd
>>> love to get together.
>>>
>>> Alex
>>
>> --
>> 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 be patient with your 
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
> --
> 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 be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure interest in Zurich

2011-04-14 Thread Max Penet
Hi,

Hi,

I live in Geneva too.

I recently found out (thanks to Christophe Grand) there are a few
Clojure users around here.

Max

On Apr 14, 10:07 pm, Ivan Koblik  wrote:
> Hello,
>
> I'll be the third guy from Switzerland :) I live in Geneva... Any Clojurians
> from Suisse romande?
>
> Cheers,
> Ivan.
>
> On 14 April 2011 18:39, Nick Zbinden  wrote:
>
>
>
>
>
>
>
> > Hi im not from zurich but I life near enough. There is no clojure user
> > group (sadly). I acctualy don't know of anybody else using clojure in
> > Switzerland.
>
> > There is however a new "Lisp and Stuff"-Meeting more or less every
> > month. It get hosted by a Startup that uses CL. The first to Meetings
> > were quite intressting.
> >http://zslug.wordpress.com/
>
> > Would be great if there were enough people for a actual clojure user
> > group.
>
> > On Apr 14, 6:06 pm, Brian Marick  wrote:
> > > I'll be working in Zurich from 16 May through 3 June. Anyone interested
> > in weekend or evening Clojure hacking? Clojure user's group?
>
> > > -
> > > Brian Marick, Artisanal Labrador
> > > Contract programming in Ruby and Clojure
> > > Occasional consulting on Agilewww.exampler.com,www.twitter.com/marick
>
> > --
> > 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 be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Agent action queuing is asynchronous.

2011-04-14 Thread André Caron
I've posted this question on StackOverflow[1], but it might be a bit
technical, so I'll ask it on the mailing list where I might get more
precise expertise on Clojure.

[1]: http://stackoverflow.com/questions/5669084/clojures-send-is-asynchronous

I'm writing a simple networking framework for Clojure using Java's
"New I/O" package. It manages a pool of "selector agents", each of
which holds a `java.nio.channels.Selector`.

I defined a `dispatch` action to for the selector agent. This action
blocks on a call to `Selector.select()`. When that returns, the
selector agent iterates over the selected keys and performs I/O. When
I/O is completed, the selector agent send's itself the dispatch action
using `send-off`, effectively looping on calls to `Selector.select()`.

When I want to add a new channel or change a channel's interest ops, I
send the selector agent the appropriate action and then unblock the
selector (it's blocked on `Selector.select()`). This ensures that
`(send-off selector-agent dispatch)` in the selector agent is executed
after `(send selector-agent add-channel channel)` in whatever agent
changed the `SelectionKey.inrestOps()`.

I thought this would be bullet-proof since the call to `send-off` is
performed before the selector waking up, and thus, before the selector
agent send itself the `dispatch` action.  However, this yields
inconsistent behavior.  Sometimes, the `dispatch` action occurs first
and sometimes it doesn't.  My understanding is that `send` and `send-
off` are themselves asynchronous in that they return before the agent
action being sent is actually queued in the agent's action backlog.

Is this correct?

This is normally not an issue; the action dispatch from different
agents/threads to the same agent is usually unpredictable and a non-
issue.  In this case, the real culprit is that I need to block on
`Selector.select()`.  One obvious workaround is to put a timeout on
the sleep operation, so that I don't need to manually unblock the
selector.  This puts me in the classic polling lose/lose situation,
where I need to decide on the polling frequency: too few polls and
suffer latency, too many polls and slow down the whole machinery.

Does anyone have any better ideas, or can `send`/`send-off` be made to
actually queue the actions synchronously such that they are executed
int the *exact* order they are sent?

Thanks,

André Caron

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-14 Thread Avram

Dear list,

I have working code for 2 inputs, but I am trying to write an
idiomatic version, where the result is that a function named "read-
files-into-memory" takes a variable number of file names and parses
the json.  My code works well until I try to wrap my stand alone call
to map into my "read-files-into-memory" function.

My stand alone call that works correctly is: (map #(read-json-filename
%1) fnames)
However, putting this into a wrapper function doesn't appear to give
each item piecemeal and results in the java.io.FileReader complaint of
"No matching ctor" for the underlying call.

Here are the details:

;; paths to 2 little testing files
proj=> fnames
["/home/avram/devel/scratch/a.json" "/home/avram/devel/scratch/
b.json"]

;; function that can read one file
proj=> (defn read-json-filename
  [ filename ]
  (clojure.contrib.json/read-json (FileReader. filename )))
#'proj/read-json-filename

;; Proof of concept: it works when passed a vector of filenames
proj=> (map #(read-json-filename %1) fnames)
({:metric1 {:section "a1", :runid "run-a", :value "123"}, :metric2
{:section "a2", :runid "run-a", :value "123.45"}, :metric3 {:section
"a3", :runid "run-a", :value "[1,2,3,4,5,6,7,8,9]"}} {:metric1
{:section "b1", :runid "run-b", :value "456"}, :metric2 {:section
"b2", :runid "run-b", :value "789.1011"}, :metric3 {:section
"b3", :runid "run-b", :value "[11,21,31,41,51,61,71,81,91]"}})

;; Intended to be a wrapper that calls map like above..
proj=> (defn read-files-into-memory
  [ & filenames ]
  (print filenames)
  (map #(read-json-filename %1) filenames))
#'proj/read-files-into-memory

;; …but it doesn't work
proj=> (read-files-into-memory fnames)
java.lang.IllegalArgumentException: No matching ctor found for class
java.io.FileReader

I thought the wrapper version was identical to the stand alone call,
but apparently not.


What changes are needed in "read-files-into-memory" ?


Many thanks,
Avram

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-14 Thread Joost
(defn read-files-into-memory
  [ & filenames ]
  (print filenames)
  (map #(read-json-filename %1) filenames))

The [& filenames] argument spec turns all the arguments given into a
sequence. You're not passing the filenames as separate arguments, but
as a vector, so you either have to change that:

(read-files-into-memory "name1" "name2" ..)

or you need to use apply:

(apply read-files-into-memory fnames)

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: call to idiomatic loop works as stand alone but not when wrapped in my function

2011-04-14 Thread Avram
Yes, I am missing a way to turn the [& filenames] into something like
"name1" "name2" …

How might this be done?  (I am not certain what "type" this would be,
a stringified version of each item in the sequence, not a sequence
itself! )

(defn read-files-into-memory
  [ & filenames ]
  (print filenames)
  (map #(read-json-filename %1) filenames))


Many thanks,
Avram

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Fun: Write the fastest code that flattens nested maps of a particular type

2011-04-14 Thread Jason Wolfe
Here are some potentially interesting observations.  First, as similar
lazy and eager versions as I could come up with:

(defn flatten-maps-lazy [coll]
  (lazy-seq
(when-let [s (seq coll)]
  (let [m (first s)]
(cons (dissoc m :c)
  (flatten-maps-lazy
(concat (get m :c) (rest s

(defn flatten-maps-eager [coll]
  (loop [r nil s coll]
(if-let [s (seq s)]
  (let [m (first s)]
(recur
  (cons (dissoc m :c) r)
  (concat (get m :c) (rest s
  r)))

(defonce d (data 200))


Some results:

user> (dotimes [_ 10] (time (let [s (flatten-maps-lazy bd)] (println
[(first s) (apply + (map (comp count keys) s))]
...
"Elapsed time: 751.97 msecs"

user> (dotimes [_ 10] (time (let [s (flatten-maps-lazy bd)] (println
[(apply + (map (comp count keys) s)) (first s)]
...
"Elapsed time: 1211.047 msecs"

user> (dotimes [_ 10] (time (let [s (flatten-maps-eager bd)] (println
[(first s) (apply + (map (comp count keys) s))]
...
"Elapsed time: 986.66 msecs"

user> (dotimes [_ 10] (time (let [s (flatten-maps-eager bd)] (println
[(apply + (map (comp count keys) s)) (first s)]
...
"Elapsed time: 993.345 msecs"

So, the lazy version is faster when the compiler can do fine-grained
locals clearing, because then presumably the JIT figures out that the
sequence never has to be actually constructed in memory (??).  The
eager version is faster when you actually need the whole sequence
there.  The speed of the lazy version may also be partially due to
better memory locality.

I don't know if this actually explains your results, since I don't
know what the JIT can conclude about the result of your doall.  I
generally prefer something like the above, where it's clear exactly
how the output of the profiled function is consumed (and thus, what
code cannot be considered dead and eliminated by the JIT).

-Jason

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Is this a good idea? (merging let, cond and ->)

2011-04-14 Thread icemaze
I was developing this project of mine, which has an intricate business
logic, and I wrote a macro that makes programming this kind of stuff
more comfortable. It's called "ilet", which stands for "implicit let".
The name is probably no longer appropriate, since I added more
features to it, but I can't make up anything better right now.

I'd really appreciate it if you could dissuade (or persuade) me from
posting this to clojure-dev for inclusion in contrib. I need to know
if this could be useful to someone besides me.


Here's the rationale of the ilet macro. (Warning: the examples are
silly. See below for a real world example.)

We have "->" in Clojure because it lets you do dataflow-programming-
like manipulations. The first version of ilet was used in a similar
way, but it simply bound a symbol ($). It works like "->" but it's
more flexible, because you can put the value of the previous
expression wherever you want (e.g., see http://pastebin.com/g7k8wK4a).

This is nice, but it's often useful to bind symbols explicitly. Using
a "let" inside an "ilet" is clunky, so I added this capability inside
"ilet" itself. If you write [symbol] [expression], ilet interprets
that as an explicit binding (see http://pastebin.com/2VJ8D738).

Finally, I wanted to be able to interrupt this kind of calculations.
Unfortunately, Clojure doesn't provide any return-like constructs:
you'd need to use if's and cond's. So I added a new syntax to ilet:
"<" [condition] [expression]
where if [condition] is true, the value of the whole ilet expression
is just [expression] (see http://pastebin.com/np2M9kZr).


I hope my explanation was clear, in spite of my poor English.

This is the definition of the ilet macro: http://pastebin.com/nHLifsu3

And this is a real world example, straight from my repository:
http://pastebin.com/xGQT1c5h


Thank you all for your input!

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Agent action queuing is asynchronous.

2011-04-14 Thread André Caron
After further analysis, I don't think this is globally a good
strategy.

I looked into a solution with a "(ref (clojure.lang.PersistentQueue/
EMPTY))" in the selector agent.  The plan was to have be able to queue
"updates" to the schedule synchronously.  Half-way through the
implementation, I realized this is equivalent to by-passing the entire
agent system and still wouldn't work anyways.

Even *if* send/send-off were forced to queue synchronously, the wakeup
strategy isn't guaranteed to work.  There is still the possibility
that "Selector.wakeup()" will be executed after the "dispatch" action
has started, but before it calls "Selector.select()".  What would be
necessary is for the agent system to sort-of interrupt calls to
"dispatch" as soon as something else is sent to the agent.  Apart from
requiring the most insane hack ever, this solution would be nothing
close to elegant.

Basically, I can't block on "Selector.select()", so I have to poll.
Can't wait for JSR203 (http://www.jcp.org/en/jsr/detail?id=203) to be
approved as part of Java 7.  Maybe that API will be less of a
hassle...

By the way, this is all for an open source project.  I've got the
basic parts working, but it's still under heavy architectural
changes.  As soon as version "0.1" is decent, I'll push the repository
to GitHub and notify you guys.


Regards,

André Caron

On Apr 14, 5:58 pm, André Caron  wrote:
> I've posted this question on StackOverflow[1], but it might be a bit
> technical, so I'll ask it on the mailing list where I might get more
> precise expertise on Clojure.
>
> [1]:http://stackoverflow.com/questions/5669084/clojures-send-is-asynchronous
>
> I'm writing a simple networking framework for Clojure using Java's
> "New I/O" package. It manages a pool of "selector agents", each of
> which holds a `java.nio.channels.Selector`.
>
> I defined a `dispatch` action to for the selector agent. This action
> blocks on a call to `Selector.select()`. When that returns, the
> selector agent iterates over the selected keys and performs I/O. When
> I/O is completed, the selector agent send's itself the dispatch action
> using `send-off`, effectively looping on calls to `Selector.select()`.
>
> When I want to add a new channel or change a channel's interest ops, I
> send the selector agent the appropriate action and then unblock the
> selector (it's blocked on `Selector.select()`). This ensures that
> `(send-off selector-agent dispatch)` in the selector agent is executed
> after `(send selector-agent add-channel channel)` in whatever agent
> changed the `SelectionKey.inrestOps()`.
>
> I thought this would be bullet-proof since the call to `send-off` is
> performed before the selector waking up, and thus, before the selector
> agent send itself the `dispatch` action.  However, this yields
> inconsistent behavior.  Sometimes, the `dispatch` action occurs first
> and sometimes it doesn't.  My understanding is that `send` and `send-
> off` are themselves asynchronous in that they return before the agent
> action being sent is actually queued in the agent's action backlog.
>
> Is this correct?
>
> This is normally not an issue; the action dispatch from different
> agents/threads to the same agent is usually unpredictable and a non-
> issue.  In this case, the real culprit is that I need to block on
> `Selector.select()`.  One obvious workaround is to put a timeout on
> the sleep operation, so that I don't need to manually unblock the
> selector.  This puts me in the classic polling lose/lose situation,
> where I need to decide on the polling frequency: too few polls and
> suffer latency, too many polls and slow down the whole machinery.
>
> Does anyone have any better ideas, or can `send`/`send-off` be made to
> actually queue the actions synchronously such that they are executed
> int the *exact* order they are sent?
>
> Thanks,
>
> André Caron

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Adding key values in a list of maps

2011-04-14 Thread Bhinderwala, Shoeb
I am a beginner in Clojure.

I have a list of maps:

(def p '({:a 1 :b 2 :c 4}, {:a 2 :b 3 :c 5}, {:a 3 :b 4 :c 6}))

How do I add up all the :b values in the map? Result should be 9
(=2+3+4)

I know I should be using one of the higher level functions like apply,
reduce and combine it with a custom filter function. But not sure how to
write it.

-- Shoeb

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Adding key values in a list of maps

2011-04-14 Thread Andreas Kostler
(reduce + (map :b p))
Cheers
Andreas


On 15 April 2011 10:43, Bhinderwala, Shoeb wrote:

>  I am a beginner in Clojure.
>
> I have a list of maps:
>
> (def p '({:a 1 :b 2 :c 4}, {:a 2 :b 3 :c 5}, {:a 3 :b 4 :c 6}))
>
> How do I add up all the :b values in the map? Result should be 9 (=2+3+4)
>
> I know I should be using one of the higher level functions like apply,
> reduce and combine it with a custom filter function. But not sure how to
> write it.
>
> ***-- Shoeb*
>
>  --
> 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 be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en




-- 
**
Andreas Koestler, Software Engineer
Leica Geosystems Pty Ltd
270 Gladstone Road, Dutton Park QLD 4102
Main: +61 7 3891 9772 Direct: +61 7 3117 8808
Fax: +61 7 3891 9336
Email: andreas.koest...@leica-geosystems.com

www.leica-geosystems.com*

when it has to be right, Leica Geosystems

Please  consider the environment before printing this email.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Adding key values in a list of maps

2011-04-14 Thread Andreas Kostler
Or: (reduce #(+ %1 (:b %2)) 0 p)

:)
On Apr 15, 10:51 am, Andreas Kostler  wrote:
> (reduce + (map :b p))
> Cheers
> Andreas
>
> On 15 April 2011 10:43, Bhinderwala, Shoeb 
> wrote:
>
>
>
>
>
>
>
>
>
> >  I am a beginner in Clojure.
>
> > I have a list of maps:
>
> > (def p '({:a 1 :b 2 :c 4}, {:a 2 :b 3 :c 5}, {:a 3 :b 4 :c 6}))
>
> > How do I add up all the :b values in the map? Result should be 9 (=2+3+4)
>
> > I know I should be using one of the higher level functions like apply,
> > reduce and combine it with a custom filter function. But not sure how to
> > write it.
>
> > ***-- Shoeb*
>
> >  --
> > 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 be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en
>
> --
> **
> Andreas Koestler, Software Engineer
> Leica Geosystems Pty Ltd
> 270 Gladstone Road, Dutton Park QLD 4102
> Main: +61 7 3891 9772     Direct: +61 7 3117 8808
> Fax: +61 7 3891 9336
> Email: andreas.koest...@leica-geosystems.com
>
> www.leica-geosystems.com*
>
> when it has to be right, Leica Geosystems
>
> Please  consider the environment before printing this email.

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Is this a good idea? (merging let, cond and ->)

2011-04-14 Thread Stuart Sierra
There's nothing wrong with this. Defining a mini-language for a class of 
common calculations is very much in the spirit macros like Common Lisp's 
`loop`.  

That said, you won't get much support for adding this to the language.  
These kinds of "mini-language" macros tend to have a large number of edge 
cases, making it difficult to determine if they are correct, and even more 
difficult to guarantee that they work correctly when combined with other 
macros.  For that reason, Clojure has generally avoided these kinds of 
macros as language-level features.  This is why Clojure has not adopted any 
of the (many) implementations of threading operators more complex than the 
built-in -> and ->>.

Also, "contrib" as a monolithic thing is being phased out in favor of 
separate repositories dedicated to individual libraries.

Stuart Sierra
clojure.com

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Open Source Projects for Beg/ Intermediate

2011-04-14 Thread Carin Meier
I have fallen for Clojure.  I would love to be able to practice and
hone my skills while contributing something to an open source
project.  Do you have any suggestions for projects that might have
some low-hanging fruit for a newish person like me.  Any floors that
need sweeping?

Carin Meier
@carinmeier

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojure group in DFW area

2011-04-14 Thread J.R. Garcia
I work off of the Tollway and Westgrove at Improving Enterprises. We
have a lot of space and have several user groups meet daily at our
office. I'm sure there are plenty of other Clojure users in the area.
There are plenty of people that I work with that would probably be
interested. Maybe we can meet for lunch sometime and discuss this
further.

On Apr 14, 9:33 am, Alex Robbins 
wrote:
> Glad to hear from you. I live and work a little south of the
> intersection of 121 and the Dallas North Tollway, so any meeting place
> along the DNT would be great for me (Addison included).
>
> Hopefully there are more than two clojure users in Dallas.
>
>
>
> On Wed, Apr 13, 2011 at 3:44 PM, J.R. Garcia  wrote:
> > I live in Fort Worth and work in Addison. I'd love to get together
> > sometime. If there is any interest in getting a user group together, I
> > have the perfect place to host it.
>
> > On Mar 10, 8:28 am, Alex Robbins 
> > wrote:
> >> Anyone else in the north Dallas area using/interested in Clojure? I'd
> >> love to get together.
>
> >> Alex
>
> > --
> > 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 be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Very odd memory allocation behavior

2011-04-14 Thread Ken Wesson
I've been using Clojure to automate some file management tasks over
here; in particular, I whipped together about 100 lines of code to
build and maintain a hash database of certain files and thereby
efficiently discover duplications among these files. (Basically, it
uses a subdirectory of the filesystem as a persisted hashmap, with the
first few bytes of the hash used to make a tree of subdirectories, the
leaves of which are hash buckets that collect files;
FileInputStream/MessageDigest is used to compute file hashes, and
byte-by-byte comparisons detect identical files from among those with
identical hashes.)

I noticed something odd after spending a while working in other file
management tools, then switching to my REPL and hammering off an
(add-files! "/some/directory"). I flipped to NB's *out* tab to monitor
its progress and ... what progress? It had printed nothing, and as I
watched, it continued to print nothing. I switched back to the REPL
and it looked like it had submitted the sexp to the evaluator. But no
output. Then I checked the process list and saw the java task
consuming no CPU (unsusprising since I'd given it an I/O bound task)
but rapidly growing in memory use. It bloated up by several tens of
megs before I finally saw "Entering /some/directory" in *out*.

The funny thing is, the code is basically this:

(defn add-files! [dir]
  (sysprint "Entering " dir)
  (doseq [f (file-seq dir)]
...))

and sysprint is basically this:

(defn sysprint [& objs]
  (.println System/out (apply str objs)))

(so the output goes to *out* instead of blitzkrieging the REPL tab's
scrollback with thousands of lines of output, which then makes looking
things up from earlier in the REPL session very annoying).

Since the thing froze for a significant amount of time allocating a
significant amount of memory before the (.println System.out ...)
succeeded, I conclude that the rest of add-files! is irrelevant here
and it was something in (apply str "Entering " "/some/directory") or
in (.println System/out ...) that spent a long time allocating tens of
megabytes of heap. I'm mystified as to why. The add-files! function
doesn't usually do this, and it recurses for subdirectories, so the
"Entering ..." message is printed several times in a typical use.
After the one long pause, this particular run generated several more
such messages without any noticeable pauses.

What the heck was it? A GC pause? Why would that grow the heap? The
heap should be near max size already and perhaps shrink somewhat in a
GC pause. On the other hand, a long pause accompanied by rapid heap
growth suggests the construction of a large data structure, so large
it's not only big in memory but slow to build. But there was no
significant CPU use by the Java process during the pause, which
suggests that it was performing *blocking I/O*. That suggests it was
loading something big from disk, but a) it hadn't even reached the
doseq yet to start reading and hashing files, b) the files never
reside completely in live heap at one time (only in 4KB chunks), and
c) the files themselves were smallish, few exceeding 1MB and none even
approaching 10MB.

The nearest thing I can figure out is that the process was going ahead
and hashing files, but the *out* display was lagging way behind. So,
the sysprint ran, then the doseq was well underway, and the heap grew
for a while as 4KB chunks were allocated ...

Except a single (byte-array 4096) is being recycled in the hashing
loop. It's a mutable Java array and DigestInputStream.read() is
overwriting its contents for each new chunk. And unless the attached
MessageDigest is building huge temporary data structures, which seems
unlikely, that's basically it. The heap should have grown by a few
megs, total, from String, String[], and File object churn, and
creating one more 4KB array for each new entire file (not each 4KB of
data), over the entire operation. If there were 20 subdirectories and
1000 files, a reasonable estimate, we're looking at:

20 String[] from File.list() on the subdirectories, average length 51
(1020/20), average size 212 bytes or so, for 4240 bytes.

1020 String for file paths, average length say around 30, for 30600 bytes.

1000 4KB byte[] arrays for just under 4MB.

1000 byte[]s of length 20 to hold the 160-bit hashes generated by
MessageDigests, for around 28000 bytes.

1000 MessageDigest objects. If we assume that they contain 20-element
byte[]s but return defensive copies, so those aren't the 28000 bytes
just counted, and (generously!) that they contain another 1KB of
temporary state at peak size, that's another meg.

1020 seq objects over arrays and a few layers of filter, remove, map,
etc. over these, say 10,000 seq objects total, backed by arrays --
generously call that another whole megabyte.

Assorted small temporary strings and such per object -- assume,
generously, yet another full meg total.

= about 7 megabytes.

With a 64 meg heap and a much smaller initial process size, I'd have
expe

Re: Weening myself off of global state - what's the idiomatic way to solve this?

2011-04-14 Thread Brandon Ferguson
This is definitely a good place to start. At very least getting most
of the functions away from the global bits. Thanks!

On Apr 14, 10:42 am, jweiss  wrote:
> I'd start by making functions that take arguments.  For instance (defn
> draw-ball [ball] ...)
>
> On Apr 13, 1:22 pm, Brandon Ferguson  wrote:
>
>
>
>
>
>
>
> > I'm not sure if this is the place to ask this but I've been struggling
> > with a few things in the world of Clojure. I've been using Processing
> > to learn Clojure (since I'm somewhat familiar with Processing) but the
> > tough part has been dealing with things like x, y positions of objects
> > without keeping some global state (I'm not sure if it's even
> > possible).
>
> > The code in question is:https://gist.github.com/887256
>
> > All this does is bounce a ball around a screen, for every frame
> > Processing calls draw which moves the ball one frame. Since I'm not
> > the one driving the loop I ended up using atoms to update some bits of
> > global state but that feels really dirty.
>
> > If I could drive the frames it would be easy to use recur or some
> > other bit of state passing as I render each successive frame. I've
> > considered using sequences and passing a frame number (which would be
> > stored in a global as well) in but then it'd (I assume) have to run
> > through every number up to that the one I passed it. Seems like
> > performance would degrade the longer it ran. There's also this idea
> > rattling around in my head where I'd just rewrite the function
> > everytime with the new state - but seems like you couldn't scale that
> > to multiple balls bouncing around (which is the next step) - and God
> > knows what, if any, performance implications that would have.
>
> > So I'm not sure where that leaves me - learning functional stuff can
> > be wonderfully mind breaking but sometimes I feel like I don't even
> > have the tools in my head to work some things out. Is there some
> > technique I'm missing for dealing with state between successive calls
> > of a function?
>
> > How would you solve something like this?
> > -Brandon

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Weening myself off of global state - what's the idiomatic way to solve this?

2011-04-14 Thread Brandon Ferguson
Holy crap that's a lot to digest! Thanks! A lot of ideas in here to
play with. For me and my purposes with Processing the big challenge
has been the fact that I have little say about the draw loop. It just
fires (or I can call it manually with a redraw, but then it just
executes whatever is in that function). I had a nice recursive
function with no state in the beginning but the first fire of draw
would set it off and it'd draw a bunch of the screen and I'd never see
anything after that from it (cause it'd never return and we'd not get
to the next draw call/frame). Think there might be ways around that
just not sure yet.

Thanks again, and I'll certainly post with an update with where I get
(probably won't be able to dive into it again until the weekend sadly :
(  ).

On Apr 14, 1:00 pm, Ken Wesson  wrote:
> On Wed, Apr 13, 2011 at 1:22 PM, Brandon Ferguson  
> wrote:
> > I'm not sure if this is the place to ask this but I've been struggling
> > with a few things in the world of Clojure. I've been using Processing
> > to learn Clojure (since I'm somewhat familiar with Processing) but the
> > tough part has been dealing with things like x, y positions of objects
> > without keeping some global state (I'm not sure if it's even
> > possible).
>
> If you're currently using atoms, you already have a function to
> compute the new position from the old, say, next-position, which you
> use with something like (swap! ball-pos next-position).
>
> Now consider this: (iterate next-position initial-ball-pos). That
> evaluates to an (infinite!) sequence of ball positions. You could have
> an animation loop step along this sequence, render a frame, wait,
> step, render, wait, etc. until the ESC key is hit (or whatever).
>
> For multiple balls that might interact with one another, a given
> ball's next position becomes a function of the other ball positions
> and not just its own. So you end up with:
>
> (iterate next-world-state initial-world-state)
>
> with world states being e.g. maps of ball-IDs to ball-positions or
> something. Obviously, other kinds of changeable world state can be
> included, too, e.g. Pong paddle positions, or the locations and amount
> of damage taken by Arkanoid bricks.
>
> This works until you get interactive (e.g. letting a human player
> control a paddle or something). At that point, iterate becomes a bit
> icky because the function becomes impure (as it polls the input
> devices).
>
> Then you probably just want two components:
>
> 1. A Swing GUI that captures mouse and keyboard events in the game's
> JPanel as well as rendering the frames there.
> 2. A game loop.
>
> The simplest case uses the Swing EDT as the game loop, with a Timer
> triggering game updates. But that requires mutable state for the game
> state to persist between Timer events.
>
> The other case keeps most of the game state immutable, but requires a
> bit of mutability to pass input to the game from the GUI:
>
> 1. The Swing event handlers post input messages to a
> LinkedBlockingQueue, or update atoms or refs holding the current
> position of the mouse and state (down or up) of relevant mouse buttons
> and keyboard keys.
>
> 2. The game loop runs in its own thread and looks something like this:
>
> (loop [foo bar other game state variables]
>   ...
>     (recur new-foo new-bar new-other ...)...)
>
> The game checks the input state, or drains the LinkedBlockingQueue, or
> whatever when it comes around to updating the player's position.
>
> One way to do it is just to have a set of game world objects:
>
> (loop [time (System/currentTimeMillis)
>        world (hash-set (cons (new-player) (generate-initial-world-state)))]
>   (let [world (map (partial update-position world) world)
>         new-objects (mapcat new-things world)
>         damages (reduce (partial merge-with +) {} (map do-damage world))
>         world (concat
>                 new-objects
>                 (remove dead?
>                   (map (partial apply-damages damages) world)))]
>     (SwingUtilities/invokeAndWait
>       (fn []
>         (let [g (get-the-jpanel's-double-buffer-graphics)]
>           (doseq [obj world] (draw-on! obj g)))
>         (flip-the-jpanel's-double-buffer!)))
>     (if (some is-player? world)
>       (let [elapsed (- (System/currentTimeMillis) time)
>             sl (- *ms-per-frame* elapsed)]
>         (if (> sl 0) (Thread/sleep sl))
>         (recur (System/currentTimeMillis) world))
>       world)))
>
> Here, new-player generates a new player object and
> generate-initial-world-state generates a seq of other objects for the
> initial world-state. The update-position function takes the world and
> a game object and runs the latter's ai, returning a new game object
> representing the old one's changed position (and possibly other state
> changes). The world is passed in so that collision checks can be done
> when needed.
>
> The new-things function allows some game objects to potentially
> generate more (e.g. shooting projectil

You should fix this before next release!

2011-04-14 Thread Armando Blancas
Could "before next release" be changed to something like, er, "real
soon"? (at least for c.c namespaces)

Var *feeling-lucky-url* not marked :dynamic true, setting to :dynamic.
You should fix this before next release!
Var *feeling-lucky* not marked :dynamic true, setting to :dynamic. You
should fix this before next release!
Var *local-javadocs* not marked :dynamic true, setting to :dynamic.
You should fix this before next release!
Var *core-java-api* not marked :dynamic true, setting to :dynamic. You
should fix this before next release!
Var *remote-javadocs* not marked :dynamic true, setting to :dynamic.
You should fix this before next release!

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Cyber Dungeon Quest Alpha 1

2011-04-14 Thread msappler
I think I fixed that yesterday evening:

Unable to load resource:http://sappler.ls4.allbytes.de/resatori/
webstart/cdq.jnlp
403 is forbidden.

I wrote deny all in the .htaccess file :)

-
Want to highlight anything you did in the game? I'm interested in any
use of agents, etc that you used.

Yes I am thinking of that. Any other things you may want to know
about?

On 14 Apr., 21:20, Alan  wrote:
> Similar error for me, on Ubuntu. Exception and "wrapped exception"
> follow. Looks like you may need permissions set better? 403 is
> Forbidden.
>
> com.sun.deploy.net.FailedDownloadException: Unable to load 
> resource:http://sappler.ls4.allbytes.de/resatori/webstart/cdq.jnlp
>         at
> com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
> 1372)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1525)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1503)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1609)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1534)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 217)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 201)
>         at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:469)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:248)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:199)
>         at com.sun.javaws.Launcher.launch(Launcher.java:116)
>         at com.sun.javaws.Main.launchApp(Main.java:416)
>         at com.sun.javaws.Main.continueInSecureThread(Main.java:248)
>         at com.sun.javaws.Main$1.run(Main.java:110)
>         at java.lang.Thread.run(Thread.java:662)
>
> java.io.IOException: Server returned HTTP response code: 403 for 
> URL:http://sappler.ls4.allbytes.de/resatori/webstart/cdq.jnlp
>         at sun.reflect.GeneratedConstructorAccessor1.newInstance(Unknown
> Source)
>         at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
> 27)
>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>         at sun.net.www.protocol.http.HttpURLConnection
> $6.run(HttpURLConnection.java:1491)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnec...
> 1485)
>         at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
> 1139)
>         at
> com.sun.deploy.net.BasicHttpRequest.doRequest(BasicHttpRequest.java:
> 229)
>         at
> com.sun.deploy.net.BasicHttpRequest.doRequest(BasicHttpRequest.java:
> 113)
>         at
> com.sun.deploy.net.BasicHttpRequest.doGetRequest(BasicHttpRequest.java:
> 78)
>         at
> com.sun.deploy.net.DownloadEngine.actionDownload(DownloadEngine.java:
> 1182)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1525)
>         at
> com.sun.deploy.net.DownloadEngine.getCacheEntry(DownloadEngine.java:
> 1503)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1609)
>         at
> com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(DownloadEngine.java:
> 1534)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 217)
>         at com.sun.deploy.net.DownloadEngine.getResource(DownloadEngine.java:
> 201)
>         at com.sun.javaws.Launcher.updateFinalLaunchDesc(Launcher.java:469)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:248)
>         at com.sun.javaws.Launcher.prepareToLaunch(Launcher.java:199)
>         at com.sun.javaws.Launcher.launch(Launcher.java:116)
>         at com.sun.javaws.Main.launchApp(Main.java:416)
>         at com.sun.javaws.Main.continueInSecureThread(Main.java:248)
>         at com.sun.javaws.Main$1.run(Main.java:110)
>         at java.lang.Thread.run(Thread.java:662)
> Caused by: java.io.IOException: Server returned HTTP response code:
> 403 for URL:http://sappler.ls4.allbytes.de/resatori/webstart/cdq.jnlp
>         at
> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
> 1436)
>         at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:
> 379)
>         at
> com.sun.deploy.net.BasicHttpRequest.doRequest(BasicHttpRequest.java:
> 190)
>         ... 17 more
>
> On Apr 14, 12:03 pm, mark skilbeck 
> wrote:
>
>
>
>
>
>
>
> > Still doesn't work for me. Same error as Alfredo.
>
> > On Thu, Apr 14, 2011 at 1:26 PM, msappler  wrote:
> > > Hmm I updated the natives-mac.jar.
> > > But dont know this error I dont have a mac..
>
> > > On 14 Apr., 14:16, Walter Chang  wrote:
> > >> failed to run on mbp osx 10.6.7 (java version "1.6.0_24").  here is the
> > >> stack trace:
>
> > >> java.lang.NullPointerException
> > >> at
> > >> o