Re: Clojure for game programming?

2009-08-30 Thread Elliott Slaughter
On Aug 30, 6:55 pm, ztellman wrote: > On Aug 30, 4:40 pm, Elliott Slaughter > wrote: > > Have you thought about OpenGL ES at all? I don't know the state of ES > > in Java, but it would be really cool if I could use one Clojure > > library to target both desktop and embedded systems. > > > Thanks

Re: Unable to build a simple project with clojure-ant-tasks

2009-08-30 Thread J. McConnell
On Sun, Aug 30, 2009 at 1:02 PM, Ivan Chernetsky wrote: > 2009/8/30 J. McConnell : > > > What versions of Clojure and Clojure-Contrib are you using? > > The freshest ones. This appears to be the problem. If I use the HEAD version of Clojure, I get the same error and it goes away if I use the -li

Re: Clojure for game programming?

2009-08-30 Thread ztellman
On Aug 30, 4:40 pm, Elliott Slaughter wrote: > On Aug 30, 12:20 am, ztellman wrote: > > > You may have already seen this and decided Cloggle was a bit more to > > your liking, but I'm also working on a JOGL wrapper called Penumbra > > No, I hadn't actually seen this. My main reason for building

How do I add a new collection in Clojure?

2009-08-30 Thread jonathan.arrender.sm...@gmail.com
I was not sure from the documentation if conj, seq, etc are generic functions (multimetiod functions). Is there any easy way to define these for a new type? Thanks! Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google G

Re: Clojure for game programming?

2009-08-30 Thread Elliott Slaughter
On Aug 30, 12:20 am, ztellman wrote: > You may have already seen this and decided Cloggle was a bit more to > your liking, but I'm also working on a JOGL wrapper called Penumbra No, I hadn't actually seen this. My main reason for building on Cloggle was that it was the only lib I was aware of; i

Re: How do I add a new collection in Clojure?

2009-08-30 Thread Timothy Pratley
According to the code you need to implement an IPersistentCollection and Seqable You can browse or download the code: http://github.com/richhickey/clojure/tree/master look in src/clj/clojure/core.clj for the definition of conj etc, which you can see call methods on RT.java which is in src/jvm/cloj

How do I add a new collection in Clojure?

2009-08-30 Thread jonathan.arrender.sm...@gmail.com
I was not sure from the documentation if conj, seq, etc are generic functions (multimetiod functions). Is there any easy way to defines these for a new type? Thanks! Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

How do I add a new collection in Clojure?

2009-08-30 Thread jonathan.arrender.sm...@gmail.com
I was not sure from the documentation if conj, seq, etc are generic functions (multimetiod functions). Is there any easy way to define these for a new type? Thanks! Jonathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google G

Re: vs. Python

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 12:32 PM, CuppoJava wrote: > > Your examples are very good I think. It always helps to have a > straight-forward conversion from one language to another for > beginners. They will eventually pick up idioms and methodology by > playing around. > > One comparison that bothers

Re: Why am I getting this performance result from Clojure CLR's LispReader?

2009-08-30 Thread Licenser
The reason is the Filesystem. The OS caches data that was read from disk in memory, so if you read the same file over and over again it is read from disk the first time every following time it takes it out of the memory. That means only the first result gives you the actual time it takes to acces

Re: assoc-in-by

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 4:14 PM, kyle smith wrote: > > I wrote this based on assoc-in. If anyone thinks this should be in > core or contrib, feel free to use it. > > (defn assoc-in-by > "'Updates' a value in a nested associative structure, where ks is a > sequence of keys and (f v) is the new

Re: Why am I getting this performance result from Clojure CLR's LispReader?

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 10:40 AM, Jason Baker wrote: > > I've written a test that does this: > >public void ReadFile(TextReader infile) >{ >using (var text_reader = new PushbackTextReader(infile)) { >LispReader.read(text_reader, false, null, true); >

Re: Clojure/EPL and the GPL

2009-08-30 Thread John Harrop
On Sun, Aug 30, 2009 at 7:57 AM, Jan Rychter wrote: > > Tassilo Horn writes: > [...] > > BTW: What's the reason that Clojure is licensed under the EPL and the > > contrib stuff under CPL? Since clojure is not really eclipse-related, I > > don't see a good rationale. IMHO, the Lesser GPL would

Re: Unable to build a simple project with clojure-ant-tasks

2009-08-30 Thread Ivan Chernetsky
2009/8/30 J. McConnell : > Hmmm ... This builds fine for me (with the inclusion of > edn.main in the element). I've > uploaded what I have here so you can try it on your machine: I have just pasted this too. > http://github.com/jmcconnell/test-clojure-ant-project/tree/master It seems to be id

Re: vs. Python

2009-08-30 Thread Jonathan
There are two styles of expression in higher level languages (including Python and Clojure). Functional programming (map, filter, reduce, fold) on one side and set (and list) comprehensions on the other. This is somewhat a matter of culture, not capability. Although slightly less convenient, funct

Re: vs. Python

2009-08-30 Thread James Cunningham
On Aug 30, 3:24 am, Dan Fichter wrote: > [...] > Take a dictionary of defaults and a user-supplied dictionary and return a > new dictionary that combines them, with the user's entries winning when both > dictionaries have the same key. > > [Clojure] > > (defn foo [defaults user] >   (merge defaul

Re: assoc-in-by

2009-08-30 Thread kyle smith
haha, the api page strikes again! I figured something so basic would have to be included, but I obviously didn't see update-in. It would be nice to have a list of related functions that do not follow the standard nomenclature. Will the upcoming documentation push address this? --~--~-~-

Re: assoc-in-by

2009-08-30 Thread Meikel Brandmeyer
Hi, Am 30.08.2009 um 22:14 schrieb kyle smith: user> (assoc-in-by {:1 1 :2 {:3 3}} [:2 :3] inc) {:1 1, :2 {:3 4}} Doesn't this sound like update-in? 1:1 user=> (update-in {:a 1 :b {:c 3}} [:b :c] inc) {:a 1, :b {:c 4}} Sincerely Meikel smime.p7s Description: S/MIME cryptographic signatur

assoc-in-by

2009-08-30 Thread kyle smith
I wrote this based on assoc-in. If anyone thinks this should be in core or contrib, feel free to use it. (defn assoc-in-by "'Updates' a value in a nested associative structure, where ks is a sequence of keys and (f v) is the new value and returns a new nested structure. If any levels do no

Re: Why am I getting this performance result from Clojure CLR's LispReader?

2009-08-30 Thread David Miller
Using a variant of your code, I got results like this: ReadFile: 516 msecs ReadFile: 75 msecs ReadFile: 76 msecs ReadFile: 75 msecs ... -David Profiling shows the bulk of the time on the first iteration being taken up by the JIT-compiler. On subsequent iterations, either String.Intern or Pushb

Re: When to use macros

2009-08-30 Thread ronen
Cool, I guess that there is no "one" correct answer but more a question of style & experience, the separation of logic & code mangling into two parts makes the most sense to me. Ill continue to sharp my macro foo ;) On Aug 30, 8:16 pm, Vagif Verdi wrote: > I would argue that macros always shou

STM article

2009-08-30 Thread Mark Volkmann
I think we'd all agree that STM is a very important feature of Clojure. I trust that it works as advertised, but until recently I didn't feel that I understood exactly how it worked. This left me unable to defend it when pressed by developers that aren't using Clojure. I wanted to change that, for

Re: When to use macros

2009-08-30 Thread Vagif Verdi
I would argue that macros always should be syntax wrappers for functions. Coding the logic into a macro in most cases is a mistake. So first write the function that does the work. Then write a macro that simplifies a syntax to call that function. --~--~-~--~~~---~--~--

Re: vs. Python

2009-08-30 Thread CuppoJava
Your examples are very good I think. It always helps to have a straight-forward conversion from one language to another for beginners. They will eventually pick up idioms and methodology by playing around. One comparison that bothers me though is this: (not= (new Exception) (new Exception)) Agai

Re: vs. Python

2009-08-30 Thread Michael Wood
2009/8/30 Dan Fichter : [...] > [Clojure] > > (println "Hello, world") > > [Python] > > print "Hello, world" Or Python 3.x: print("Hello, world") > A list (in Clojure, a vector) of three integers. > > [Clojure] > > [1 2 3] This can also be written in Clojure as [1, 2, 3]. Commas are considere

Re: When to use macros

2009-08-30 Thread Jonathan Smith
On Aug 29, 3:48 pm, ronen wrote: > In a lot of cases its seems that macros are used even when a function > can do the same task, > Macros seems to be less readable than their functional counterparts & > more complex to write (to me at least). > > Its clear that there are special cases in which

Re: Help

2009-08-30 Thread Emeka
Angel, (note the space between & and v) --> no clojure here... it's English... :-) > > If you write &v (without space) it's just another identifier &v. You are pretty right. However, for your case to hold that &v is another identifier, just try it out. Regards, Emeka --~--~-~--~~-

Re: Unable to build a simple project with clojure-ant-tasks

2009-08-30 Thread J. McConnell
On Sun, Aug 30, 2009 at 10:15 AM, Ivan Chernetsky wrote: > > Either of clojure/core.clj and clojure/core__init.class is on > classpath, I think. What am I doing wrong? > Hmmm ... This builds fine for me (with the inclusion of edn.main in the element). I've uploaded what I have here so you can t

Unable to build a simple project with clojure-ant-tasks

2009-08-30 Thread Ivan Chernetsky
Hello! I wrote build.xml with the following content: And I have a simple directory structure: # find . ./build.xml ./src ./src/edn ./sr

Re: Help

2009-08-30 Thread Angel Java Lopez
I guess you want to write: (defn foo [& v] (apply + v)) (note the space between & and v) --> no clojure here... it's English... :-) If you write &v (without space) it's just another identifier &v. Angel "Java" Lopez http://www.ajlopez.com http://twitter.com/ajlopez On Sun, Aug 30, 2009 at 10:

Re: Significant isa? / multimethod optimization opportunity

2009-08-30 Thread Chas Emerick
On Aug 29, 2009, at 7:41 PM, Rich Hickey wrote: > Since multimethods (are supposed to) cache their lookup *results* > (i.e. they shouldn't lookup over and over), I wouldn't expect this to > yield any improvement in a stable system with reused call paths. Are > you calling isa? yourself? Can you

Re: vs. Python

2009-08-30 Thread Dragan Djuric
> For example, consider these two snippets: > > [Clojure] > (if x >   (foo y) >   (bar y)) > > [Python] > if x: >   foo(y) > else: >   bar(y) > Yeah, but then, in plain old Java: if x { foo(y); } else { bar(y); } which is not that different at all. The point is that these trivial micro-sni

Why am I getting this performance result from Clojure CLR's LispReader?

2009-08-30 Thread Jason Baker
I've written a test that does this: public void ReadFile(TextReader infile) { using (var text_reader = new PushbackTextReader(infile)) { LispReader.read(text_reader, false, null, true); } } ...in a loop. I'm running this operation

Re: vs. Python

2009-08-30 Thread Rob Wolfe
Dan Fichter napisał(a): > I'd like to convince some Python developers that Clojure is not foreign and > does many things better than Python. I'd appreciate whatever suggestions > you have about what I've written. [...] > Check whether every object in the collection x can be called like a > fu

Re: Clojure for game programming?

2009-08-30 Thread CuppoJava
Hi Elliot, I've written a small game using Clojure and LWJGL, and I've run into the exact same issue (balancing between mutability and immutability) when I was working on it. The three approaches I tried were: The world is 1 ref containing the state of the game. Everything else is immutable. Spr

Re: Help

2009-08-30 Thread Mark Volkmann
On Sun, Aug 30, 2009 at 8:09 AM, Emeka wrote: > Hello All, > > I was fooling around with clojure and I found something I have not noticed > before. Could someone explain it ? > > (defn foo [ &v] > (apply + &v)) > > Is '&' + the identifier's name another where of making sure that the > parameter mu

Re: vs. Python

2009-08-30 Thread Jason Baker
On Aug 30, 2:24 am, Dan Fichter wrote: > The Clojure version is more concise and radically safer but a little more > conceptually packed.  Is it worth your trouble? Being primarily a Python programmer, I can say that the first thing my co-workers would say is that Clojure isn't as readable as Py

Help

2009-08-30 Thread Emeka
Hello All, I was fooling around with clojure and I found something I have not noticed before. Could someone explain it ? (defn foo [ &v] (apply + &v)) Is '&' + the identifier's name another where of making sure that the parameter must be a collection? Or is there something I am doing wrong here?

Re: vs. Python

2009-08-30 Thread Chas Emerick
On Aug 30, 2009, at 3:24 AM, Dan Fichter wrote: > I'd like to convince some Python developers that Clojure is not > foreign and does many things better than Python. I'd appreciate > whatever suggestions you have about what I've written. > > Though I am crazy about STM and Clojure agents, I

Re: Searching the group archives

2009-08-30 Thread Emeka
Thanks, I was about asking for help. Regards, Emeka On Sat, Aug 29, 2009 at 6:54 PM, Rich Hickey wrote: > > While the "Search this group" interface seems increasingly anemic, and > time-limited in its results, you can get an effective search on the > group archives using the advanced search: >

Re: Clojure/EPL and the GPL

2009-08-30 Thread Jan Rychter
Tassilo Horn writes: [...] > BTW: What's the reason that Clojure is licensed under the EPL and the > contrib stuff under CPL? Since clojure is not really eclipse-related, I > don't see a good rationale. IMHO, the Lesser GPL would be a much better > fit. Then you can use clojure also in commerc

Re: help with clojure + slime

2009-08-30 Thread Lauri Pesonen
2009/8/30 mlm : > (setq swank-clojure-extra- > classpaths >      (list > "/opt/clojure/clojure-contrib/clojure-contrib.jar:/opt/clojure/swan\ > k-clojure/swank/swank.clj")) Try changing the swank-clojure bit to point to the directory rather than the .clj file, i.e. either /opt/clojure/swank-clo

Re: Clojure for game programming?

2009-08-30 Thread fyuryu
In general, staying on the purely functional side will most likely kill your performance. You will need some mutation (I'd like to be proven otherwise, though). And not mutation via refs and so on, but mutation in the Java sense. So you'll have to create some Java classes for your game objects It

Re: Clojure for game programming?

2009-08-30 Thread David Nolen
On Sun, Aug 30, 2009 at 6:01 AM, Elliott Slaughter < elliottslaugh...@gmail.com> wrote: > > All game simulation models I've seen used graphs of mutable objects; > I'm not entirely sure how to move to a more functional model. One the > one hand, reallocating the game world on every frame seems exce

vs. Python

2009-08-30 Thread Dan Fichter
I'd like to convince some Python developers that Clojure is not foreign and does many things better than Python. I'd appreciate whatever suggestions you have about what I've written. Though I am crazy about STM and Clojure agents, I don't deal with them here. This has to be a gentle introduction

Re: Clojure for game programming?

2009-08-30 Thread Daniel
On Sun, Aug 30, 2009 at 2:20 PM, ztellman wrote: > > You may have already seen this and decided Cloggle was a bit more to > your liking, but I'm also working on a JOGL wrapper called Penumbra > ( http://github.com/ztellman/penumbra/tree/master ).  Documentation is > thin, but here are some demos i

Re: When to use macros

2009-08-30 Thread Meikel Brandmeyer
Hi, Am 29.08.2009 um 21:48 schrieb ronen: In a lot of cases its seems that macros are used even when a function can do the same task, Macros seems to be less readable than their functional counterparts & more complex to write (to me at least). Its clear that there are special cases in which ma

Re: Clojure for game programming?

2009-08-30 Thread ztellman
You may have already seen this and decided Cloggle was a bit more to your liking, but I'm also working on a JOGL wrapper called Penumbra ( http://github.com/ztellman/penumbra/tree/master ). Documentation is thin, but here are some demos in the src/examples subdirectory to illustrate usage. At th