Re: better error messages > smaller stack traces

2011-03-03 Thread Daniel Werner
On 2 March 2011 09:32, Alan  wrote:
> '(apply + 1 1) would be how you create a list of those symbols.
> ('apply + 1 1) says "call the function 'apply with the arguments of +
> 1 and 1".

Note that this will still break at runtime because Integers are not seqable. :-)

You probably want either (apply + [1 1]) or (apply + 1 [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: Master worker pattern

2011-03-03 Thread Jeff Rose
I've used something along these lines in the past for a medical
imaging app.  We needed to pre-fetch images and possibly pre-process
them (filter, apply overlays) so that as a user was scrolling through
an image set it was smooth and they weren't waiting for images to be
processed.  The GUI handler thread would figure out what images were
supposed to lie just above and below the current viewport, then it
would put tasks onto a queue where worker threads would pull them off
and process them as fast as possible.

That's one example anyway.

On Mar 2, 10:56 pm, Jonathan Mitchem  wrote:
> At the risk of sounding incredibly uneducated about the matter (oh wait,
> it's true):
>
> What is the purpose/need/reason for this kind of architecture?  What can you
> do with it?  Where would you use it?  Why would you use it?
>
> Thanks,
> Jonathan

-- 
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: Serialising functions...

2011-03-03 Thread Alessio Stalla
On Wednesday, March 2, 2011 2:54:07 PM UTC+1, Jules wrote:
[snip]

> I don't have time to look at this any further today, but I think it is 
> looking promising if I can find a way to avoid class name collisions - 
> more hacking of clojure.lang I'm afraid :-( 
>
> Apologies for posting all the source code here - but I thought that it 
> would enable others to follow my track if interested. 
>

I didn't analyze your code in detail but I think you don't have a very clear 
idea of "class name collisions". I'll try to shed some light, in hope of 
helping you; sorry if I'm saying things you already know, or that do not 
apply to your specific case.

In the JVM, classes are not identified by name alone. The identifier of a 
class is a couple (name, classloader), where name is the fully qualified 
name of the class. You can have two classes with the very same name, 
provided that they are loaded by two separate classloaders.
To complicate matters further, classloaders do not exist in isolation but 
form a hierarchy (a tree). They typically work by delegation: each 
classloader first asks its parent, and attempts to load the class itself 
only if the parent can't find it - except for the system classloader, which 
has no parent; and except for classloaders that have been written without 
following the delegation principle (for example, in ABCL we don't use 
delegation within the classloader used to load our compiled functions; we 
used to do that, but the extra trip to the parent classloader with 
consequent ClassNotFoundException had a significant performance impact on 
JRockit).
So depending on the hierarchy, a given classloader might or might not be 
able to load its own version of a class when another classloader has loaded 
a class with the same name.

hth,
Alessio

-- 
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

processing a socket stream

2011-03-03 Thread finbeu
Hello!

I'm new to clojure and socket programming in particular and I kindly
ask you to help me a little bit in how to design my application  (all
this is still overwhelming). This is a task I gave me to have
something usefull while learning the clojure api:

The scenario is as follows:

I have a client application that connects to a server on a port, opens
a socket stream and pumps in a stream of xml data. This streams never
stops, but the protocol is simple,  key/value data. That's it.

1/ I want to write a server in clojure that accepts the connection
from this client application, parses the xml-input stream and builds a
cache with the key/values received from xml-parsing this stream.

2/ I want to start threads within my server that do some work (get
notified) each time the cache has new/updated items.

My naive approach is as follows:

1) use create-server to build the server that accepts the socket
connection
2) use an atom as the cache that gets updated by the input stream
handler/thread
3) use futures to start my working threads

But how do I notify my working threads that the cache was updated? Are
there some (clojure) patterns that I can use?

Also some boilerplate or examples would help me a lot to get
started! :-)

Thanks!

- Finn (finbeu)



-- 
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: Serialising functions...

2011-03-03 Thread Jules


Thanks, Alessio,

I did know this, but it is a welcome addition to the thread.

I reread my last posting and it was a bit confused - I've done a
little research in the Compiler class and can now clarify what I think
is happening.

Clojure 1.3.0-alpha4
user=> (type (fn []))
user$eval1$fn__2
user=>

Here I have created a new function and asked it for its class. Clojure
has emitted bytecode on the fly to implement this and packed this into
a Java Class. A Class has a name unique - as you pointed out - within
its ClassLoader, so to avoid name collisions, Clojure attempts to
create a unique name for the class. This is composed, amongst other
things from its namespace and RT.nextID() (I'm assuming RT = RunTime).

RT.nextID seems to start at 0 and allocate ids sequentially - lets
create another fn :

user=> (type (fn []))
user$eval5$fn__6
user=>

I suspect that the gap between 2 and 6 is due to other processes going
on behind the scenes which require ids, rather than some intentional
design - but haven't checked.

This all works fine in a single JVM - no two functions will end up
creating types with the same name - however if I take the class for a
function from [a ClassLoader in] one clojure runtime and copy it
across to another clojure runtime that has already allocated this
classes id to another [in the receiving ClassLoader] then I would see
a collision.

I think that this is what is happening above. I am serialising an
object in one jvm, putting it into a message and sending the message
to another jvm. Upon receipt I attempt to deserialise the object
contained in the message. This involves looking up its class by name
[within the scope of a ClassLoader] - but the name has already been
allocated to a local class [within the same ClassLoader] which is
mistakenly then used to try to deserialise the object. The object's
data is not presented in the format that the local class expects for
one of its own instances - hence the Exception in my posting above.

This is currently only theory.

I think that the easiest way to fix it is to use not just a jvm-local
uid as part of the class name, but also an id which uniquely
identifies this jvm amongst all the jvms involved in my cluster. It
looks like not too many classes make use of RT.nextID(), so I think my
next move will be to add an e.g. RT.jvmID and use this in conjunction
with RT.nextID(). If this resolves my problem then there is a good
chance that my supposition was correct - otherwise it is back to the
drawing board.

I'll try to make time to give this a whirl soon and report back.

Thanks,


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: processing a socket stream

2011-03-03 Thread James Reeves
On 3 March 2011 10:25, finbeu  wrote:
> But how do I notify my working threads that the cache was updated? Are
> there some (clojure) patterns that I can use?

Presumably you're starting your worker processes to avoid the overhead
of starting a new thread each time? In which case, a better solution
may be to use a thread pool instead.

- 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


Re: Serialising functions...

2011-03-03 Thread Alessio Stalla
On Thursday, March 3, 2011 11:46:03 AM UTC+1, Jules wrote:
>
>
>
> Thanks, Alessio, 
>
> I did know this, but it is a welcome addition to the thread. 
>

Ok. Classloaders are a tricky matter and many people don't have clear ideas 
about them - sorry for assuming you were one of those people :)
 

> I reread my last posting and it was a bit confused - I've done a 
> little research in the Compiler class and can now clarify what I think 
> is happening. 
>
> Clojure 1.3.0-alpha4 
> user=> (type (fn [])) 
> user$eval1$fn__2 
> user=> 
>
> Here I have created a new function and asked it for its class. Clojure 
> has emitted bytecode on the fly to implement this and packed this into 
> a Java Class. A Class has a name unique - as you pointed out - within 
> its ClassLoader, so to avoid name collisions, Clojure attempts to 
> create a unique name for the class. This is composed, amongst other 
> things from its namespace and RT.nextID() (I'm assuming RT = RunTime). 
>
> RT.nextID seems to start at 0 and allocate ids sequentially - lets 
> create another fn : 
>
> user=> (type (fn [])) 
> user$eval5$fn__6 
> user=> 
>
> I suspect that the gap between 2 and 6 is due to other processes going 
> on behind the scenes which require ids, rather than some intentional 
> design - but haven't checked. 
>
> This all works fine in a single JVM - no two functions will end up 
> creating types with the same name - however if I take the class for a 
> function from [a ClassLoader in] one clojure runtime and copy it 
> across to another clojure runtime that has already allocated this 
> classes id to another [in the receiving ClassLoader] then I would see 
> a collision. 
>
> I think that this is what is happening above. I am serialising an 
> object in one jvm, putting it into a message and sending the message 
> to another jvm. Upon receipt I attempt to deserialise the object 
> contained in the message. This involves looking up its class by name 
> [within the scope of a ClassLoader] - but the name has already been 
> allocated to a local class [within the same ClassLoader] which is 
> mistakenly then used to try to deserialise the object. The object's 
> data is not presented in the format that the local class expects for 
> one of its own instances - hence the Exception in my posting above. 
>
> This is currently only theory. 
>

Makes sense.
 

> I think that the easiest way to fix it is to use not just a jvm-local 
> uid as part of the class name, but also an id which uniquely 
> identifies this jvm amongst all the jvms involved in my cluster. It 
> looks like not too many classes make use of RT.nextID(), so I think my 
> next move will be to add an e.g. RT.jvmID and use this in conjunction 
> with RT.nextID(). If this resolves my problem then there is a good 
> chance that my supposition was correct - otherwise it is back to the 
> drawing board. 
>

I think a better option is to make sure that the classloader you use for 
deserializing is completely separated from the classloader Clojure uses to 
load compiled functions. Then, no possibility of collision exists, 
regardless of how you generate class names.

-- 
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: processing a socket stream

2011-03-03 Thread Miki


> But how do I notify my working threads that the cache was updated? Are 
> there some (clojure) patterns that I can use? 
>
> add-watch? (http://clojuredocs.org/clojure_core/clojure.core/add-watch) 

-- 
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: Serialising functions...

2011-03-03 Thread Jules

On Mar 3, 1:22 pm, Alessio Stalla  wrote:
> On Thursday, March 3, 2011 11:46:03 AM UTC+1, Jules wrote:
>
> > Thanks, Alessio,
>
> > I did know this, but it is a welcome addition to the thread.
>
> Ok. Classloaders are a tricky matter and many people don't have clear ideas
> about them - sorry for assuming you were one of those people :)
>
>
np :-)
>
>
>
> > I reread my last posting and it was a bit confused - I've done a
> > little research in the Compiler class and can now clarify what I think
> > is happening.
>
> > Clojure 1.3.0-alpha4
> > user=> (type (fn []))
> > user$eval1$fn__2
> > user=>
>
> > Here I have created a new function and asked it for its class. Clojure
> > has emitted bytecode on the fly to implement this and packed this into
> > a Java Class. A Class has a name unique - as you pointed out - within
> > its ClassLoader, so to avoid name collisions, Clojure attempts to
> > create a unique name for the class. This is composed, amongst other
> > things from its namespace and RT.nextID() (I'm assuming RT = RunTime).
>
> > RT.nextID seems to start at 0 and allocate ids sequentially - lets
> > create another fn :
>
> > user=> (type (fn []))
> > user$eval5$fn__6
> > user=>
>
> > I suspect that the gap between 2 and 6 is due to other processes going
> > on behind the scenes which require ids, rather than some intentional
> > design - but haven't checked.
>
> > This all works fine in a single JVM - no two functions will end up
> > creating types with the same name - however if I take the class for a
> > function from [a ClassLoader in] one clojure runtime and copy it
> > across to another clojure runtime that has already allocated this
> > classes id to another [in the receiving ClassLoader] then I would see
> > a collision.
>
> > I think that this is what is happening above. I am serialising an
> > object in one jvm, putting it into a message and sending the message
> > to another jvm. Upon receipt I attempt to deserialise the object
> > contained in the message. This involves looking up its class by name
> > [within the scope of a ClassLoader] - but the name has already been
> > allocated to a local class [within the same ClassLoader] which is
> > mistakenly then used to try to deserialise the object. The object's
> > data is not presented in the format that the local class expects for
> > one of its own instances - hence the Exception in my posting above.
>
> > This is currently only theory.
>
> Makes sense.
>
> > I think that the easiest way to fix it is to use not just a jvm-local
> > uid as part of the class name, but also an id which uniquely
> > identifies this jvm amongst all the jvms involved in my cluster. It
> > looks like not too many classes make use of RT.nextID(), so I think my
> > next move will be to add an e.g. RT.jvmID and use this in conjunction
> > with RT.nextID(). If this resolves my problem then there is a good
> > chance that my supposition was correct - otherwise it is back to the
> > drawing board.
>
> I think a better option is to make sure that the classloader you use for
> deserializing is completely separated from the classloader Clojure uses to
> load compiled functions. Then, no possibility of collision exists,
> regardless of how you generate class names.- Hide quoted text -
>
> - Show quoted text -

That's an interesting idea, that I haven't really pursued, I think,
OTOH, because client-side, I think that I want to be able to mix
objects that herald from both local and remote jvms... - but this is
just a gut feeling, I haven't really looked for any concrete usecases
in any detail, so I'll give your suggestion consideration and see
whether it would fit the bill.

Using your approach would also be a good way of checking that my
assumption about the name collision was correct, so I may see if I can
set up my code to use a different ClassLoader in which to deserialise
to see if that solves my problem.

Thanks for this idea, it may help me a lot :-)


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: processing a socket stream

2011-03-03 Thread finbeu
With my limited clojure skills I just managed to get the create-server
up and running :-)

Now I found out that I don't know how to do the following thing (sorry
for my beginner questions):

The stream arrives with a sequence of 10 characters. These 10
characters  (e.g. 000190) give me the exact size (190 characters)
of the next full xml-message. So I have to read 10 characters first,
then the  subsequent 190 characters which give me the xml-message, and
so on and so forth

But I have right now no clue to do this (navigating to the stream
forth by a fixed number of bytes). Is there a clojure function to do
this or do I have to fall back to java?

Thanks.


On 3 Mrz., 11:25, finbeu  wrote:

> 1/ I want to write a server in clojure that accepts the connection
> from this client application, parses the xml-input stream and builds a
> cache with the key/values received from xml-parsing this stream.
>

-- 
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 on JS VMs

2011-03-03 Thread Timothy Baldridge
I know we have Scriptjure. But has there been any concentrated effort
to port Clojure to JS? This may sound odd, but personally I would love
to use Clojure in the browser. Scriptjure would work fairly well, but
from what I see, it doesn't support persistent maps and instead relies
on JS objects.

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: processing a socket stream

2011-03-03 Thread James Reeves
On 3 March 2011 14:39, finbeu  wrote:
> But I have right now no clue to do this (navigating to the stream
> forth by a fixed number of bytes). Is there a clojure function to do
> this or do I have to fall back to java?

You're better off falling back to Java for this. Clojure doesn't yet
have a native mechanism for handling streaming data, so the standard
Java stream classes are generally used when dealing with I/O.

However, there are a bunch of helper functions in clojure.java.io that
you'll definitely want to use.

Once you have your stream, you probably want a function like:

(defn read-bytes [stream n]
  (let [bytes (byte-array n)]
(.read stream bytes)
bytes))

And then turn it into a string with:

  (String. bytes "UTF-8")

- 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


Re: Clojure on JS VMs

2011-03-03 Thread Joost
On Mar 3, 3:56 pm, Timothy Baldridge  wrote:
> I know we have Scriptjure. But has there been any concentrated effort
> to port Clojure to JS? This may sound odd, but personally I would love
> to use Clojure in the browser. Scriptjure would work fairly well, but
> from what I see, it doesn't support persistent maps and instead relies
> on JS objects.

Not as far as I know. Scripture is extremely limited; it's only a lisp-
like wrapper on basic javascript that just happens to have names like
clojure's. For instance, there's not even "real" (if ), (let ..),
no automatic returns etc.

Its possible to do a real port of clojure that sort of does the basics
right, but that would be a lot more involved than just translating
source code.

Joost.


-- 
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 on JS VMs

2011-03-03 Thread James Reeves
On 3 March 2011 14:56, Timothy Baldridge  wrote:
> I know we have Scriptjure. But has there been any concentrated effort
> to port Clojure to JS? This may sound odd, but personally I would love
> to use Clojure in the browser. Scriptjure would work fairly well, but
> from what I see, it doesn't support persistent maps and instead relies
> on JS objects.

Persistent maps would be pretty tricky to support in Javascript. I
don't think there's any way of supporting them that wouldn't result in
a significant performance impact, because you'd have to build them on
top of the native mutable maps.

- 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


Re: processing a socket stream

2011-03-03 Thread finbeu
James thx. That is what I need for my project: Some coaching when to
fall back to java, when to use clojure function and so on. That's
cool.

Rgds

- Finn

On 3 Mrz., 15:59, James Reeves  wrote:
> On 3 March 2011 14:39, finbeu  wrote:
>
> > But I have right now no clue to do this (navigating to the stream

> You're better off falling back to Java for this. Clojure doesn't yet

-- 
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: Swank fix for slime cvs

2011-03-03 Thread Fred Concklin
You should patch and send upstream. 

fpc

-- 
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 on JS VMs

2011-03-03 Thread Chouser
On Thu, Mar 3, 2011 at 9:56 AM, Timothy Baldridge  wrote:
> I know we have Scriptjure. But has there been any concentrated effort
> to port Clojure to JS? This may sound odd, but personally I would love
> to use Clojure in the browser. Scriptjure would work fairly well, but
> from what I see, it doesn't support persistent maps and instead relies
> on JS objects.

There has been, but it's extremely out of date at this point:

https://github.com/clojure/clojure-contrib/tree/master/clojurescript

That's a pre-1.0 version of Clojure that does indeed compile to
JavaScript.  It supports persistent hash maps and vectors
(pre-transients), lazy sequences (actually, lazy-con, pre-chunking),
and most of the clojure.core functions.  There's no attempt to support
Clojure's concurrency constructs, and it relies on the Java-based
compiler rather than having a port of the compiler itself to
JavaScript.

I gave up trying to hand-port all the features from the Java half of
Clojure's implementation over to JavaScript, with the hope that when
we eventually have clojure-in-clojure this task would be significantly
easier.

You can even try it out in a browser (doesn't work on Macs, I think):
http://clojurescript.n01se.net/

That loads the clojure-to-javascript compiler as a Java applet, after
which you can run Clojure commands in the browser, like:

(-> document .body)

or:

(set! (-> document .body .style .background) "orange")

I'm sorry it's too out of date to be of much real use now, but it does
show it's possible and hopefully has some tidbits that will be useful
in later implementations.

--Chouser
http://joyofclojure.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


Re: Master worker pattern

2011-03-03 Thread Zlatko Josic
My company have made system based on some kind of such architecture.
It is parkng service for cites. You have parts of some streets where parking
is allowed. That parts have name and phone number. For example
Zone 1 and 9111. People use mobile phones for pay parking.
They send sms message to 9111 number.

System have components that read sms messsages from mobile operaters
and put them in some queue. Master reads messages from queue and give
them to workers for execution. Messages are processed in parallel and it is
most important. Processing one message does not depepend on another.

Even more you can have lot of diffrent computers with workers that process
messages.


Zlaja

On Thu, Mar 3, 2011 at 9:42 AM, Jeff Rose  wrote:

> I've used something along these lines in the past for a medical
> imaging app.  We needed to pre-fetch images and possibly pre-process
> them (filter, apply overlays) so that as a user was scrolling through
> an image set it was smooth and they weren't waiting for images to be
> processed.  The GUI handler thread would figure out what images were
> supposed to lie just above and below the current viewport, then it
> would put tasks onto a queue where worker threads would pull them off
> and process them as fast as possible.
>
> That's one example anyway.
>
> On Mar 2, 10:56 pm, Jonathan Mitchem  wrote:
> > At the risk of sounding incredibly uneducated about the matter (oh wait,
> > it's true):
> >
> > What is the purpose/need/reason for this kind of architecture?  What can
> you
> > do with it?  Where would you use it?  Why would you use it?
> >
> > Thanks,
> > Jonathan
>
> --
> 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

jME3 and Clojure

2011-03-03 Thread Dustin Withers
Hello All,

In case there is any interest I took the time to figure out the
correct repositories and dependencies to get the jME3 tutorial app to
work. I've posted about it here:
http://7sudos.com/blog/clojure-jme3

Regards,
-dustin

-- 
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: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Sam Ritchie
I'd like to bump this, with the question rephrased:

Is there a way to call commands from a JVM process's REPL in any way other
than pasting it in to that REPL? Specifically, is there a way to tell an
active REPL to re-enter its current namespace?

On Tue, Mar 1, 2011 at 8:50 AM, Sam Ritchie  wrote:

> Hey all -- quick question on the REPL. I'm an emacs user, but my two
> teammates have been working with the excellent 
> textmate-clojure,
> and it's exposed an issue that I'm not sure how to deal with.
>
> The bundle provides a command to load the current file active in textmate,
> by running (load-file tm-filepath) within cake's JVM. So, the textmate
> workflow is
>
> 1. Open the project in textmate
> 2. Run "cake repl" in the command line
> 3. switch back and forth, loading files or eval-ing functions in textmate,
> and seeing them appear in the cake repl.
>
> Here's the load file  source code.
>
> Now, if I'm working in a namespace in the REPL, modify a current function,
> and load the file, those changes appear right away in the REPL. However, If
> I bind a new var in the file and load it, I get the following:
>
> java.lang.Exception: Unable to resolve symbol: testsymbol in this context
> (NO_SOURCE_FILE:0)
>
> Running (in-ns 'the.namespace), or even (in-ns (ns-name *ns*)), fixes the
> problem right away, and subsequent modifications are picked up with
> load-file, as long as I don't change the symbol name.
>
> This happens with the textmate workflow, but I can confirm that running
> (load-file "/path/to/file.clj") when it that current file's namespace
> doesn't register new vars.
>
> My question is -- why do existing functions catch modifications from
> load-file, while new vars need me to re-enter the namespace? Also, does
> anyone have any suggestions on how to modify the load 
> file code
> to force cake's repl to run (in-ns (ns-name *ns*)), without actually being
> at the REPL? Is there some way to run a command, not just in the current
> file's namespace, but at the current REPL?
>
> Thanks, all,
> Sam
>
>
>

-- 
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: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread David Nolen
On Thu, Mar 3, 2011 at 12:39 PM, Sam Ritchie  wrote:

> I'd like to bump this, with the question rephrased:
>
> Is there a way to call commands from a JVM process's REPL in any way other
> than pasting it in to that REPL? Specifically, is there a way to tell an
> active REPL to re-enter its current namespace?
>

Sam,

Sorry I haven't been focusing much on textmate-clojure lately and don't plan
on doing so in the near future (though very open to taking patches). What do
you mean by "bind a new var in a file and load it?" Can you give me the
exact set of steps to recreate the issue? There's a textmate-clojure Google
Group as well.

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

using records in Java

2011-03-03 Thread Earl J. Wagner
Hi all,

I'm running into a problem with Java code using records defined in
Clojure (1.2.0) code.

Here's the Clojure code:
(ns t.core
  (:gen-class))
(defrecord TRecord [a b c])
(compile 't.core)

I run Lein (1.3) to compile this and generate a jar file. Inside the
jar file I see an entry for the record class:
t/core/TRecord.class

Then I try to compile Java code to use it:

import java.lang.reflect.Method;
import t.core;
import t.core.TRecord;

class Main {
public static void main (String [] args) {
try {
Class trClass = Class.forName ("t.core.TRecord");
System.out.println ("trClass: " + trClass);
Method trMethods [] = trClass.getDeclaredMethods ();
for (Method trMethod : trMethods) {
System.out.println ("trMethod: " + trMethod);
}
} catch (Exception e) {
e.printStackTrace ();
}
}
}

Attempting to compile this with the jar in the classpath produces a
"cannot find symbol" error for the TRecord class. It does however
compile with the last import line commented out, and when run this
successfully prints out the name of the class and its methods.

I'd like to just import the TRecord class, and instantiate and use
TRecord objects. Any idea what I'm missing here?

Thanks for any help with this.

-Earl

-- 
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: Master worker pattern

2011-03-03 Thread Jonathan Mitchem
So, fundamentally, it's an architecture for dealing with "trivially 
parallel" problems?  Would that be an accurate summary?

(Not to imply your problems are trivial.)

-- 
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: using records in Java

2011-03-03 Thread Aaron Cohen
On Wed, Mar 2, 2011 at 11:38 PM, Earl J. Wagner wrote:

>
> Then I try to compile Java code to use it:
>
> import java.lang.reflect.Method;
> import t.core;
> import t.core.TRecord;
>


> Attempting to compile this with the jar in the classpath produces a
> "cannot find symbol" error for the TRecord class. It does however
> compile with the last import line commented out, and when run this
> successfully prints out the name of the class and its methods.
>

Are you sure that the "Cannot find symbol" error is referring to the line
"import t.core.TRecord;"?

I'm pretty sure the line before that: "import t.core;" is invalid, you can't
import a package in Java (you could do "import t.core.*" if you wanted
though).

--Aaron

-- 
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: Master worker pattern

2011-03-03 Thread Zlatko Josic
It is most suitable for parallel processing where you have lot of tasks that
can be independently processed.
If your tasks have shared states things are going to be more complicated.
Fortunately this is changed
with languages like Scala/Clojure. In both you have STM(Software transaction
memory ) approach
for writing application that share states.


Zlaja

On Thu, Mar 3, 2011 at 7:46 PM, Jonathan Mitchem  wrote:

> So, fundamentally, it's an architecture for dealing with "trivially
> parallel" problems?  Would that be an accurate summary?
>
> (Not to imply your problems are trivial.)
>
> --
> 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: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Daniel Solano Gomez
On Thu Mar  3 09:39 2011, Sam Ritchie wrote:
> Is there a way to call commands from a JVM process's REPL in any way other
> than pasting it in to that REPL? Specifically, is there a way to tell an
> active REPL to re-enter its current namespace?

I'm not sure if this answers your question, but have you looked at the
:reload and :reload-all arguments to the use and require functions?

One caveat to using these: they will load any new definitions, but they
do not remove any old definitions.

Sincerely,

Daniel Solano Gómez


pgpr7CwotVHv1.pgp
Description: PGP signature


Re: using records in Java

2011-03-03 Thread Daniel Solano Gomez
On Thu Mar  3 13:48 2011, Aaron Cohen wrote:
> On Wed, Mar 2, 2011 at 11:38 PM, Earl J. Wagner 
> wrote:
> 
> >
> > Then I try to compile Java code to use it:
> >
> > import java.lang.reflect.Method;
> > import t.core;
> > import t.core.TRecord;
> >
> > Attempting to compile this with the jar in the classpath produces a
> > "cannot find symbol" error for the TRecord class. It does however
> > compile with the last import line commented out, and when run this
> > successfully prints out the name of the class and its methods.
> >
> 
> Are you sure that the "Cannot find symbol" error is referring to the line
> "import t.core.TRecord;"?
> 
> I'm pretty sure the line before that: "import t.core;" is invalid, you can't
> import a package in Java (you could do "import t.core.*" if you wanted
> though).

Well, t.core exists because in his ns declaration he included
:gen-class.  Now, this isn't necessary for compiling records.  As for
why it isn't compiling, I am not sure.  I tried replicating the problem
(albiet without Leiningen), but was unable to.

Here is the code I used:

t/core.clj:

(ns t.core)

(defrecord TRecord [a b c])

(compile 't.core)

---

Main.java:

import t.core.TRecord;

public class Main {
public static void main(String[] args) {
System.out.println(new TRecord(1,2,3));
}
}



Sincerely,

Daniel Solano Gómez


pgpV5NxLCfRGU.pgp
Description: PGP signature


Re: using records in Java

2011-03-03 Thread Aaron Cohen
On Thu, Mar 3, 2011 at 2:24 PM, Daniel Solano Gomez wrote:

> On Thu Mar  3 13:48 2011, Aaron Cohen wrote:
> > On Wed, Mar 2, 2011 at 11:38 PM, Earl J. Wagner <
> dont.spam.e...@gmail.com>wrote:
>
> Well, t.core exists because in his ns declaration he included
> :gen-class.  Now, this isn't necessary for compiling records.  As for
> why it isn't compiling, I am not sure.  I tried replicating the problem
> (albiet without Leiningen), but was unable to.
>

Hmm, it's illegal to have a class name that collides with a package name,
isn't it? If :gen-class creates a class named "t.core", then you won't be
able to have a record named "t.core.TRecord", at least not in a way that
actually works consistantly. Clojure should probably prevent this from
compiling.

For reference: https://bugs.eclipse.org/bugs/show_bug.cgi?id=63668

-- 
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: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Sam Ritchie
David, not a problem! I was trying to put together a patch, but stumbled on
this one issue, and figured the clojure list might be able to help out with
the more general question, here.

Exact steps:

   1. Open textmate project
   2. run "cake repl" at a terminal, inside the project directory
   3. Navigate to, say, test/namespace.clj, and press Shift-Command-L to
   load the file. "Loading Finished!" should pop up.
   4. In the terminal, run (in-ns 'test.namespace). This gets me into the
   namespace, and gives me access to all current definitions... say,
   (def test-string "test!")

Now, if I change that line to (def test-string "test again!"), reload the
file, and type test-string into the repl, I see "test again!". So, changing
a currently defined var "catches".

But! If I change the line to (def test-string2 "test!"), load the file, and
type test-string2 at the repl, I get an error noting that the var isn't
bound. After running (in-ns 'test.namespace) again, test-string2 returns
"test!".

The textmate-clojure code uses "cake run" to call "load-file" on the current
active file in textmate, as you of course know. The problem seems to be that
load-file isn't making new defs available to the current repl, even though
it can successfully update currently bounds defs. I'm looking for a way to
write a patch that forces (in-ns (ns-name *ns*)) to run inside the current
repl, whenever the user presses shift-command-L, getting around this issue.

(I've also found that (require 'test.playground :reload) and (require
'test.playground :reload-all) have no effect. Only the in-ns call works.)

Sorry about the length, here! The issue applies without textmate-clojure in
the loop -- substitute a call to load-file for the shift-command-L business.

Best,
Sam

On Thu, Mar 3, 2011 at 9:55 AM, David Nolen  wrote:

> On Thu, Mar 3, 2011 at 12:39 PM, Sam Ritchie  wrote:
>
>> I'd like to bump this, with the question rephrased:
>>
>> Is there a way to call commands from a JVM process's REPL in any way other
>> than pasting it in to that REPL? Specifically, is there a way to tell an
>> active REPL to re-enter its current namespace?
>>
>
> Sam,
>
> Sorry I haven't been focusing much on textmate-clojure lately and don't
> plan on doing so in the near future (though very open to taking patches).
> What do you mean by "bind a new var in a file and load it?" Can you give me
> the exact set of steps to recreate the issue? There's a textmate-clojure
> Google Group as well.
>
> 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: easier exit

2011-03-03 Thread rogerdpack


On Feb 25, 9:43 am, Stuart Halloway  wrote:
> > Hello all. A bit new to clojure here.  Anyway I found it a bit
> > difficult to exit from a REPL.
> > Would a patch to make it give instructions (like Python's
>
> > C:\>c:\installs\Python26\python.exe
>  exit
> > Use exit() or Ctrl-Z plus Return to exit
>
> > )
>
> > like that have a chance to be accepted?
>
> Hi Roger,
>
> Thanks for asking--it is always good to start on the mailing list before 
> going to the trouble of making a patch. A REPL exit patch would not be 
> accepted, for the following reasons:
>
> (1) The problem, and its solution, are far from clear and compelling. 
> Python's approach to this is not universally hailed as a good one.

I believe the "problem" in this case is that typically, one types exit
to exit a shell (bash, ruby, python [warns you that this doesn't
work]). This is quite convenient for newcomers (and no other shell
that I'm aware of, in windows, requires a ctrl+d or ctrl+z to exit).
Cheers!
-r

-- 
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: easier exit

2011-03-03 Thread rogerdpack

> > Also is there any way to contribute patches to the clojure website
> > itself? (maybe put it up on github too?)
>
> Instructions on the patch process are 
> athttp://dev.clojure.org/display/design/JIRA+workflow.  Issues waiting for 
> patches are 
> athttp://dev.clojure.org/jira/secure/IssueNavigator.jspa?mode=hide&requ

I was referring to patches against the text of http://clojure.org/
itself is that patchable somewhere?
Cheers!
-r

-- 
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: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread David Nolen
On Thu, Mar 3, 2011 at 4:12 PM, Sam Ritchie  wrote:

> David, not a problem! I was trying to put together a patch, but stumbled on
> this one issue, and figured the clojure list might be able to help out with
> the more general question, here.
>
> Exact steps:
>
>1. Open textmate project
>2. run "cake repl" at a terminal, inside the project directory
>3. Navigate to, say, test/namespace.clj, and press Shift-Command-L to
>load the file. "Loading Finished!" should pop up.
>4. In the terminal, run (in-ns 'test.namespace). This gets me into the
>namespace, and gives me access to all current definitions... say,
>(def test-string "test!")
>
> Now, if I change that line to (def test-string "test again!"), reload the
> file, and type test-string into the repl, I see "test again!". So, changing
> a currently defined var "catches".
>
> But! If I change the line to (def test-string2 "test!"), load the file, and
> type test-string2 at the repl, I get an error noting that the var isn't
> bound. After running (in-ns 'test.namespace) again, test-string2 returns
> "test!".
>
> The textmate-clojure code uses "cake run" to call "load-file" on the
> current active file in textmate, as you of course know. The problem seems to
> be that load-file isn't making new defs available to the current repl, even
> though it can successfully update currently bounds defs. I'm looking for a
> way to write a patch that forces (in-ns (ns-name *ns*)) to run inside the
> current repl, whenever the user presses shift-command-L, getting around this
> issue.
>
> (I've also found that (require 'test.playground :reload) and (require
> 'test.playground :reload-all) have no effect. Only the in-ns call works.)
>
> Sorry about the length, here! The issue applies without textmate-clojure in
> the loop -- substitute a call to load-file for the shift-command-L business.
>
> Best,
> Sam
>

Thanks for the detailed description. Will look into it.

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

Writing a generic function for getting any value for a key

2011-03-03 Thread HB
Hi,

I'm trying to write a function that gets the value for a key of a map.

(def *places* {:room "Nice room"
:basement "what ever"})

(defn describe-place [place places]
   (places place))

(describe-place :room *places*)

Of course it isn't running :)
What should I do?
Thanks for help and time.

-- 
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: load-file, and new function definitions not catching at the REPL

2011-03-03 Thread Lee Spector

On Mar 3, 2011, at 5:53 PM, David Nolen wrote:
> 
> Thanks for the detailed description. Will look into it.
> 
> David

FWIW I posted this as issue #13 on the textmate-clojure github site some time 
back, and Sam provided some confirmation there. I'd love to use 
textmate-clojure regularly but this foils my normal workflow. There are some 
other significant issues posted too... but also a lot of promise in this 
project, I think, so I hope that someone with the right skills can take this 
on...

Thanks,

 -Lee

-- 
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: Writing a generic function for getting any value for a key

2011-03-03 Thread Ken Wesson
On Thu, Mar 3, 2011 at 8:33 PM, HB  wrote:
> Hi,
>
> I'm trying to write a function that gets the value for a key of a map.
>
> (def *places* {:room "Nice room"
>                    :basement "what ever"})
>
> (defn describe-place [place places]
>   (places place))
>
> (describe-place :room *places*)
>
> Of course it isn't running :)

Works for me. *shrug*

-- 
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: Writing a generic function for getting any value for a key

2011-03-03 Thread Alan
Copied and pasted straight from your post to my REPL it works fine.
Maybe verify that you're actually doing what you think you're doing?

That said, this function already exists: it's called get.

user=> (def *places* {:room "Nice room"
   :basement "what ever"})
#'user/*places*
user=> (defn describe-place [place places]
  (places place))
#'user/describe-place
user=> (describe-place :room *places*)
"Nice room"
user=> (get *places* :room)
"Nice room"

On Mar 3, 5:33 pm, HB  wrote:
> Hi,
>
> I'm trying to write a function that gets the value for a key of a map.
>
> (def *places* {:room "Nice room"
>                     :basement "what ever"})
>
> (defn describe-place [place places]
>    (places place))
>
> (describe-place :room *places*)
>
> Of course it isn't running :)
> What should I do?
> Thanks for help and time.

-- 
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: Writing a generic function for getting any value for a key

2011-03-03 Thread .Bill Smith
I'm not sure what you want describe-place to do, but you don't need a new 
function to get the value for a key of a map.

user=> (def *places* {:room "Nice room" :basement "what ever"}) 
#'user/*places*
user=> (:room *places*)
"Nice room"
user=> (*places* :room)
"Nice room"
user=> (:basement *places*)
"what ever"
user=> (*places* :basement)
"what ever"
user=> 


-- 
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

Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Dear Clojure Group,

I am currently reading the online book Pro 
Git.
 
In chapter 7.4  (section “Enforcing a 
User-Based ACL System”) there is a task of reading in an access control list 
(ACL) file, such as the following

# avail/unavail | users | path
avail|nickh,pjhyett,defunkt,tpw
avail|usinclair,cdickens,ebronte|doc
avail|schacon|lib
avail|schacon|tests

and printing out a map of the form { "user1" [path 1, path 2], "user2" 
[path2, path3] ...}.

The author of the book provides a solution in Ruby, which I find relatively 
easy to follow, despite not having written any Ruby code before:

def get_acl_access_data(acl_file)
 # read in ACL data
 acl_file = File.read(acl_file).split("\n").reject { |line| line == '' }
 access = {}
 acl_file.each do |line|
   avail, users, path = line.split('|')
   next unless avail == 'avail'
   users.split(',').each do |user|
 access[user] ||= []
 access[user] << path
   end
 end
 access
end

I then tried the same in Clojure, but found my solution to be much less 
readable compared to the Ruby code:

(use '[clojure.string :only (split)])

(defn get-acl-access-data [file]
 (let [acl (split (slurp file) #"\n")]
   (apply merge-with #(into %1 %2)
 (map (fn [[avail users path]]
 (let [users (split users #",")]
(reduce (fn [acc user]
(when (= avail "avail")
  (assoc acc user [path])))
   {} users)))
   (map #(split % #"\|") acl)

;; Output:
;; {"schacon" ["lib" "tests"], 
;;  "usinclair" ["doc"], 
;;  "cdickens" ["doc"], 
;;  "ebronte" ["doc"], 
;;  "tpw" [nil], 
;;  "defunkt" [nil], 
;;  "pjhyett" [nil], 
;; "nickh" [nil]}

Maybe it is just because I am still a beginner, but I am afraid I won’t be 
able to figure out immediately what this code is doing a few weeks from now.

However, I am sure there must be a better way of translating the Ruby 
version into Clojure. My main goal is on clarity, as I often struggle 
organizing my code in a way I would consider readable.

I therefore would be glad for any ideas of improvement. Any suggestions are 
highly welcome!

Best regards,

Stefan

-- 
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: Writing a generic function for getting any value for a key

2011-03-03 Thread HB
Yes indeed, it runs on my REPL too!
However, if I save the code to a file and try to run it, I got this
exception:

Exception in thread "main" java.lang.IllegalArgumentException: Wrong
number of args (1) passed to: user$describe-location (wizard-game.clj:
0)


On Mar 4, 3:59 am, Alan  wrote:
> Copied and pasted straight from your post to my REPL it works fine.
> Maybe verify that you're actually doing what you think you're doing?
>
> That said, this function already exists: it's called get.
>
> user=> (def *places* {:room "Nice room"
>                            :basement "what ever"})
> #'user/*places*
> user=> (defn describe-place [place places]
>           (places place))
> #'user/describe-place
> user=> (describe-place :room *places*)
> "Nice room"
> user=> (get *places* :room)
> "Nice room"
>
> On Mar 3, 5:33 pm, HB  wrote:
>
>
>
> > Hi,
>
> > I'm trying to write a function that gets the value for a key of a map.
>
> > (def *places* {:room "Nice room"
> >                     :basement "what ever"})
>
> > (defn describe-place [place places]
> >    (places place))
>
> > (describe-place :room *places*)
>
> > Of course it isn't running :)
> > What should I do?
> > Thanks for help and time.

-- 
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


Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Dear Clojure Group,

I am currently reading the online book Pro Git . In 
chapter 7.4  (section “Enforcing a 
User-Based ACL System”) there is a task of reading in an access control list 
(ACL) file, such as the following

# avail/unavail | users | path
avail|nickh,pjhyett,defunkt,tpw
avail|usinclair,cdickens,ebronte|doc
avail|schacon|lib
avail|schacon|tests

and printing out a map of the form { "user1" [path 1, path 2], "user2" 
[path2, path3] ...}.

The author of the book provides a solution in Ruby, which I find relatively 
easy to follow, despite not having written any Ruby code before:

def get_acl_access_data(acl_file)
 # read in ACL data
 acl_file = File.read(acl_file).split("\n").reject { |line| line == '' }
 access = {}
 acl_file.each do |line|
   avail, users, path = line.split('|')
   next unless avail == 'avail'
   users.split(',').each do |user|
 access[user] ||= []
 access[user] << path
   end
 end
 access
end

I then tried the same in Clojure, but found my solution to be much less 
readable compared to the Ruby code:

(use '[clojure.string :only (split)])

(defn get-acl-access-data [file]
 (let [acl (split (slurp file) #"\n")]
   (apply merge-with #(into %1 %2)
 (map (fn [[avail users path]]
 (let [users (split users #",")]
(reduce (fn [acc user]
(when (= avail "avail")
  (assoc acc user [path])))
   {} users)))
   (map #(split % #"\|") acl)

;; Output:
;; {"schacon" ["lib" "tests"], 
;;  "usinclair" ["doc"], 
;;  "cdickens" ["doc"], 
;;  "ebronte" ["doc"], 
;;  "tpw" [nil], 
;;  "defunkt" [nil], 
;;  "pjhyett" [nil], 
;; "nickh" [nil]}

Maybe it is just because I am an ambitious beginner at best, but I am afraid 
I won’t be able to figure out immediately what this code is doing in a few 
weeks.

However, there probably is a better way of translating the Ruby version into 
Clojure. With "better" I mean easier to follow. My main goal is on clarity, 
as I often struggle organizing my code in a way I would consider readable.

I therefore would be glad for any ideas of improvement. Any suggestions are 
highly welcome!

Best regards,

Stefan

-- 
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: CLR classpath

2011-03-03 Thread Timothy Pratley
On Wed, Mar 2, 2011 at 8:39 AM, dmiller  wrote:
> (1)  I think the copy solution is the easiest.

Ok sounds good


> (2)  I'll have to look at the ambiguous match problem.

User error on my part; I figured out that mixing .NET versions is
bad... switch to compiled from source and it is working beautifully
now.


Thanks!


Regards,
Timothy

-- 
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: Writing a generic function for getting any value for a key

2011-03-03 Thread HB
Sorry, it is:

Exception in thread "main" java.lang.IllegalArgumentException: Wrong
number of args (1) passed to: user$describe-place (wizard-game.clj:
0)

On Mar 4, 4:12 am, HB  wrote:
> Yes indeed, it runs on my REPL too!
> However, if I save the code to a file and try to run it, I got this
> exception:
>
> Exception in thread "main" java.lang.IllegalArgumentException: Wrong
> number of args (1) passed to: user$describe-location (wizard-game.clj:
> 0)
>
> On Mar 4, 3:59 am, Alan  wrote:
>
>
>
> > Copied and pasted straight from your post to my REPL it works fine.
> > Maybe verify that you're actually doing what you think you're doing?
>
> > That said, this function already exists: it's called get.
>
> > user=> (def *places* {:room "Nice room"
> >                            :basement "what ever"})
> > #'user/*places*
> > user=> (defn describe-place [place places]
> >           (places place))
> > #'user/describe-place
> > user=> (describe-place :room *places*)
> > "Nice room"
> > user=> (get *places* :room)
> > "Nice room"
>
> > On Mar 3, 5:33 pm, HB  wrote:
>
> > > Hi,
>
> > > I'm trying to write a function that gets the value for a key of a map.
>
> > > (def *places* {:room "Nice room"
> > >                     :basement "what ever"})
>
> > > (defn describe-place [place places]
> > >    (places place))
>
> > > (describe-place :room *places*)
>
> > > Of course it isn't running :)
> > > What should I do?
> > > Thanks for help and time.

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stuart Halloway
> Dear Clojure Group,
> 
> I am currently reading the online book Pro Git. In chapter 7.4 (section 
> “Enforcing a User-Based ACL System”) there is a task of reading in an access 
> control list (ACL) file, such as the following
> 
> # avail/unavail | users | path
> avail|nickh,pjhyett,defunkt,tpw
> avail|usinclair,cdickens,ebronte|doc
> avail|schacon|lib
> avail|schacon|tests
> 
> and printing out a map of the form { "user1" [path 1, path 2], "user2" 
> [path2, path3] ...}.
> 
> The author of the book provides a solution in Ruby, which I find relatively 
> easy to follow, despite not having written any Ruby code before:
> 
> def get_acl_access_data(acl_file)
>   # read in ACL data
>   acl_file = File.read(acl_file).split("\n").reject { |line| line == '' }
>   access = {}
>   acl_file.each do |line|
> avail, users, path = line.split('|')
> next unless avail == 'avail'
> users.split(',').each do |user|
>   access[user] ||= []
>   access[user] << path
> end
>   end
>   access
> end
> 
> I then tried the same in Clojure, but found my solution to be much less 
> readable compared to the Ruby code:
> 
> (use '[clojure.string :only (split)])
> 
> (defn get-acl-access-data [file]
>   (let [acl (split (slurp file) #"\n")]
> (apply merge-with #(into %1 %2)
>   (map (fn [[avail users path]]
>   (let [users (split users #",")]
>  (reduce (fn [acc user]
>  (when (= avail "avail")
>(assoc acc user [path])))
> {} users)))
> (map #(split % #"\|") acl)
> 
> ;; Output:
> ;; {"schacon" ["lib" "tests"], 
> ;;  "usinclair" ["doc"], 
> ;;  "cdickens" ["doc"], 
> ;;  "ebronte" ["doc"], 
> ;;  "tpw" [nil], 
> ;;  "defunkt" [nil], 
> ;;  "pjhyett" [nil], 
> ;; "nickh" [nil]}
> 
> Maybe it is just because I am still a beginner, but I am afraid I won’t be 
> able to figure out immediately what this code is doing a few weeks from now.
> 
> However, I am sure there must be a better way of translating the Ruby version 
> into Clojure. My main goal is on clarity, as I often struggle organizing my 
> code in a way I would consider readable.
> 
> I therefore would be glad for any ideas of improvement. Any suggestions are 
> highly welcome!
> 
> Best regards,
> 
> Stefan

Both the approaches above have the weakness that the steps are commingled, 
making it difficult to test (or reuse) part of the work done by the fn. Here is 
a Clojure version that makes the steps more distinct:

(require '[clojure.string :as str])
(require '[clojure.java.io :as io])

(with-open [r (io/reader "somefile")]
  (->> (line-seq r)
   (map #(str/split % #"\|"))
   (filter #(= "avail" (first %)))
   (mapcat (fn [[_ users path]] (map hash-map (str/split users #",") 
(repeat [path]
   (apply merge-with into)))

>From this it is easy to see that the fn:

1. splits the lines on |
2. filters on "avail"
3. builds a list of user|path pairs
4. merges the user|path pairs into a map


Stuart Halloway
Clojure/core
http://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

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread gaz jones
i was gonna suggest this:

(let [users (->> (split (slurp "acl") #"\n")
 (map #(split % #"\|"))
 (map (fn [[a u p]] [a (split u #",") p]))
 (filter (fn [[a _ _]] (= "avail" a)))
 (mapcat (fn [[_ users path]]
   (map #(hash-map % [path]) users)))
 (apply merge-with into))]
  users)

then i read the bit about readable... :P

On Thu, Mar 3, 2011 at 8:51 PM, Stuart Halloway
 wrote:
> Dear Clojure Group,
>
> I am currently reading the online book Pro Git. In chapter 7.4 (section
> “Enforcing a User-Based ACL System”) there is a task of reading in an access
> control list (ACL) file, such as the following
>
> # avail/unavail | users | path
> avail|nickh,pjhyett,defunkt,tpw
> avail|usinclair,cdickens,ebronte|doc
> avail|schacon|lib
> avail|schacon|tests
>
> and printing out a map of the form { "user1" [path 1, path 2], "user2"
> [path2, path3] ...}.
>
> The author of the book provides a solution in Ruby, which I find relatively
> easy to follow, despite not having written any Ruby code before:
>
> def get_acl_access_data(acl_file)
>  # read in ACL data
>  acl_file = File.read(acl_file).split("\n").reject { |line| line == '' }
>  access = {}
>  acl_file.each do |line|
>    avail, users, path = line.split('|')
>    next unless avail == 'avail'
>    users.split(',').each do |user|
>  access[user] ||= []
>  access[user] << path
>    end
>  end
>  access
> end
>
> I then tried the same in Clojure, but found my solution to be much less
> readable compared to the Ruby code:
>
> (use '[clojure.string :only (split)])
>
> (defn get-acl-access-data [file]
>  (let [acl (split (slurp file) #"\n")]
>    (apply merge-with #(into %1 %2)
>  (map (fn [[avail users path]]
>  (let [users (split users #",")]
> (reduce (fn [acc user]
> (when (= avail "avail")
>   (assoc acc user [path])))
>    {} users)))
>    (map #(split % #"\|") acl)
>
> ;; Output:
> ;; {"schacon" ["lib" "tests"],
> ;;  "usinclair" ["doc"],
> ;;  "cdickens" ["doc"],
> ;;  "ebronte" ["doc"],
> ;;  "tpw" [nil],
> ;;  "defunkt" [nil],
> ;;  "pjhyett" [nil],
> ;; "nickh" [nil]}
>
> Maybe it is just because I am still a beginner, but I am afraid I won’t be
> able to figure out immediately what this code is doing a few weeks from now.
>
> However, I am sure there must be a better way of translating the Ruby
> version into Clojure. My main goal is on clarity, as I often struggle
> organizing my code in a way I would consider readable.
>
> I therefore would be glad for any ideas of improvement. Any suggestions are
> highly welcome!
>
> Best regards,
>
> Stefan
>
> Both the approaches above have the weakness that the steps are commingled,
> making it difficult to test (or reuse) part of the work done by the fn. Here
> is a Clojure version that makes the steps more distinct:
> (require '[clojure.string :as str])
> (require '[clojure.java.io :as io])
> (with-open [r (io/reader "somefile")]
>   (->> (line-seq r)
>        (map #(str/split % #"\|"))
>        (filter #(= "avail" (first %)))
>        (mapcat (fn [[_ users path]] (map hash-map (str/split users #",")
> (repeat [path]
>        (apply merge-with into)))
> From this it is easy to see that the fn:
> 1. splits the lines on |
> 2. filters on "avail"
> 3. builds a list of user|path pairs
> 4. merges the user|path pairs into a map
>
> Stuart Halloway
> Clojure/core
> http://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

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
Don't be afraid to split your work across multiple functions.  Not
only is this clearer, but you can then test the functions
independently.  So something like this:

(defn access-map-add-users [access-map users path]
  (apply merge-with into access-map
 (for [user users] {user [path]})))

(defn access-map-add-line [access-map line]
  (let [[avail user-string path] (split line #"\|"),
users (split user-string #"\,")]
(cond
 (not= avail "avail") access-map  ; no change to access-map
 :else (access-map-add-users access-map users path

(defn get-acl-access-data [file]
  (let [acl-lines (split (slurp file) #"\n")]
(reduce access-map-add-line {} acl-lines)))

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
It's also worth noting that you can translate the Ruby code almost
line for line if you make use of Clojure's atoms to adopt a more
"imperative" approach.  In general, it's more satisfying to find a
pure functional way to solve a problem, but while you're transitioning
from Ruby, it's not unreasonable to copy Ruby's style in localized
contexts.

For example (untested),

(defn get-acl-access-data [file]
  (let [acl (split (slurp file) #"\n"),
access (atom {})]
(doseq [line acl]
  (let [[avail user-string path] (split line #"\|")]
(when (not= avail "avail")
  (doseq [user (split user-string #"\,")]
(swap! access update user conj path)
@access))

Note that this makes use of an "update" function that really should be
in the core, but isn't:
; This should be in core
(defn update [m k f & args]
  (apply update-in m [k] f args))

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
On Thu, Mar 3, 2011 at 7:35 PM, Mark Engelberg  wrote:
>        (when (not= avail "avail")

Whoops, should be:
(when (= avail "avail")

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Thank you all so much for helping me improve my code!

I personally find Stuart's suggestion to be the most readable. The use of 
the ->> macro makes the workflow quite easy to follow. 

I hope that with some more experience I will be able to see these patterns 
myself and adapt my code accordingly.

Best regards,

Stefan  

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Mark Engelberg
On Thu, Mar 3, 2011 at 9:15 PM, Stefan Rohlfing
 wrote:
> I personally find Stuart's suggestion to be the most readable. The use of
> the ->> macro makes the workflow quite easy to follow.

Yes, both the -> and ->> macros are useful.  Unfortunately, about half
of Clojure's functions put the "object" you're operating on first, and
the other half put it last.  -> works best with the former, and ->>
with the latter.

Stuart's code is readable because he found a way to structure it all
in terms of functions that put the main object last.  I find that in
most code, you end up with a mixture of the two types of functions,
and then those macros aren't quite so useful.

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
You are perfectly right. Organizing the code so that -> or ->> an be applied 
is key here. 
Unfortunately, only if all functions to be composed follow the same pattern 
of either 'insert first' or 'insert last' can these macros be used.

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Justin Kramer
'for' can be handy when unpacking compound lines:

(ns foobar
  (:require [clojure.java.io :as io]))

(defn parse-acl [acl-file]
  (with-open [r (io/reader acl-file)]
(apply
 merge-with into
 (for [[status users path] (map #(.split % "\\|") (line-seq r))
   :when (= "avail" status)
   user (.split users ",")]
   {user [path]}

Justin

On Mar 3, 9:15 pm, Stefan Rohlfing  wrote:
> Dear Clojure Group,
>
> I am currently reading the online book Pro Git . In
> chapter 7.4  (section “Enforcing a
> User-Based ACL System”) there is a task of reading in an access control list
> (ACL) file, such as the following
>
> # avail/unavail | users | path
> avail|nickh,pjhyett,defunkt,tpw
> avail|usinclair,cdickens,ebronte|doc
> avail|schacon|lib
> avail|schacon|tests
>
> and printing out a map of the form { "user1" [path 1, path 2], "user2"
> [path2, path3] ...}.
>
> The author of the book provides a solution in Ruby, which I find relatively
> easy to follow, despite not having written any Ruby code before:
>
> def get_acl_access_data(acl_file)
>  # read in ACL data
>  acl_file = File.read(acl_file).split("\n").reject { |line| line == '' }
>  access = {}
>  acl_file.each do |line|
>    avail, users, path = line.split('|')
>    next unless avail == 'avail'
>    users.split(',').each do |user|
>      access[user] ||= []
>      access[user] << path
>    end
>  end
>  access
> end
>
> I then tried the same in Clojure, but found my solution to be much less
> readable compared to the Ruby code:
>
> (use '[clojure.string :only (split)])
>
> (defn get-acl-access-data [file]
>  (let [acl (split (slurp file) #"\n")]
>    (apply merge-with #(into %1 %2)
>              (map (fn [[avail users path]]
>                          (let [users (split users #",")]
>                             (reduce (fn [acc user]
>                                             (when (= avail "avail")
>                                               (assoc acc user [path])))
>                                            {} users)))
>                        (map #(split % #"\|") acl)
>
> ;; Output:
> ;; {"schacon" ["lib" "tests"],
> ;;  "usinclair" ["doc"],
> ;;  "cdickens" ["doc"],
> ;;  "ebronte" ["doc"],
> ;;  "tpw" [nil],
> ;;  "defunkt" [nil],
> ;;  "pjhyett" [nil],
> ;; "nickh" [nil]}
>
> Maybe it is just because I am an ambitious beginner at best, but I am afraid
> I won’t be able to figure out immediately what this code is doing in a few
> weeks.
>
> However, there probably is a better way of translating the Ruby version into
> Clojure. With "better" I mean easier to follow. My main goal is on clarity,
> as I often struggle organizing my code in a way I would consider readable.
>
> I therefore would be glad for any ideas of improvement. Any suggestions are
> highly welcome!
>
> Best regards,
>
> Stefan

-- 
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: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Thanks for your suggestion. 
Using the 'for' macro here makes the main part of the parse function much 
clearer.

-- 
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