Re: struct question

2009-01-22 Thread Jason Wolfe
On Jan 21, 11:48 pm, Mark Engelberg mark.engelb...@gmail.com wrote: Thanks for the thread links.  This is basically what I suspected -- if you want to use structs in multimethods, you have to roll your own constructor which adds some kind of type tag to either the hashmap or the metadata.

Re: struct question

2009-01-22 Thread Konrad Hinsen
On 22.01.2009, at 07:48, Mark Engelberg wrote: Is there any way to determine whether something is a struct (versus an ordinary hash map), and if so, determine which kind of struct it was built from? Not that I know. I have been searching for a while, and ended up using my own tag attached

Re: struct question

2009-01-22 Thread David Nolen
Finally started a GitHub repo just for this project. http://github.com/swannodette/cljos/tree/master The earlier version of course was very flawed/buggy. OK start, but the macros in it were written with little/no understanding about how symbols are resolved into their namespaces in Clojure (or

Re: struct question

2009-01-22 Thread David Nolen
I am not entirely happy with this approach though. If everyone starts to use metadata for various purposes, such type tags may well disappear by some function replacing the metadata on an object without preserving the tags that are already there. This is all the more likely because there is

Re: struct question

2009-01-22 Thread Christophe Grand
Konrad Hinsen a écrit : there is nothing in the standard library to add a tag to an existing metadata map. All there is is (with-meta ...), which replaces the metadata map completely. It itched me before and since there's already alter-meta! maybe there should also be an alter-meta

Re: struct question

2009-01-22 Thread Konrad Hinsen
On 22.01.2009, at 09:30, Konrad Hinsen wrote: Not that I know. I have been searching for a while, and ended up using my own tag attached to the struct as metadata. In clojure.zip there is a similar use of metadata: methods are implemented as functions passed in the metadata. After a quick

Re: Clojure Web Libraries

2009-01-22 Thread James Reeves
On Jan 21, 9:39 pm, Frank ffai...@gmail.com wrote: I am interested in trying to use Clojure to develop web-based applications.  Can someone point me to any Clojure libraries that have been written that I can use.  Thanks. There's Compojure, which looks like this: (defservlet demo-servlet

Re: struct question

2009-01-22 Thread Konrad Hinsen
On 22.01.2009, at 10:51, Konrad Hinsen wrote: At the end of this message is a simple illustration of what can be done with these changes. Any feedback is welcome of course! Maybe I should reply immediately to some objections I expect to come: 1) Why create a secondary type system around

Re: Agent as a processing queue

2009-01-22 Thread Greg Harman
Thanks Tim, I'll have a look at that. To clarify my use case, I was thinking of events that can be processed sequentially but that may take a non-trivial amount of time to complete (both CPU and IO bound at different stages of processing) so it's ideal to have a thread pool to process different

Re: Gorilla issue with recent builds?

2009-01-22 Thread Mark Feeney
Hi Meikel, On Jan 21, 3:01 pm, Meikel Brandmeyer m...@kotka.de wrote: There was a breakage some time ago, which made it necessary to release a bug fix release. The revisions are named on the vim.org page, where you can download Gorilla. Please check there if this solves your problem. If not,

Re: Streams work

2009-01-22 Thread Rich Hickey
On Jan 22, 12:53 am, Mark H. mark.hoem...@gmail.com wrote: On Jan 21, 5:21 pm, e evier...@gmail.com wrote: I would think it would be useful to have something exactly like a stream but that allowed as many iterators as you like but that a mutex prevented any two from consuming the same

Re: Streams work

2009-01-22 Thread e
Now imagine two threads T1 and T2 accessing this generator at the same time. Suppose they reach the same node at the same time, and suppose that you've protected file deletion and link deletion each individually with a mutex (and forbade multiple deletions silently). T1 might delete the

Re: Agent as a processing queue

2009-01-22 Thread Greg Harman
I like the example, and I should be able to adapt it. I do have one question about the example (probably not related to agents: ; queue up some work to be done (defn add-job [func] (let [a (agent nil)] (send a (fn [_] (func))) (swap! jobs #(conj %1 a What is the notation fn [_]? I

Re: Streams work

2009-01-22 Thread Konrad Hinsen
On 21.01.2009, at 20:33, Rich Hickey wrote: I've started documenting the streams work I have been doing, for those interested: http://clojure.org/streams Nice! I have played a bit with the stream implementation, and I came across a behaviour that I do not understand: First, define a

Re: struct question

2009-01-22 Thread Rich Hickey
On Jan 22, 4:46 am, Christophe Grand christo...@cgrand.net wrote: Konrad Hinsen a écrit : there is nothing in the standard library to add a tag to an existing metadata map. All there is is (with-meta ...), which replaces the metadata map completely. It itched me before and since there's

Re: printing deeply nested things

2009-01-22 Thread Stuart Halloway
Hi Rich, It is a small real problem: in the book I demonstrate an incorrect, stack-consuming recursion that blows up on a deeply nested structure. When the recursion is fixed, it *still* blows up because the REPL cannot print it, so I introduce *print-level*. I don't think printing

Re: Agent as a processing queue

2009-01-22 Thread Christian Vest Hansen
On Thu, Jan 22, 2009 at 2:52 PM, Greg Harman ghar...@gmail.com wrote: I like the example, and I should be able to adapt it. I do have one question about the example (probably not related to agents: ; queue up some work to be done (defn add-job [func] (let [a (agent nil)] (send a (fn

Re: struct question

2009-01-22 Thread Rich Hickey
On Jan 22, 2:48 am, Mark Engelberg mark.engelb...@gmail.com wrote: Thanks for the thread links. This is basically what I suspected -- if you want to use structs in multimethods, you have to roll your own constructor which adds some kind of type tag to either the hashmap or the metadata.

Re: Streams work

2009-01-22 Thread Christian Vest Hansen
On Thu, Jan 22, 2009 at 2:18 PM, Rich Hickey richhic...@gmail.com wrote: Those are important things to think about. There are, in fact, thread semantics for the streams mechanism, as for the rest of Clojure. Currently, I've made it such that the stream/iter/ seq combination ensures

Re: Clojure Web Libraries

2009-01-22 Thread Mark McGranaghan
I'd suggest using Compojure for your first project - its fairly widely used, is easy to pick up, and has a growing set of docs. I'm not sure that Webjure is maintained anymore (i.e. no commits to its repo in a few months). Weld is still a work in progress - I'm trying to stabilize it now but it

Re: struct question

2009-01-22 Thread Konrad Hinsen
On 22.01.2009, at 15:26, Rich Hickey wrote: It's pretty easy to write a trivial struct system, much harder to address performance, interop, compilability, dynamicity etc constraints. Indeed. As a simple case, if a defstruct is re-evaluated, will objects created after that be of the same

Re: Streams work

2009-01-22 Thread Rich Hickey
On Jan 22, 9:08 am, Konrad Hinsen konrad.hin...@laposte.net wrote: On 21.01.2009, at 20:33, Rich Hickey wrote: I've started documenting the streams work I have been doing, for those interested: http://clojure.org/streams Nice! I have played a bit with the stream implementation, and

Re: Agent as a processing queue

2009-01-22 Thread Timothy Pratley
(both CPU and IO bound at different stages of processing) so it's ideal to have a thread pool to process different tasks in parallel, even though they are independent. If you use the agents, the underlying implementation uses two thread pools: (1) static relative to your processors, use send

Re: Streams work

2009-01-22 Thread Konrad Hinsen
On 22.01.2009, at 16:27, Rich Hickey wrote: Now it works - fine. But what happened to the seq that now owns the stream? Nothing refers to it, so it should be gone. No, the stream must refer to it, in order to keep its promise to return the same seq every time. OK. Did it perhaps

Re: Clojure Web Libraries

2009-01-22 Thread Stuart Sierra
Hi Frank, I'd also recommend looking at Restlet http://www.restlet.org/ and the Java Servlets API. -Stuart Sierra On Jan 21, 4:39 pm, Frank ffai...@gmail.com wrote: Hi, I am interested in trying to use Clojure to develop web-based applications.  Can someone point me to any Clojure libraries

Re: very simple javascript source using clojurescript?

2009-01-22 Thread Chouser
On Thu, Jan 22, 2009 at 12:33 AM, Allen Rohner aroh...@gmail.com wrote: Chouser, how usable is clojurescript to generate extremely simple javascript calls? When creating HTML templates, I find myself using ugly string interpolation to generate the .js. I would really love it if I could do

Re: Agent as a processing queue

2009-01-22 Thread Emeka
Tim, Could you explain atoms the way you explained agents?\ Emeka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from

Re: struct question

2009-01-22 Thread David Nolen
http://lispnyc.org/soc2009.clp Forget most of what I said, it seems the BDFL already has these things in mind ;) Enough of types and structs for me, time for me dive into the less familiar territory of Clojure. On Thu, Jan 22, 2009 at 12:25 PM, David Nolen dnolen.li...@gmail.comwrote: Can't

Re: Streams work

2009-01-22 Thread Stuart Sierra
On Jan 21, 2:33 pm, Rich Hickey richhic...@gmail.com wrote: I've started documenting the streams work I have been doing, for those interested: Cool! 3 questions: 1. Can you feed things into a stream? 2. Could streams be used for I/O? 3. Can streams have clean-up/close code when they are

Re: struct question

2009-01-22 Thread Meikel Brandmeyer
Hi, Am 22.01.2009 um 18:25 schrieb David Nolen: Can't some elements of the problem be solved with some form of predicate dispatching as proposed by Meikel? Predicate dispatching would allows us to use _anything_ as a type (i.e. structs themselves), as well as allowing user defined

File, Line Number and Usage Info

2009-01-22 Thread Peter Wolf
Here's a dumb question which has been answered before... but I can't find it in the docs. How does one find out the file and line number upon which a symbol was defined? I want to use it for go-to-defintion in the IntelliJ plugin. Also, is there any way to find all the code that is

Re: File, Line Number and Usage Info

2009-01-22 Thread Chouser
On Thu, Jan 22, 2009 at 1:20 PM, Peter Wolf opus...@gmail.com wrote: Here's a dumb question which has been answered before... but I can't find it in the docs. user= (map (meta (var take)) [:file :line]) (core.clj 1434) Which is to say, the file and line number are stored in the metadata of

Re: Streams work

2009-01-22 Thread Rich Hickey
On Jan 22, 2009, at 11:17 AM, Konrad Hinsen wrote: On 22.01.2009, at 16:27, Rich Hickey wrote: Now it works - fine. But what happened to the seq that now owns the stream? Nothing refers to it, so it should be gone. No, the stream must refer to it, in order to keep its promise to return

Re: Streams work

2009-01-22 Thread Rich Hickey
On Jan 22, 2009, at 12:36 PM, Stuart Sierra wrote: On Jan 21, 2:33 pm, Rich Hickey richhic...@gmail.com wrote: I've started documenting the streams work I have been doing, for those interested: Cool! 3 questions: 1. Can you feed things into a stream? Yes, you can put a generator on

newbie: namespaces and load-file

2009-01-22 Thread Paul Henning
Suppose I have a clojure file called app.clj that contains something like: (ns app) (defn foo [] (println hello)) (defn reader [filename] (load-file filename)) and a file called data that simply contains (foo) What I would like to see, from the REPL, is: user= (load-file app.clj) user=

Re: newbie: namespaces and load-file

2009-01-22 Thread Stephen C. Gilardi
On Jan 22, 2009, at 12:46 PM, Paul Henning wrote: As described, this doesn't work. load-file looks up symbols in the current namespace (user in this case), but foo is interned in app. At some point in this process, Clojure needs to know which foo you're talking about. It can't retrieve

Re: newbie: namespaces and load-file

2009-01-22 Thread Paul Henning
At some point in this process, Clojure needs to know which foo you're   talking about. It can't retrieve the var associated with foo without   knowing which namespace it's in. That determination can either be   explicit or it can be made via the current namespace (*ns*), but it   has to be

Re: File, Line Number and Usage Info

2009-01-22 Thread lpetit
Hello, Here is how I get an hierarchical data structure of information on ns in clojure-dev : The tree has really just 3 levels : one root node representing all ns, one child node of the root node representing one ns each, one child node per ns node for ns interned symbols. Each node is

Calling Clojure from Java (again)

2009-01-22 Thread Peter Wolf
This is a rejuvenation of the old calling Java from Clojure thread I have been looking at the solutions from Mark / 1) From a Java application, read a text file containing Clojure code and invoke specific functions it defines from Java code. 2) Compile Clojure code to bytecode and use

Re: newbie: namespaces and load-file

2009-01-22 Thread Stephen C. Gilardi
On Jan 22, 2009, at 3:56 PM, Paul Henning wrote: As long as no one cares if I muck with *ns*, I can make it work [...] That brings up an important point. The var *ns* may look like a global variable in C++, but it's really a dynamic variable--something quite a bit safer and more

Re: Clojure Web Libraries

2009-01-22 Thread Frank
Thanks to everyone for their responses. I will be looking into all these libraries. I wanted to add two other references to this thread that I will also be researching. I found two libraries written by Christophe Grand: Ring - http://github.com/mmcgrana/ring/tree/master Enlive -

Re: Calling Clojure from Java (again)

2009-01-22 Thread Michael Reid
On Thu, Jan 22, 2009 at 4:43 PM, Peter Wolf opus...@gmail.com wrote: This is a rejuvenation of the old calling Java from Clojure thread I have been looking at the solutions from Mark / 1) From a Java application, read a text file containing Clojure code and invoke specific functions it

Re: File, Line Number and Usage Info

2009-01-22 Thread lpetit
Peter, A weird thing seems to happen often those days, and I have remarked it's related to you. You start a new post, but it appears to be in the continuation of a previous one, with the subject changed. This does not look good to me. Are you doing something like this to start a new post :

Re: Clojure Web Libraries

2009-01-22 Thread James Reeves
On Jan 22, 10:15 pm, Frank ffai...@gmail.com wrote: I found two libraries written by Christophe Grand: Only Enlive was written my Christophe; Ring was written by Mark. From what I gather Ring is an abstraction layer like Rack, and isn't designed to be used directly to build web applications.

function that takes primitives?

2009-01-22 Thread Korny Sietsma
Hi folks, Is there any way to make a function that takes primitive parameters? It seems you can't, but I might be missing something. I have the following code (a start to playing with mandelbrot sets): (defn step [x0, y0, xn, yn] (let [xm (+(-(* xn xn)(* yn yn)) x0) ym (+(* 2 xn yn)

Re: File, Line Number and Usage Info

2009-01-22 Thread Peter Wolf
Ooops! How embarrassing :-( Yes, that's exactly what I am doing. It did not occur to me that there is extra information embedded in the reply that marks it as being part of a thread. Sorry, won't happen again P lpetit wrote: Peter, A weird thing seems to happen often those days, and

Re: Calling Clojure from Java (again)

2009-01-22 Thread Peter Wolf
Thanks for the lengthy reply Laurent, Replies in-line lpetit wrote: Peter, We asked us the same question some weeks ago, on clojuredev. We took the path to follow how eclipse launches a java application when the user requires it to test it. So we created a customized launch configuration

what when (some identity maps) mean?

2009-01-22 Thread wubbie
Hi, Here is def of merge: (defn merge [ maps] (when (some identity maps) (reduce #(conj (or %1 {}) %2) maps))) How can I interpret when (some identity maps)? Thanks -sun --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Re: Agent as a processing queue

2009-01-22 Thread e
wow. I wonder if I could use this for the quicksort I was talking about. I would need to have the function being added as a job be able to add it's own jobs recursively . . . .and kill jobs when they are done. But do you have to sleep, or is there a way to join the children when they are done?

Re: what when (some identity maps) mean?

2009-01-22 Thread Stuart Sierra
Hi, It means that some of the maps can be nil, but at least one of them has to be non-nil. some requires a predicate, but since nil is logical false, we can just use identity. Here's the behavior: user (merge nil nil nil) nil user (merge {:a 1} nil {:b 2}) {:b 2, :a 1} -Stuart

Re: Calling Clojure from Java (again)

2009-01-22 Thread Stuart Sierra
On Jan 22, 6:51 pm, Peter Wolf opus...@gmail.com wrote: However, if there is only one Clojure image used for references and the like, what happens if someone calls an infinite loop, or infinite recursion, in a file.  Does the Clojure server hang/blow up?   If you code an infinite loop, the

Re: Streams work

2009-01-22 Thread evins.mi...@gmail.com
On Jan 21, 1:33 pm, Rich Hickey richhic...@gmail.com wrote: I've started documenting the streams work I have been doing, for those interested: http://clojure.org/streams Feedback welcome, Rich This work reminds me in a general way of the old Dylan iteration protocol. They're not the

Re: Inheritance multiple inheritance using structs

2009-01-22 Thread evins.mi...@gmail.com
On Jan 19, 12:38 am, David Nolen dnolen.li...@gmail.com wrote: Of course it might be the case that not many people are interested in the implementing ideas from CLOS for Clojure It's definitely interesting. I'd like to have eql specializers and the ability to build hierarchies of arbitrary

Re: Agent as a processing queue

2009-01-22 Thread Mark H.
On Jan 22, 4:24 pm, e evier...@gmail.com wrote: At first, there will only be one thread for the first pass, but the number will grow as subtasks fire sub-sub tasks.  I am sure this is a silly way to sort because the threadspawning time is so much longer than the filtering time, but it's just

Any way we can get this in clojure-contrib?

2009-01-22 Thread Matt Moriarity
Under the suggestion of some people in the #clojure channel, I started working on a date library for Clojure since the built-in Java one is kind of a mess. It's not totally complete, but I think it could be quite useful. It supports getting the current date and time, and creating dates based on

Re: Any way we can get this in clojure-contrib?

2009-01-22 Thread Matt Moriarity
By the way, I'm in the process of sending in my contributor agreement. Just so you know :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com

Re: Inheritance multiple inheritance using structs

2009-01-22 Thread aria42
[sorry for duplicating content from the email i sent you David] Would anyone be interested in simplifying some of the boilerplate for defining methods in clojs? Currently you have to do this, (defclass circle [shape] (:radius 10)) (defmulti area :tag) (defmethod area ::circle [this] (*

Re: Any way we can get this in clojure-contrib?

2009-01-22 Thread Nick Vogel
That sounds interesting; you might take a look at Joda Timehttp://joda-time.sourceforge.net/. Although I've never used it myself, from what I've heard it's the Java library that people actually use for dates/times (I do know that Google uses it). Doing a quick search, it looks like Mark

Re: Any way we can get this in clojure-contrib?

2009-01-22 Thread Matt Moriarity
We discussed Joda Time, but it was decided that it wasn't a good idea to add another dependency, since this is something so integral to the language. I don't know what other people think, though. This was just an informal decision on #clojure. On Jan 23, 12:05 am, Nick Vogel voge...@gmail.com

updated pdf of clojure manual?

2009-01-22 Thread Korny Sietsma
Hi folks; Is there any way to get an updated dump of clojure.org as a pdf file? I like to print out stuff and read it on the train, and the clojure_manual.pdf available on the google groups site is a tad old, good for an introduction, but I'd like to read the bleeding edge stuff off-line. -