Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Mark Engelberg
On Fri, Nov 13, 2009 at 12:58 AM, Konrad Hinsen wrote: > Coming from a Python background, I don't think access restrictions are > necessary. However, flagging fields as "not meant for use by > outsiders" could be of interest for documentation tools, to make it > clear what client code can safely r

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 3:45 AM, Mark Engelberg wrote: > On Fri, Nov 13, 2009 at 12:58 AM, Konrad Hinsen > wrote: > > Coming from a Python background, I don't think access restrictions are > > necessary. However, flagging fields as "not meant for use by > > outsiders" could be of interest for doc

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-14 Thread ajuc
> > I would like to somehow hide the global hilbert-map into my function, > > but I can't see how to do that. > > Just put the literal directly into the function. > > > Is this possible? I know that I can just inert literal into my let, > > but that degrades performance, when function is called man

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Konrad Hinsen
On 13 Nov 2009, at 23:03, Stuart Sierra wrote: >> This example has maybe a problem : doesn't the symmetry of these >> Arithmetic operators seems to be crying for type multiple dispatch in >> this particular case ? :-) > > Yes, in the general case, arithmetic requires multimethods. But > multimeth

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Konrad Hinsen
On 14 Nov 2009, at 02:50, Mark Engelberg wrote: > together. So would it make sense for multimethods to be included as > part of protocols, or should there be some similar grouping system for > multimethods? The "old ideas/scratchpad" section of http://www.assembla.com/wiki/show/clojure/

why a defn- but not a def- ?

2009-11-14 Thread Mike Hogye
Why is there an easy way to def a private function (defn-), but no similarly easy way to def an arbitrary var as private? -- 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 fro

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Jonas Enlund
Hi there! I have built a simple Matrix datatype with defprotocol and deftype. You can take a look at it at http://gist.github.com/234535 (constructive criticism welcome!). Some simple examples are provided at the end of the file. I have a few questions. - Why must i write (matrix/Matrix ...) ins

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Konrad Hinsen
On 14 Nov 2009, at 09:45, Mark Engelberg wrote: > In general, I really hate it when it's difficult to tell what parts of > an API are the things that the end-user is really supposed to call, > and what part of the data you're supposed to access directly versus an > accessor method. It bugs me whe

Re: why a defn- but not a def- ?

2009-11-14 Thread Albert Cardona
On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye wrote: > Why is there an easy way to def a private function (defn-), but no > similarly easy way to def an arbitrary var as private? The way I see it, def- would encourage gratuitous variable declaration imperative style. By private var what one mean

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Rich Hickey
On Nov 14, 8:28 am, Jonas Enlund wrote: > Hi there! > > I have built a simple Matrix datatype with defprotocol and deftype. > You can take a look at it athttp://gist.github.com/234535 > (constructive criticism welcome!). Some simple examples are provided > at the end of the file. > > I have a fe

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Rich Hickey
On Nov 14, 1:32 am, cody koeninger wrote: > On Nov 13, 9:42 am, Sean Devlin wrote: > > > In this case, you provide the docs for each method after parameters. > > Would the following be possible: > > > (defprotocol AProtocol :on AnInterface > >   "A doc string for AProtocol abstraction" > >   (b

Idiomatic way to remove & in binding?

2009-11-14 Thread Sean Devlin
Hi, I recently was writing a macro that creates requires creating a worker fn, and the wrapping a worker fn with an adapter fn. The adapter fn is what I intend to have called. To give you an idea what's going on: user=>(doc my-fn) "This calls my-fn* to do some work, after my-fn calls a multimet

Multiarray design study

2009-11-14 Thread Konrad Hinsen
Following recent discussions on this list about how to work with multiarrays (n-dimensional arrays, data cubes) in Clojure, I have started a project on Google Code that is at the moment more of a design study than an implementation meant for use. It contains - a protocol definition for multi

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-14 Thread Wilson MacGyver
The server VM is part of the standard JDK. To use it you can either do java -server or set environment variable JAVA_OPS like this on linux/OSX export JAVA_OPTS="-server" On Sat, Nov 14, 2009 at 6:19 AM, ajuc wrote: >> > I would like to somehow hide the global hilbert-map into my function, >

Deep deref

2009-11-14 Thread André Thieme
I watched http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey and it is a very nice video. Rich mentioned around minute 9 to 10:05 a big problem: when some code gets handed data, can it be sure this thing is immutable? Clojure wants to help, because it encapsulates state in refs, which

Map a list of agents to a list of their values

2009-11-14 Thread Kevin Q
I have a list of agents, each of which has a hasmap state. I want to get a list of values from the list of agents, naturally I used the map function and print the result of the map: (println (map #(@%) agents)) However, when I run this, I got error "Wrong number of args passed to: PersistentHas

Re: Map a list of agents to a list of their values

2009-11-14 Thread Sean Devlin
Try (map deref agents) On Nov 14, 12:49 pm, Kevin Q wrote: > I have a list of agents, each of which has a hasmap state. I want to > get a list of values from the list of agents, naturally I used the map > function and print the result of the map: > > (println >   (map #(@%) agents)) > > However,

ExceptionInInitializerError in eval with user defined functions

2009-11-14 Thread gun43
Using r1366 under Win XP. A user defined function: 1:27 user=> (defn plus2 [x] (+ x 2)) #'user/plus2 1:28 user=> (plus2 5) 7 can only be eval'd 1:29 user=> (list plus2 5) (# 5) 1:30 user=> (eval (list plus2 5)) java.lang.ExceptionInInitializerError (repl-1:30) when passed with #' 1:31 user=> (li

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread Richard Newman
> I don't really care how strictly the language *enforces* that > separation, but I think the ability to specify that separation is a > good thing. I'd go so far as to request that it does not enforce separation. I'm sure anyone who's spent enough time using Other People's Libraries has hit in

Re: why a defn- but not a def- ?

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 8:55 AM, Albert Cardona wrote: > On Fri, Nov 13, 2009 at 11:26 PM, Mike Hogye > wrote: > > Why is there an easy way to def a private function (defn-), but no > > similarly easy way to def an arbitrary var as private? > > > The way I see it, def- would encourage gratuitous

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 6:19 AM, ajuc wrote: > > > I would like to somehow hide the global hilbert-map into my function, > > > but I can't see how to do that. > > > > Just put the literal directly into the function. > > > > > Is this possible? I know that I can just inert literal into my let, > >

Re: Deep deref

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 11:42 AM, André Thieme wrote: > Dereferencing *persons* will result in: > {"Tina" #, > "Jeff" #, > "Karl" #} > Great so far. > > People can become friends, so we need > (defn add-friend [#^String person #^String friend] > (dosync >(let [p (get @*persons* person) >

Re: ExceptionInInitializerError in eval with user defined functions

2009-11-14 Thread Jarkko Oranen
On Nov 14, 8:08 pm, gun43 wrote: > Using r1366 under Win XP. r1366? From Subversion? That's ancient. Clojure moved to git ages ago; see http://github.com/richhickey/clojure > > A user defined function: > 1:27 user=> (defn plus2 [x] (+ x 2)) > #'user/plus2 > 1:28 user=> (plus2 5) > 7 > > can onl

Re: Multiarray design study

2009-11-14 Thread Rock
Great news Konrad! I'll be having a look as soon as possible, and I hope I can help out. Thank you! Rock On Nov 14, 3:54 pm, Konrad Hinsen wrote: > Following recent discussions on this list about how to work with   > multiarrays (n-dimensional arrays, data cubes) in Clojure, I have   > started

Re: Deep deref

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 2:11 PM, John Harrop wrote: > On Sat, Nov 14, 2009 at 11:42 AM, André Thieme < > splendidl...@googlemail.com> wrote: > >> Dereferencing *persons* will result in: >> {"Tina" #, >> "Jeff" #, >> "Karl" #} >> Great so far. >> >> People can become friends, so we need >> (defn

Re: Map a list of agents to a list of their values

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 12:49 PM, Kevin Q wrote: > I have a list of agents, each of which has a hasmap state. I want to > get a list of values from the list of agents, naturally I used the map > function and print the result of the map: > > (println > (map #(@%) agents)) > > However, when I run

Re: Deep deref

2009-11-14 Thread Danny Woods
André Thieme wrote: > How can we handle this situation? > Is it possible to implement a function “deep-deref” which works > as blindingly fast as deref does? > I find this very important, and this is of great practical relevance > for me. Please share your ideas Hi André, I had a similar issue wi

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-14 Thread ajuc
> Eeeuw. > > Was this with a Clojure literal in the let, or with a non-trivial > calculation using constants? The only difference is literal map of maps in let form. Full code here: http://clojure.pastebin.com/m17b8d69 I have to install java one more time, when I try to start java - server, I ge

Re: Map a list of agents to a list of their values

2009-11-14 Thread Kevin Q
Thanks! That works. However, why wouldn't (map #(@%) agents) work? On Nov 14, 1:01 pm, Sean Devlin wrote: > Try > > (map deref agents) > > On Nov 14, 12:49 pm, Kevin Q wrote: > > > I have a list of agents, each of which has a hasmap state. I want to > > get a list of values from the list of agen

Re: Map a list of agents to a list of their values

2009-11-14 Thread Kevin Q
Hi, Thanks for the hint. I tried (map deref agents) and it did work. I don't know if this is a bug? On Nov 14, 2:31 pm, John Harrop wrote: > On Sat, Nov 14, 2009 at 12:49 PM, Kevin Q wrote: > > I have a list of agents, each of which has a hasmap state. I want to > > get a list of values from the

Re: Datatypes and Protocols - early experience program

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 1:42 PM, Richard Newman wrote: > I like CL's package support for this kind of situation, where > unexported symbols can still be reached via foo::bar, at the cost of > an obvious "code smell". This suggests an alternate fix for the private functions in macros problem: 1

Re: local constants in functions or static locals/Hilbert curve in clojure (no images:)

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 3:03 PM, ajuc wrote: > I have to install java one more time, when I try to start java - > server, I get: > Error: no `server' JVM at `F:\Program Files\Java\jre6\bin\server > \jvm.dll > You need to use the one in F:\Program Files\Java\jdk6 instead. I'm surprised your IDE

Re: Map a list of agents to a list of their values

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 2:51 PM, Kevin Q wrote: > Hi, > Thanks for the hint. I tried (map deref agents) and it did work. I > don't know if this is a bug? Nah, it's just being really sneaky. > > (fn* [p1__6536] ((clojure.core/deref p1__6536))) > Even I didn't notice it before. There's an extr

Re: Map a list of agents to a list of their values

2009-11-14 Thread John Harrop
On Sat, Nov 14, 2009 at 3:24 PM, John Harrop wrote: > On Sat, Nov 14, 2009 at 2:51 PM, Kevin Q wrote: > >> Hi, >> Thanks for the hint. I tried (map deref agents) and it did work. I >> don't know if this is a bug? > > > Nah, it's just being really sneaky. > > >> > (fn* [p1__6536] ((clojure.core/

Re: with-command-line and empty/nil args list

2009-11-14 Thread Mike Hogye
Thanks! -- 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

Re: Deep deref

2009-11-14 Thread André Thieme
On 14 Nov., 20:22, John Harrop wrote: > On Sat, Nov 14, 2009 at 2:11 PM, John Harrop wrote: > > On Sat, Nov 14, 2009 at 11:42 AM, André Thieme < > > splendidl...@googlemail.com> wrote: > > >> Dereferencing *persons* will result in: > >> {"Tina" #, > >>  "Jeff" #, > >>  "Karl" #} > >> Great so far

Re: Deep deref

2009-11-14 Thread André Thieme
On 14 Nov., 20:32, Danny Woods wrote: > André Thieme wrote: > > How can we handle this situation? > > Is it possible to implement a function “deep-deref” which works > > as blindingly fast as deref does? > > I find this very important, and this is of great practical relevance > > for me. Please

ANN: Clojure API for AllegroGraph

2009-11-14 Thread Mike Hinchey
Franz Inc and I just put the AllegroGraph 3.2 Java API on github with my new Clojure API. The clojure is a wrapper of the java client, which is an implementation of openrdf/sesame. The wrapper is mostly to make it more idiomatic clojure so you don't have to deal with so many java classes, mutable

YAClojureBlog

2009-11-14 Thread Seth
As I spelunk through Clojure my experiences are being posted to http://blogs.foognostic.net/topics/code/clojure/. Recently, I have been implementing some basics of poker with the goal of playing it at the REPL. Any and all comments -- including scathing code reviews! -- would be very welcome. BTW,

Re: Clojure Web Libraries

2009-11-14 Thread ngocdaothanh
Hi Stuart, Can you elaborate on Restlet? After some short investigation I think it uses annotation but Clojure does not support it, so Clojure is not "Restlet-ready". Thanks On Jan 23, 1:44 am, Stuart Sierra wrote: > Hi Frank, > I'd also recommend looking atRestlet and

Re: Clojure Web Libraries

2009-11-14 Thread Stuart Sierra
The latest restlet versions use annotations. I stil use 1.1, which uses ordinary classes. I'm bothered by restlet's move to annotations, but hoefully the old API is still available. sent from my phone On Nov 14, 2009 10:58 PM, "ngocdaothanh" wrote: Hi Stuart, Can you elaborate on Restlet? Af

Re: Clojure Web Libraries

2009-11-14 Thread David Brown
>> On Jan 21, 4:39 pm, Frank 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. I spent a couple of days this week using Compojure both in anger, and fo