Re: Agent errors reporting

2008-11-18 Thread Toralf Wittner
On Sun, 2008-11-16 at 01:35 +0100, [EMAIL PROTECTED] wrote:
> Currently agent errors are only reported when the agent is derefenced
> or further actions are dispatched to the agent. It would be great if
> one can get immediate notification of agent errors maybe through a
> callback.

I also have a need for early error reporting in case of agent errors, so
I changed Agent.java to optionally take an addition error handler
function that will be used as a callback as soon as exceptions occur.
For example:

user=> (def agt (agent 0))
#'user/agt
user=> (defn trouble [_] (throw (new Exception "Trouble")))
#'user/trouble
user=> (send agt trouble)
#
user=> @agt
java.lang.Exception: Agent has errors (NO_SOURCE_FILE:0)
user=> (clear-agent-errors agt)
nil
user=> @agt
0
user=> (set-errorhandler agt (fn [a e] (.printStackTrace e) (clear-agent-errors 
a)))
nil
user=> (send agt trouble)
java.lang.Exception: Trouble
at user$trouble__2.invoke(Unknown Source)
at clojure.lang.AFn.applyToHelper(AFn.java:193)
at clojure.lang.AFn.applyTo(AFn.java:184)
at clojure.lang.Agent$Action.doRun(Agent.java:72)
at clojure.lang.Agent$Action.run(Agent.java:117)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
#
user=> @agt
0
user=> (def agt (agent 0 :error-fn (fn [a e] (.printStackTrace e) 
(clear-agent-errors a
#'user/agt
#'user/agt
user=> (send agt trouble)
java.lang.Exception: Trouble
at user$trouble__2.invoke(Unknown Source)
at clojure.lang.AFn.applyToHelper(AFn.java:193)
at clojure.lang.AFn.applyTo(AFn.java:184)
at clojure.lang.Agent$Action.doRun(Agent.java:72)
at clojure.lang.Agent$Action.run(Agent.java:117)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
#
user=> @agt
0


The agent function is now keyword based and accepts :error-fn
and/or :validate-fn. Alternatively error handlers can be set on an agent
later. Since the change of the agent function is breaking existing code
it is probably not what you (or Rich) want to have. Overloading it to
take 3 parameters might be the better way.

Anyway I second your request and would love to see some error reporting
functionality in agents, as this really helped me a couple of times.

Cheers,
Toralf



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---

diff --git a/trunk/src/clj/clojure/core.clj b/trunk/src/clj/clojure/core.clj
index a6d7ca2..73a2e06 100644
--- a/trunk/src/clj/clojure/core.clj
+++ b/trunk/src/clj/clojure/core.clj
@@ -1033,14 +1033,20 @@
  [sym] (. clojure.lang.Var (find sym)))
 
 ;;; Refs ;;;
+
+(def array-map)
+
 (defn agent
   "Creates and returns an agent with an initial value of state and an
   optional validate fn. validate-fn must be nil or a side-effect-free fn of
   one argument, which will be passed the intended new state on any state
   change. If the new state is unacceptable, the validate-fn should
   throw an exception."
-  ([state] (new clojure.lang.Agent state))
-  ([state validate-fn] (new clojure.lang.Agent state validate-fn)))
+  ([state]
+(new clojure.lang.Agent state))
+  ([state & fns]
+(let [fnmap (apply array-map fns)]
+  (new clojure.lang.Agent state (:validate-fn fnmap) (:error-fn fnmap)
 
 (defn ! [& args] (throw (new Exception "! is now send. See also send-off")))
 
@@ -1127,6 +1133,12 @@
   "Gets the validator-fn for a var/ref/agent."
  [#^clojure.lang.IRef iref] (. iref (getValidator)))
 
+(defn set-errorhandler
+  [#^clojure.lang.IRef iref errorhandler-fn] (. iref (setErrorHandler errorhandler-fn)))
+
+(defn get-errorhandler
+ [#^clojure.lang.IRef iref] (. iref (getErrorHandler)))
+
 (defn commute
   "Must be called in a transaction. Sets the in-transaction-value of
   ref to:
diff --git a/trunk/src/jvm/clojure/lang/Agent.java b/trunk/src/jvm/clojure/lang/Agent.java
index 4c0fc71..324de96 100644
--- a/trunk/src/jvm/clojure/lang/Agent.java
+++ b/trunk/src/jvm/clojure/lang/Agent.java
@@ -19,6 +19,7 @@ import java.util.Map;
 public class Agent implements IRef{
 volatile Object state;
 volatile IFn validator = null;
+volatile IFn errorhandler = null;
 AtomicReference q = new AtomicReference(PersistentQueue.EMPTY);
 AtomicReference watchers = new AtomicReference(Persistent

Re: POLL: Domain name for project hosting site.

2008-11-18 Thread Christian Vest Hansen
Clojury and conj.us are good names, I think.

On Tue, Nov 18, 2008 at 6:47 AM, cwyang <[EMAIL PROTECTED]> wrote:
>
> What a great name 'conj' is, for project hosting site name!
> (no shame for self-complement :-) )
>
> user=> (def repository '(proj-foo proj-bar))
> #=(var user/repository)
> user=> (conj repository 'proj-yours)
> (proj-yours proj-foo proj-bar)
>
> However, conj.net is already occupied. ;-(
> conj.us is avaliable, meaning (conjoin to us)
>
> user=> (def us '(foo bar))
> #=(var user/us)
> user=> (conj us 'new-proj)
> (new-proj foo bar)
>
>
> On 11월18일, 오후2시29분, cwyang <[EMAIL PROTECTED]> wrote:
>> How about 'conj'?
>>
>> conj is (1) for 'conj' in Clojure, and (2) for abbrev of 'conjure',
>> meaning (Conjuring Clojure).
>>
>> 'cons' for lisp, and 'conj' for clojure. :-)
>> --
>> Chul-Woong Yang
>>
>> On Nov 18, 4:52 am, Drew Crampsie <[EMAIL PROTECTED]> wrote:
>>
>> > Hey All,
>>
>> > I've finally found some time to start getting the project hosting site
>> > together, and i need a name.. so lets put it to a vote.
>>
>> > Here are some suggestions so far, but please feel free to chime in
>> > with your own as well.
>>
>> >  - projecture
>> >  - clojr
>> >  - proj4cloj
>> >  - clojforge, cloforj,
>> >  - forj
>> > - clojects
>> > - clojury
>> > - openjure
>>
>> > Thanks for the help Clojurians!
>>
>> > Cheers,
>>
>> > drewc
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: POLL: Domain name for project hosting site.

2008-11-18 Thread Rastislav Kassak

Ruby has gems, python has eggs, I guess Clojure could have jewels.
And Clojure could have Clojury of jewels.
So +1 for clojury.

On 11/17/08, Drew Crampsie <[EMAIL PROTECTED]> wrote:
>
>  Hey All,
>
>  I've finally found some time to start getting the project hosting site
>  together, and i need a name.. so lets put it to a vote.
>
>  Here are some suggestions so far, but please feel free to chime in
>  with your own as well.
>
>   - projecture
>   - clojr
>   - proj4cloj
>   - clojforge, cloforj,
>   - forj
>  - clojects
>  - clojury
>  - openjure
>
>  Thanks for the help Clojurians!
>
>  Cheers,
>
>  drewc
>
>
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: POLL: Domain name for project hosting site.

2008-11-18 Thread Paul Drummond
At the risk of sounding like an old fart, I cringe when I hear "Clojury" and
"Jewel" - they are too "cute" (as Rich nicely put it a while back -
http://groups.google.com/group/clojure/msg/0351ca20c758b0b3).

I agree with Brian Carper - we should keep it readable so +1 for something
like "clojureforge" - but I don't really like that either if I'm honest.

Just for the record, my own contribution would be "The Clojure Project
Hosting Site" but even I will admit that is too boring ;)

Paul

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Alioth binary-tree benchmark

2008-11-18 Thread Simon Brooke

As a learning exercise and also to continue to investigate Clojure
performance I've roughly translated the Alioth binary-tree benchmark
into Clojure. I chose the binary-tree simply because it's the first of
the Alioth benchmarks in alphabetical collation; I may do others
later.

I've based my implementation on Manuel Giraud's Common LISP
implementation 
http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&lang=sbcl&id=2
and followed his algorithm blindly. However Giraud uses the Common
LISP ASH (arithmetic shift) function, and, if there's a built-in
function in Clojure, I did not find it; consequently I implemented an
arithmetic-shift function of my own. As I'm as yet unfamiliar with
Clojure it's likely that my implementation is less than optimal.

;;; -*- mode: clojure -*-
;;;
;;; http://shootout.alioth.debian.org/
;;;
;;; From: Simon Brooke
;;; Based on Common LISP by: Manuel Giraud
;;; Node is either NIL (for leaf nodes) or an improper list (DATA
LEFT . RIGHT)

(defn build-btree [item depth]
  (if (zero? depth)
  (cons item
(cons nil nil))
  (let [item2 (* 2 item)
depth-1 (- depth 1)]
(cons item
  (cons (build-btree (- item2 1) depth-1)
(build-btree item2 depth-1))


(defn check-node [node]
  (if node
  (let [data (first node)
kids (rest node)]
(- (+ data (check-node (first kids)))
   (check-node (rest kids
  0))


;;; The Common LISP implementation used the ASH (arithmetic shift)
function.
;;; Whether this was optimisation or just showing off I'm not sure,
;;; but I'm going to blindly follow their implementation. This
function
;;; could almost certainly be improved upon
(defn arithmetic-shift [n i]
(cond
 (zero? i) n
 (> i 0) (loop [result n expt 0]
 (cond
(= expt i) result
true (recur (* result 
2) (+ expt 1
true (loop [result n expt 0]
 (cond
(= expt i) result
true (recur (/ result 2) (- 
expt 1))



(defn loop-depths [max-depth & others]
(let [min-depth (or (first others) 4)]
 (loop [d min-depth]
(let [iterations
(arithmetic-shift 1 (+ 
max-depth min-depth (- d)))]
(if (> d max-depth)
nil ;; 
return value
(do

(println (* iterations 2)

 "\t trees of depth " d "\t check: "

 (loop [i 1 sum 0]

 (if (> i iterations)

 sum

 (recur (+ i 1)


(+ sum


 (check-node (build-btree i d))


 (check-node (build-btree (- i) d)))

(recur

 (+ d 2


(defn main [n]
;;; ignore for now the issue of parsing a command-line variable
(println "stretch trees of depth " (+ n 1) "\t check: "
(check-node (build-btree 0 (+ n 1
(let [long-lived-tree (build-btree 0 n)]
 (loop-depths n)
 (println "long lived tree of depth " n "\t check: "
(check-node 
long-lived-tree


;;(main)

I get the following values (normalised to seconds) for (time (mai

Re: multi-method dispatch for structs

2008-11-18 Thread Stuart Halloway

Hi Steve,

Metadata is data that does not contribute to an equality relationship.  
In most  scenarios different types are considered not equal, and so  
should be modelled as data.

Stuart

>
> On Nov 14, 3:42 pm, Chouser <[EMAIL PROTECTED]> wrote:
>> On Fri, Nov 14, 2008 at 2:11 PM, Jeff Rose <[EMAIL PROTECTED]> wrote:
>>> Does my dispatch function have to inspect the passed in values to
>>> figure out whichtypeof struct they are, or can I query that
>>> somehow?
>>
>> My understanding is that StructMaps are just Maps with an
>> implementation that's optimized to reduce memory usage.  The  
>> different
>> basis types don't really function as "classes" of StractMaps or
>> anything.  You can still add new keys to StructMaps, for example,  
>> just
>> like any other Map.  So if you want some kind of 'type'datado
>> dispatch off of, you'll have to attach that yourself, either as
>> another key that all your Maps share or as metadata.
>>
> I've actually got the same use case as Jeff Rose -- I want some
> generic methods on algebraic data types. Is there any reason to prefer
> a data field over a metadata field, or vice versa, for the type tag?
>
> -- Steve
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Patch: standalone compiler (almost)

2008-11-18 Thread Rich Hickey


On Nov 18, 2008, at 12:53 AM, Stephen C. Gilardi wrote:

>
> On Nov 17, 2008, at 11:42 PM, Stephen C. Gilardi wrote:
>
>> It seems there's something not quite right, though. I did a fresh  
>> checkout of 1108 and built with "ant" and ran with "java -jar  
>> clojure.jar" and got an exception:
>
> Making pushNS public on line 4461 of src/jvm/clojure/lang/ 
> Compiler.java fixes the exception.
>
>

Fixed - thanks.

Rich



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: multi-method dispatch for structs

2008-11-18 Thread [EMAIL PROTECTED]

On Nov 14, 3:42 pm, Chouser <[EMAIL PROTECTED]> wrote:
> On Fri, Nov 14, 2008 at 2:11 PM, Jeff Rose <[EMAIL PROTECTED]> wrote:
> > Does my dispatch function have to inspect the passed in values to
> > figure out which type of struct they are, or can I query that
> > somehow?
>
> My understanding is that StructMaps are just Maps with an
> implementation that's optimized to reduce memory usage.  The different
> basis types don't really function as "classes" of StractMaps or
> anything.  You can still add new keys to StructMaps, for example, just
> like any other Map.  So if you want some kind of 'type' data do
> dispatch off of, you'll have to attach that yourself, either as
> another key that all your Maps share or asmetadata.
>
> --Chouser

I have the same use case as Jeff Rose -- I want some generic methods
on algebraic data types. Do you know of a reason to favor a data field
over a metadata field, or vice versa, for the type tag?

Thanks,
Steve Huwig

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Alioth binary-tree benchmark

2008-11-18 Thread J. McConnell

On Tue, Nov 18, 2008 at 5:58 AM, Simon Brooke <[EMAIL PROTECTED]> wrote:
>
> However Giraud uses the Common
> LISP ASH (arithmetic shift) function, and, if there's a built-in
> function in Clojure, I did not find it;

find-doc is your friend in this case:

user=> (find-doc "shift")
-
clojure.core/bit-shift-left
([x n])
  Bitwise shift left
-
clojure.core/bit-shift-right
([x n])
  Bitwise shift right

- J.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: POLL: Domain name for project hosting site.

2008-11-18 Thread David

I'm not in favour of slangish derivatives. They're good for code-
names, but when you get serious, a silly name is an obstacle.

First of all, pronunciation descriptors after the name are down-right
silly. People start making remarks that you sound like a Wikipedia
article.

Moreover, it's hard to make a good pitch when you get stuck on a name
before the actual pitch begins. Clojure is no different, BTW. "No,
sir, it's actually pronounced cloe-shur, like closure with an ess.
This way we'll be able to tell it apart from Java closures due in one
of the next releases of the JVM. No, not ass. Ess. Let me write it
down for you. ..."

That being said, why can't clojure.org be used for that purpose? If I
remember correctly, all it takes is some DNS magic, and we have a,
say, project.clojure.org. Hosted on another physical machine, if need
be.

On Nov 17, 8:52 pm, Drew Crampsie <[EMAIL PROTECTED]> wrote:
> Hey All,
>
> I've finally found some time to start getting the project hosting site
> together, and i need a name.. so lets put it to a vote.
>
> Here are some suggestions so far, but please feel free to chime in
> with your own as well.
>
>  - projecture
>  - clojr
>  - proj4cloj
>  - clojforge, cloforj,
>  - forj
> - clojects
> - clojury
> - openjure
>
> Thanks for the help Clojurians!
>
> Cheers,
>
> drewc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Agent errors reporting

2008-11-18 Thread Rich Hickey
On Tue, Nov 18, 2008 at 3:14 AM, Toralf Wittner <[EMAIL PROTECTED]>wrote:

> On Sun, 2008-11-16 at 01:35 +0100, [EMAIL PROTECTED] wrote:
> > Currently agent errors are only reported when the agent is derefenced
> > or further actions are dispatched to the agent. It would be great if
> > one can get immediate notification of agent errors maybe through a
> > callback.
>
> I also have a need for early error reporting in case of agent errors, so
> I changed Agent.java to optionally take an addition error handler
> function that will be used as a callback as soon as exceptions occur.
> For example:
>
> user=> (def agt (agent 0))
> #'user/agt
> user=> (defn trouble [_] (throw (new Exception "Trouble")))
> #'user/trouble
> user=> (send agt trouble)
> #
> user=> @agt
> java.lang.Exception: Agent has errors (NO_SOURCE_FILE:0)
> user=> (clear-agent-errors agt)
> nil
> user=> @agt
> 0
> user=> (set-errorhandler agt (fn [a e] (.printStackTrace e)
> (clear-agent-errors a)))
> nil
> user=> (send agt trouble)
> java.lang.Exception: Trouble
>at user$trouble__2.invoke(Unknown Source)
>at clojure.lang.AFn.applyToHelper(AFn.java:193)
>at clojure.lang.AFn.applyTo(AFn.java:184)
>at clojure.lang.Agent$Action.doRun(Agent.java:72)
>at clojure.lang.Agent$Action.run(Agent.java:117)
>at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>at java.lang.Thread.run(Thread.java:619)
> #
> user=> @agt
> 0
> user=> (def agt (agent 0 :error-fn (fn [a e] (.printStackTrace e)
> (clear-agent-errors a
> #'user/agt
> #'user/agt
> user=> (send agt trouble)
> java.lang.Exception: Trouble
>at user$trouble__2.invoke(Unknown Source)
>at clojure.lang.AFn.applyToHelper(AFn.java:193)
>at clojure.lang.AFn.applyTo(AFn.java:184)
>at clojure.lang.Agent$Action.doRun(Agent.java:72)
>at clojure.lang.Agent$Action.run(Agent.java:117)
>at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>at java.lang.Thread.run(Thread.java:619)
> #
> user=> @agt
> 0
>
>
> The agent function is now keyword based and accepts :error-fn
> and/or :validate-fn. Alternatively error handlers can be set on an agent
> later. Since the change of the agent function is breaking existing code
> it is probably not what you (or Rich) want to have. Overloading it to
> take 3 parameters might be the better way.
>
> Anyway I second your request and would love to see some error reporting
> functionality in agents, as this really helped me a couple of times.
>
> Cheers,
> Toralf
>
>
I'm definitely interested in more centralized agent error handling, but I
don't want to jump into the per-agent error handler thing just yet.

At some point I'm probably going to provide abstractions over some of the
java.util.concurrent workflow stuff like queues and latches (since so few
people know they are there or how to use them). Then there might be a
default queue for agent errors, with the possibility of connecting an agent
to a specific error queue.

Rich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: POLL: Domain name for project hosting site.

2008-11-18 Thread blackdog


+1

On Tue, 18 Nov 2008 04:54:22 -0800 (PST)
David <[EMAIL PROTECTED]> wrote:

> 
> I'm not in favour of slangish derivatives. They're good for code-
> names, but when you get serious, a silly name is an obstacle.
> 
> First of all, pronunciation descriptors after the name are down-right
> silly. People start making remarks that you sound like a Wikipedia
> article.
> 
> Moreover, it's hard to make a good pitch when you get stuck on a name
> before the actual pitch begins. Clojure is no different, BTW. "No,
> sir, it's actually pronounced cloe-shur, like closure with an ess.
> This way we'll be able to tell it apart from Java closures due in one
> of the next releases of the JVM. No, not ass. Ess. Let me write it
> down for you. ..."
> 
> That being said, why can't clojure.org be used for that purpose? If I
> remember correctly, all it takes is some DNS magic, and we have a,
> say, project.clojure.org. Hosted on another physical machine, if need
> be.
> 
> On Nov 17, 8:52 pm, Drew Crampsie <[EMAIL PROTECTED]> wrote:
> > Hey All,
> >
> > I've finally found some time to start getting the project hosting
> > site together, and i need a name.. so lets put it to a vote.
> >
> > Here are some suggestions so far, but please feel free to chime in
> > with your own as well.
> >
> >  - projecture
> >  - clojr
> >  - proj4cloj
> >  - clojforge, cloforj,
> >  - forj
> > - clojects
> > - clojury
> > - openjure
> >
> > Thanks for the help Clojurians!
> >
> > Cheers,
> >
> > drewc
> > 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: POLL: Domain name for project hosting site.

2008-11-18 Thread Matt Revelle

+1

On Nov 18, 2008, at 8:27 AM, blackdog <[EMAIL PROTECTED]> wrote:

>
>
> +1
>
> On Tue, 18 Nov 2008 04:54:22 -0800 (PST)
> David <[EMAIL PROTECTED]> wrote:
>
>>
>> I'm not in favour of slangish derivatives. They're good for code-
>> names, but when you get serious, a silly name is an obstacle.
>>
>> First of all, pronunciation descriptors after the name are down-right
>> silly. People start making remarks that you sound like a Wikipedia
>> article.
>>
>> Moreover, it's hard to make a good pitch when you get stuck on a name
>> before the actual pitch begins. Clojure is no different, BTW. "No,
>> sir, it's actually pronounced cloe-shur, like closure with an ess.
>> This way we'll be able to tell it apart from Java closures due in one
>> of the next releases of the JVM. No, not ass. Ess. Let me write it
>> down for you. ..."
>>
>> That being said, why can't clojure.org be used for that purpose? If I
>> remember correctly, all it takes is some DNS magic, and we have a,
>> say, project.clojure.org. Hosted on another physical machine, if need
>> be.
>>
>> On Nov 17, 8:52 pm, Drew Crampsie <[EMAIL PROTECTED]> wrote:
>>> Hey All,
>>>
>>> I've finally found some time to start getting the project hosting
>>> site together, and i need a name.. so lets put it to a vote.
>>>
>>> Here are some suggestions so far, but please feel free to chime in
>>> with your own as well.
>>>
>>>  - projecture
>>>  - clojr
>>>  - proj4cloj
>>>  - clojforge, cloforj,
>>>  - forj
>>> - clojects
>>> - clojury
>>> - openjure
>>>
>>> Thanks for the help Clojurians!
>>>
>>> Cheers,
>>>
>>> drewc
>>>
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: offtopic - where are you come from? (poll)

2008-11-18 Thread bnb



On Oct 17, 3:27 am, "Rastislav Kassak" <[EMAIL PROTECTED]> wrote:
> Hello Clojurians,
>
> I think after 1st year of Clojure life it's good to check how far has
> Clojure spread all over the world.
>
> So wherever are you come from, be proud and say it.
>
> I'm from Slovakia. :)
>
> RK

First post, Boyd Brown from Houston, Texas, USA.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: POLL: Domain name for project hosting site.

2008-11-18 Thread Geoffrey Teale
2008/11/18 David <[EMAIL PROTECTED]>
--- %< ---


> That being said, why can't clojure.org be used for that purpose? If I
> remember correctly, all it takes is some DNS magic, and we have a,
> say, project.clojure.org. Hosted on another physical machine, if need
> be.
>

That gets my vote!

+1

--
Geoff

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-18 Thread Stuart Halloway

Hi Ralph,

In some sense you can think of a cached stable install of some set of  
developer tools as a performance optimization. In this case, the  
performance being optimized is the developer's performance installing  
a tool set.

Like any performance optimization, it should not be made prematurely.  
Maybe  the cost of managing the stable install outweighs the time  
saved over developers just grabbing the various bits.

Your bad experience certainly suggests that it is time for a  
prepackaged slime+clojure, --but--

> Remember the context: "Getting Started." The context is NOT bleeding
> edge developers who want the very latest build of everything. If you
> want the very latest slime, etc., you should be on your own.

If you are using Clojure you are somewhere in the neighborhood of the  
bleeding edge. It isn't 1.0 yet.

I would love to see somebody step forward in the next few weeks and  
announce a cached install that works. Then I could point to it in the  
book before we go to print. :-)

Cheers,
Stuart


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-18 Thread Raffael Cavallaro



On Nov 18, 1:46 am, "Cosmin Stejerean" <[EMAIL PROTECTED]> wrote:

> What kind of bugs are acceptable for the
> purpose of a known good combination? Is slime starting up sufficient?

It's a whole lot better than slime *not* starting up. Again, context:
"Getting Started."

BTW, it's this sort of thinking, that one wants to constantly update
because some bug or other may have been fixed in the latest svn/cvs
commit that leads to projects never making releases, which is a Bad
Thing(TM).

>
> Assuming some automated tests can be created to define the characteristics
> of a known good combination I'll volunteer to create a continuous
> integration server to report the status of trying to use the latest version
> of each project so interested users can quickly see if the most recent
> combination works, and if not look, at the history to find the most recent
> one that does. Is providing automated tests something you'd like to help
> with?


Again, *not* looking for the latest and greatest in the context of
"Getting Started." Merely looking for "known to work even though it's
6 months old."

As the old chestnut goes, one never gets a second chance to make a
first impression. The first impression one gets now does *not* reflect
the quality of clojure at this point. The first impression one gets
now is "OK, broken, check back later." Clojure is more mature than
this, and the initial setup brokenness is easily solved by putting up
an archive of working versions of the various components even if they
grow to be many months old before they're refreshed. This would not
require an automated testing server, just a single tar command line
once or twice a year.

regards,

Ralph



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Alioth binary-tree benchmark

2008-11-18 Thread mb

Hi,

blindly copying code is usually not a good way to learn a new
language

I don't know, whether this is more idiomatic Clojure code, but
it works...

(defn build-tree
  [item depth]
  (when (< 0 depth)
(let [i (* 2 item)
  d (dec depth)]
  [item (build-tree (dec i) d) (build-tree i d)])))

(defn check-node
  [z]
  (if z
(+ (z 0) (check-node (z 1)) (- (check-node (z 2
0))

(defn iterate-trees
  [mx mn d]
  (let [iterations (bit-shift-left 1 (+ mx mn (- d)))]
(println (* 2 iterations) "\ttrees of depth" d "\tcheck:"
 (reduce + (map (fn [i]
  (+ (check-node (build-tree i d))
 (check-node (build-tree (- i) d
(range 1 (inc iterations)))

(defn main
  [max-depth]
  (let [min-depth 4
str-depth (inc max-depth)]
(let [tree (build-tree 0 str-depth)
  x(check-node tree)]
  (println "stretch tree of depth" str-depth "\tcheck:" x))
(let [long-lived-tree (build-tree 0 max-depth)]
  (doseq d (range min-depth str-depth 2)
(iterate-trees max-depth min-depth d))
  (println "long lived tree of depth" max-depth "\tcheck:"
   (check-node long-lived-tree)

> Armed Bear
>         Interpreted     232.54
>         Compiled                 35.3
> CMUCL
>         Interpreted     600.15
>         Compiled                  6.13
> Clojure                  57.131432
>
> These are not formal benchmark tests; each test is of one run, not
> averaged over several, and is performed on my development machine
> which has many other processes running.

user=> (time (main 16))
stretch tree of depth 17check: -1
131072  trees of depth 4check: -131072
32768   trees of depth 6check: -32768
8192trees of depth 8check: -8192
2048trees of depth 10   check: -2048
512 trees of depth 12   check: -512
128 trees of depth 14   check: -128
32  trees of depth 16   check: -32
long lived tree of depth 16 check: -1
"Elapsed time: 24222.279088 msecs"
nil

That is 24.2 seconds on my crappy 1.7 GHz Office machine.

Sincerely
Meikel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure.contrib.test-is changes

2008-11-18 Thread Stuart Sierra

Hi Frantisek, Meikel,

Good suggestions, all.  I'll have to spend some time looking at these
and figure out if I can make them work with the existing test-is.  Two
thoughts first:

1. I want to keep optional messages per-assertion.  These are very
useful in the RSpec testing framework for Ruby; they're like comments
explaining what each assertion is supposed to demonstrate.

2. The current 'is' macro works more or less like the one Meikel
described.  The multimethod is "assert-expr", but it's complicated and
could be simplified.

In general, I want to make the library more oriented towards
functional programming, and less reliant on macros.  That should both
simplify the interface and make it easier to add new kinds of
assertions.  Stay tuned.

-Stuart Sierra



On Nov 17, 6:55 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Am 18.11.2008 um 00:13 schrieb Frantisek Sodomka:
>
> > B) What about 'throws' macro? Could this become a function returning
> > true/false? Then we could stick it inside 'is' or 'all-true'. (I  
> > guess it
> > doesn't matter that much, does it?)
>
> I have a is-like construct, which is build-up slightly different.
> Instead of checking, what I get, I immediatelly dispatch to a
> multimethod.
>
> (defmacro is [t msg] (is* t msg))
>
> (defmulti is* (fn [t _] (first t)))
>
> (defmethod is* :default `(simply-run-t-here ...))
> (defmethod is* nil `(always-fail ...))
> (defmethod is* '= `(do-test-here ...))
> (defmethod is* 'not= `(do-test-here ...))
> (defmethod is* 'instance? `(do-test-here ...))
> (defmethod is* 'throwing? `(do-test-here ...))
>
> So it is easy to extend is with other tests, while still being able
> to provide diagnostics in case a test should fail.
>
> Furthermore I use a test driver function, which reduces the repition to
> a minimum. It takes care to run the tests in a try, report the result
> and provide diagnostics in case of a failure. Then each methods above
> just has to specify in a callback how the actual test is carried out and
> what kind diagnostics should be printed. (eg. compare assert-expr
> for = and instance?. They are very similar.)
>
> What do you think about such a structure?
>
> Sincerely
> Meikel
>
>  smime.p7s
> 5KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: POLL: Domain name for project hosting site.

2008-11-18 Thread Fogus

I like forj, but after reflecting on that it might be better to simply
use clojure.org.

-m

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-18 Thread Rich Hickey
On Tue, Nov 18, 2008 at 9:42 AM, Raffael Cavallaro <
[EMAIL PROTECTED]> wrote:

>
>
>
> On Nov 18, 1:46 am, "Cosmin Stejerean" <[EMAIL PROTECTED]> wrote:
>
> > What kind of bugs are acceptable for the
> > purpose of a known good combination? Is slime starting up sufficient?
>
> It's a whole lot better than slime *not* starting up. Again, context:
> "Getting Started."
>
> BTW, it's this sort of thinking, that one wants to constantly update
> because some bug or other may have been fixed in the latest svn/cvs
> commit that leads to projects never making releases, which is a Bad
> Thing(TM).
>
> >
> > Assuming some automated tests can be created to define the
> characteristics
> > of a known good combination I'll volunteer to create a continuous
> > integration server to report the status of trying to use the latest
> version
> > of each project so interested users can quickly see if the most recent
> > combination works, and if not look, at the history to find the most
> recent
> > one that does. Is providing automated tests something you'd like to help
> > with?
>
>
> Again, *not* looking for the latest and greatest in the context of
> "Getting Started." Merely looking for "known to work even though it's
> 6 months old."
>
> As the old chestnut goes, one never gets a second chance to make a
> first impression. The first impression one gets now does *not* reflect
> the quality of clojure at this point. The first impression one gets
> now is "OK, broken, check back later." Clojure is more mature than
> this, and the initial setup brokenness is easily solved by putting up
> an archive of working versions of the various components even if they
> grow to be many months old before they're refreshed. This would not
> require an automated testing server, just a single tar command line
> once or twice a year.
>
> regards,
>
>
The complexity here lies on the Emacs/Swank/Slime side, and the coordination
it requires with a matching Clojure.

You can always grab the latest Clojure from svn, run ant, and have a working
Repl with java -jar clojure.jar in under 30 seconds.

Might I suggest that for "Getting Started", Swank/Slime is a bit much? For
many people, this will be their first use of Emacs. Perhaps some simple
instructions for getting clojure-mode going would be better? Its
functionality/complexity ratio seems much higher.

Also, I'd like not to imply that emacs+swank/slime is the only way, or a
prerequisite for using Clojure. There's a mode for vim, and there's also
enclojure, something for TextMate, etc.

Let's not make getting started any harder than it need be. People can move
up to swank/slime when they are ready.

Rich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure.contrib.test-is changes

2008-11-18 Thread mb

Hello Stuart,

On 18 Nov., 15:58, Stuart Sierra <[EMAIL PROTECTED]> wrote:
> 1. I want to keep optional messages per-assertion.  These are very
> useful in the RSpec testing framework for Ruby; they're like comments
> explaining what each assertion is supposed to demonstrate.

I'd also like to see the messages included. I'm working on a TAP
implementation for Clojure, which I find nice for communicating test
results to external processes. In TAP also the messages are used
as some kind of documentation.

This leads me to another question: Is it possible to look into
pluggable
harnesses? That is: can we separate the tests from the result
reporting?
In my TAP implementation I currently have two harnesses, one
produces TAP output, one can be used inside a test to allow recursive
tests. One application is for example the ClojureCheck library I am
working on.

(holds?
  (for-all [x Integer
y Integer]
(is (= (+ x y) (+ y x
  "addition commutes")

for-all sets up a batch-harness, so the body of the for-all may
contain
any number or form of tests. The result of the for-all, is then the
result
of the internal tests.

> 2. The current 'is' macro works more or less like the one Meikel
> described.  The multimethod is "assert-expr", but it's complicated and
> could be simplified.

My sketch was rather minimalistic. I will post a more complete
example with working code later on today.

Sincerely
Meikel

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Alioth binary-tree benchmark

2008-11-18 Thread Michael Wood

On Tue, Nov 18, 2008 at 4:55 PM, mb <[EMAIL PROTECTED]> wrote:
[...]
> I don't know, whether this is more idiomatic Clojure code, but
> it works...
[...]

What revision is that?  On r1099 I got:
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: Symbol (NO_SOURCE_FILE:31)

so I updated to r1109 and got the same thing.

OK, I see you're using the old doseq syntax.  After fixing that I get:
user=> (time (main 16))
stretch tree of depth 17check: -1
131072  trees of depth 4check: -131072
32768   trees of depth 6check: -32768
8192trees of depth 8check: -8192
2048trees of depth 10   check: -2048
512 trees of depth 12   check: -512
128 trees of depth 14   check: -128
32  trees of depth 16   check: -32
long lived tree of depth 16 check: -1
"Elapsed time: 15129.053 msecs"
nil

That's on a 2.8GHz Xeon.

-- 
Michael Wood <[EMAIL PROTECTED]>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-18 Thread Matt Revelle



On Nov 18, 2008, at 9:42 AM, Raffael Cavallaro <[EMAIL PROTECTED] 
 > wrote:

>
>
>
> On Nov 18, 1:46 am, "Cosmin Stejerean" <[EMAIL PROTECTED]> wrote:
>
>> What kind of bugs are acceptable for the
>> purpose of a known good combination? Is slime starting up sufficient?
>
> It's a whole lot better than slime *not* starting up. Again, context:
> "Getting Started."
>
> BTW, it's this sort of thinking, that one wants to constantly update
> because some bug or other may have been fixed in the latest svn/cvs
> commit that leads to projects never making releases, which is a Bad
> Thing(TM).
>
>>
>> Assuming some automated tests can be created to define the  
>> characteristics
>> of a known good combination I'll volunteer to create a continuous
>> integration server to report the status of trying to use the latest  
>> version
>> of each project so interested users can quickly see if the most  
>> recent
>> combination works, and if not look, at the history to find the most  
>> recent
>> one that does. Is providing automated tests something you'd like to  
>> help
>> with?
>
>
> Again, *not* looking for the latest and greatest in the context of
> "Getting Started." Merely looking for "known to work even though it's
> 6 months old."

The problem is there have been breaking changes in Clojure and the  
SWANK component needs to be updated.  A package like you request would  
have to include a stale version of Clojure.  Once Clojure has a 1.0  
release it will make sense for all development tools to provide  
packages releases known to work.

>
>
> As the old chestnut goes, one never gets a second chance to make a
> first impression. The first impression one gets now does *not* reflect
> the quality of clojure at this point. The first impression one gets
> now is "OK, broken, check back later." Clojure is more mature than
> this, and the initial setup brokenness is easily solved by putting up
> an archive of working versions of the various components even if they
> grow to be many months old before they're refreshed. This would not
> require an automated testing server, just a single tar command line
> once or twice a year.

Sure, you're absolutely correct that more effort could have been made  
to streamline Emacs/SLIME support for particular revisions of  
Clojure.  But since Clojure is bleeding edge and Emacs/SLIME users are  
usually tinkerers there hasn't been enough of a demand to warrant the  
effort.  I expect this will change as soon as 1.0 is released.

>
>
> regards,
>
> Ralph
>
>
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Adapting a functional pretty-printer to Clojure

2008-11-18 Thread [EMAIL PROTECTED]

Hello everyone,

I looked at Wadler's "A Prettier Printer" paper (http://
homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf) and did a
rote translation of it into Clojure. Then I wrote printing routines
for sequences and maps -- very barebones. They work OK:

user> (def something '(a b c d (e f g h i) j k (l m n) (o p q r s t u
v) w x y (z)))
#'user/something
user> (pp something 20)
nil
(a
 b
 c
 d
 (e f g h i)
 j
 k
 (l m n)
 (o p q r s t u v)
 w
 x
 y
 (z))
user> (def things {:one "another" :two {:map "inside" :a "map"} :three
[1 2 3 4 5] :four "still making things up" :five :done})
#'user/things
user> (pp things)
nil
{:three [1 2 3 4 5],
 :one "another",
 :five :done,
 :four "still making things up",
 :two {:a "map", :map "inside"}}
user>
user> (pp (bean (. java.awt.Color black)))
nil
{:RGB -16777216,
 :class class java.awt.Color,
 :red 0,
 :colorSpace [EMAIL PROTECTED],
 :transparency 1,
 :blue 0,
 :green 0,
 :alpha 255}

BUT -- Wadler's implementation is for Haskell, so my transcription
predictably blows up with a stack overflow:

user> (pp (range 1000))
  [Thrown class java.lang.StackOverflowError]

Restarts:
 0: [ABORT] Return to SLIME's top level.

Backtrace:
  0: java.lang.Number.(Number.java:32)
  1: java.lang.Integer.(Integer.java:602)
  2: sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
  3: sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
  4: java.lang.reflect.Method.invoke(Method.java:597)
  5: clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:82)
  6: clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:
245)
  7: user.fn__4400.invoke(pretty.clj:98)


What could be some good strategies to adapt the code I have here to
Clojure, where tail calls are not eliminated and structs are not lazy?


(defstruct NIL :type)
(defstruct CONCAT :type :doc1 :doc2)
(defstruct NEST :type :level :doc)
(defstruct TEXT :type :contents)
(defstruct LINE :type)
(defstruct UNION :type :doc1 :doc2)

(defn doc-nil []
  (struct NIL :NIL))

(defn doc-concat [x y]
  (struct CONCAT :CONCAT x y))

(defn doc-nest [i x]
  (struct NEST :NEST i x))

(defn doc-text [s]
  (struct TEXT :TEXT s))

(defn doc-line []
  (struct LINE :LINE))

(defn doc-union [x y]
  (struct UNION :UNION x y))

(defstruct Nil :type)
(defstruct Text :type :contents :rest)
(defstruct Line :type :level :rest)

(defmulti flatten :type)
(defmethod flatten :NIL [x] x)
(defmethod flatten :TEXT [x] x)
(defmethod flatten :CONCAT [x]
  (doc-concat (flatten (:doc1 x))
  (flatten (:doc2 x
(defmethod flatten :NEST [x]
  (doc-nest (:level x)
(flatten (:doc x
(defmethod flatten :LINE [x]
  (doc-text " "))
(defmethod flatten :UNION [x]
  (flatten (:doc1 x)))

(defmulti layout :type)
(defmethod layout :Nil [x] "")
(defmethod layout :Text [x]
  (lazy-cat (:contents x)
(layout (:rest x
(defmethod layout :Line [x]
  (lazy-cat (lazy-cons \newline
   (replicate (:level x) \space))
(layout (:rest x

(defn group [x]
  (doc-union (flatten x) x))

(defmulti fits (fn [w x] (if (< w 0)
   :ZERO
   (:type x
(defmethod fits :ZERO [w x] false)
(defmethod fits :Nil [w x] true)
(defmethod fits :Line [w x] true)
(defmethod fits :Text [w x]
  (fits (- w (.length (:contents x)))
(:rest x)))

(defn better [w k x y]
  (if (fits (- w k) x)
x
y))

(defmulti be (fn [w k d]
   (if (empty? d)
 :EMPTY
 (:type (second (first d))

(defmethod be :EMPTY [w k d]
  (struct Nil :Nil))
(defmethod be :NIL [w k d]
  (be w k (rest d)))
(defmethod be :CONCAT [w k d]
  (let [level (first (first d))
doc (second (first d))]
(be w k (lazy-cons [level,(:doc1 doc)]
   (lazy-cons [level,(:doc2 doc)] (rest d))
(defmethod be :NEST [w k d]
  (let [level (first (first d))
doc (second (first d))]
(be w k (lazy-cons [(+ level (:level doc)), (:doc doc)]
   (rest d)
(defmethod be :TEXT [w k d]
  (let [doc (second (first d))]
(struct Text :Text (:contents doc)
(be w (+ k (.length (:contents doc)))
(rest d)
(defmethod be :LINE [w k d]
  (let [level (first (first d))]
(struct Line :Line level (be w level (rest d)
(defmethod be :UNION [w k d]
  (let [level (first (first d))
doc (second (first d))]
(better w k (be w k (lazy-cons [level,(:doc1 doc)] (rest d)))
(be w k (lazy-cons [level,(:doc2 doc)] (rest d))

(defn best [w k x]
  (be w k (list [0,x])))

(defn pretty [w x]
  (layout (best w 0 x)))

(defn show-dispatch [x]
  (cond (seq? x)
:list
(map? x)
:map
true
:default))


(defmulti show show-dispatch)

(def show-list-children)
(defn show-list-children [x]
  (cond (empty? x)
(doc-nil)
(= (count x) 1)
(show (first x))
true
(reduce 

Patch: Use vector binding for with-in-str

2008-11-18 Thread Chouser
tWip in IRC notice with-in-str is broken.  Patch attached.

--Chouser

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---

commit 071c5ab1c5b1fd9c80cf1ee825944c7da383a7e2
Author: Chouser <[EMAIL PROTECTED]>
Date:   Tue Nov 18 12:06:50 2008 -0500

Use vector binding for with-in-str

diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 8376f13..a8a1df2 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -2400,7 +2400,7 @@
   "Evaluates body in a context in which *in* is bound to a fresh
   StringReader initialized with the string s."
   [s & body]
-  `(with-open s# (-> (java.io.StringReader. ~s) clojure.lang.LineNumberingPushbackReader.)
+  `(with-open [s# (-> (java.io.StringReader. ~s) clojure.lang.LineNumberingPushbackReader.)]
  (binding [*in* s#]
[EMAIL PROTECTED])))
 


Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread Chouser
On Tue, Nov 18, 2008 at 11:29 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> I looked at Wadler's "A Prettier Printer" paper (http://
> homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf) and did a
> rote translation of it into Clojure. Then I wrote printing routines
> for sequences and maps -- very barebones. They work OK:

I started working on a pretty-printer as well.  I wouldn't show it to
anybody yet, but I also don't want any unnecessary duplicated effort.
So I'll go ahead and show what I've got so far, and then we can decide
how to proceed. I have no interest in pursuing my solution if it's not
a good approach, or if anyone else would rather pursue it.

That is, I want to use a pretty printer, not necessarily write one. :-)

> user> (def something '(a b c d (e f g h i) j k (l m n) (o p q r s t u
> v) w x y (z)))
> #'user/something
> user> (pp something 20)

I don't have nice API yet, so for now I have to use binding:

user=> (binding [*max-width* 20] (pprint something))
(a
  b
  c
  d
  (e f g h i)
  j
  k
  (l m n)
  (o p q r s t u v)
  w
  x
  y
  (z))

> user> (def things {:one "another" :two {:map "inside" :a "map"} :three
> [1 2 3 4 5] :four "still making things up" :five :done})
> #'user/things
> user> (pp things)

user=> (pprint things)
{:five
   :done
 :three
   [1 2 3 4 5]
 :two
   {:a "map", :map "inside"}
 :four
   "still making things up"
 :one
   "another"}

I still need to add commas and collapse key/vals onto a single line
when possible.

> user> (pp (range 1000))
>  [Thrown class java.lang.StackOverflowError]

user=> (pprint (range 5000))
(0
  1
  2
  3
  4
[...manually snipped here...]
  4996
  4997
  4998
  4999)

Not a problem, though I don't have *line-limit* yet.

I allow \newlines to print, which helps with long multi-line strings:

(defn
  gen-and-load-class
  "Generates and immediately loads the bytecode for the specified
  class. Note that a class generated this way can be loaded only once
  - the JVM supports only one class with a given name per
  classloader. Subsequent to generation you can import it into any
  desired namespaces just like any other class. See gen-class for a
  description of the options."
  [name & options]
  (let
[{:keys [name bytecode]} (apply gen-class (str name) options)]
(.. clojure.lang.RT ROOT_CLASSLOADER (defineClass (str name) bytecode

I'd like to add a *detect-code* option that looks for "well-known"
symbols that are used in code (defn, let, etc.) and can format the
required args differently than the "rest" args. This would allow some
code forms to look more natural.

Anyway, it's definitely a work in progress.  What I've got so far is
attached.  All thoughts and comments are welcome.
--Chouser

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---

;   Copyright (c) Chris Houser, Nov 2008. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
;   which can be found in the file CPL.TXT at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.

; Print nicely-indented Clojure data structures, including code forms

;(ns clojure.contrib.pprint)

(def *max-width* 80) ; not a hard limit
(def *vertical-start-column* 40)
(def *spaces-per-indent* 2)
;(def *conserve-lines* false)
;(def *detect-code* true)

(defn- indent [depth]
  (print (apply str \newline (replicate depth \space

(defmulti pprint-method (fn [obj depth] (class obj)))

(defn- pprint-seq-vert [begin end o d]
  (print begin)
  (pprint-method (first o) (inc d))
  (let [d (+ d *spaces-per-indent*)]
(loop [o (rest o)]
  (when o
(indent d)
(pprint-method (first o) d)
(recur (rest o
(print end)))

(defn- pprint-seq [begin end o d]
  (if (< d *vertical-start-column*)
(let [one-line (pr-str o)] ; XXX rebind limits here
  (if (< (+ d (.length one-line)) *max-width*)
(print one-line)
(pprint-seq-vert begin end o d)))
(pprint-seq-vert begin end o d)))

(defmethod pprint-method :default [o d]
  (pr o))

(defmethod pprint-method clojure.lang.ISeq [o d]
  (pprint-seq "(" ")" o d))

(defmethod pprint-method clojure.lang.IPersistentVector [o d]
  (pprint-seq "[" "]" o d))

(defmethod pprint-method clojure.lang.IPersistentMap [o d]
  (binding [*spaces-per-indent* 1]
(pprint-seq "{" "}" o d)))

(defmethod pprint-method clojure.lang.AMapEntry [o d]
  (pprint-method (key o) d)
  (let [d2 (+ 1 d *spac

Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-18 Thread Bill Clementson

On Tue, Nov 18, 2008 at 6:42 AM, Raffael Cavallaro
<[EMAIL PROTECTED]> wrote:
> On Nov 18, 1:46 am, "Cosmin Stejerean" <[EMAIL PROTECTED]> wrote:
>
>> What kind of bugs are acceptable for the
>> purpose of a known good combination? Is slime starting up sufficient?
>
> It's a whole lot better than slime *not* starting up. Again, context:
> "Getting Started."

Maybe the "Getting Started" section of the wiki shouldn't point
beginners towards slime. Once someone is accustomed to using Clojure
with Emacs, they will appreciate the power of slime; however, to get
started, clojure-mode is more than sufficient. You should also
probably eliminate clojure-contrib and the separate clojure binary
from the "Getting Started" steps. The minimal steps to get started
with clojure and emacs then become:

1. Download latest Clojure from svn: http://sourceforge.net/svn/?group_id=137961
2. Download latest clojure-mode from git: http://github.com/jochu/
3. Use ant to build clojure
4.  Put the following minimal setup in your .emacs file (adjusting the
paths as necessary):

(setq inferior-lisp-program "java -server -cp
/Users/bc/lisp/clojure/clojure/trunk/clojure.jar clojure.lang.Repl")
(pushnew "/Users/bc/lisp/clojure/clojure-mode" load-path
(require 'clojure-auto)

5. Restart Emacs. Load a clojure (clj) file in a buffer, press C-c C-z
to get a repl.

That is far simpler to get setup and the user can focus on clojure
rather than slime as they're getting started with the language.

--
Bill Clementson

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Can functions be decompiled?

2008-11-18 Thread Konrad Hinsen

Is there a way to recover readable source code from a compiled  
function in Clojure? Debugging things like "[EMAIL PROTECTED]" is  
not much fun. It would already be a great help to be able to find out  
from where in the source code the function was compiled.

Konrad.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread Meikel Brandmeyer

Hi,

Am 18.11.2008 um 17:29 schrieb [EMAIL PROTECTED]:


What could be some good strategies to adapt the code I have here to
Clojure, where tail calls are not eliminated and structs are not lazy?


There is the lazy-map package[1], which also allows lazy (struct)maps.
However it is not updated to 1094+, yet.

I only skimmed through your code and I don't know the paper, but
maybe I can give some general tips.

As always: don't copy code blindly! Take a step back and look from a
distance, how you can *translate* the code. For example, in the
show-list-children function, the recursion is just used for iteration.
It starts with x, do something to (first x) and then calls itself
with (rest x). So the first step is to translate this into a loop
recur pair. The next step is to see, that one can also write this
as (doseq [child x] (do-something-to x)), or in case its the result
you are interested in and not the side-effects: (map #(do-something-to
%) x).

So don't just copy the code, but understand what it does and then
ask: "how would I do this in Clojure?"

Stuart's "PCL goes Clojure" series[2] is great example for this.

Just my 2¢.

Sincerely
Meikel

[1]: http://kotka.de/projects/clojure/lazy-map.html
[2]: http://blog.thinkrelevance.com/2008/9/16/pcl-clojure




smime.p7s
Description: S/MIME cryptographic signature


Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread Chouser

On Tue, Nov 18, 2008 at 1:05 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Your implementation needs to get the whole value of pr-str before
> deciding that it is too long to put on a single line.

That's certainly what it does, but I don't think it has to.  My plan
was to use *print-length* and *print-level* to cause pr-str to bail
out if it's getting too long.  I can't decide if this general approach
is an ugly hack or an elegant re-use of existing code.

> But then, your implementation actually works and doesn't run out of
> stack space on short lists. :-)

I wanted to post what I had right away, but I will now take the time
to understand your code, so I can come up with own opinion about how
we ought to proceed.

--Chouser

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread [EMAIL PROTECTED]



On Nov 18, 12:53 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:

> As always: don't copy code blindly! Take a step back and look from a
> distance, how you can *translate* the code. For example, in the
> show-list-children function, the recursion is just used for iteration.
> It starts with x, do something to (first x) and then calls itself
> with (rest x). So the first step is to translate this into a loop
> recur pair. The next step is to see, that one can also write this
> as (doseq [child x] (do-something-to x)), or in case its the result
> you are interested in and not the side-effects: (map #(do-something-to
> %) x).
>
> So don't just copy the code, but understand what it does and then
> ask: "how would I do this in Clojure?"

Thanks for the advice. I think this works for show-list-children:

(defn insert-line [x y]
  (doc-concat x (doc-concat (doc-line) y)))

(defn show-list-children [x]
  (cond (empty? x)
(doc-nil)
(= (count x) 1)
(show (first x))
true
(reduce insert-line (map show x

Unfortunately the problem spot is:

(defmethod be :TEXT [w k d]
  (let [doc (second (first d))]
(struct Text :Text (:contents doc)
(be w (+ k (.length (:contents doc)))
(rest d)

which I think I'll need to make lazy somehow.

-- Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread [EMAIL PROTECTED]



On Nov 18, 1:12 pm, Chouser <[EMAIL PROTECTED]> wrote:
> On Tue, Nov 18, 2008 at 1:05 PM, [EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote:
>
> > Your implementation needs to get the whole value of pr-str before
> > deciding that it is too long to put on a single line.
>
> That's certainly what it does, but I don't think it has to.  My plan
> was to use *print-length* and *print-level* to cause pr-str to bail
> out if it's getting too long.  I can't decide if this general approach
> is an ugly hack or an elegant re-use of existing code.
>
> > But then, your implementation actually works and doesn't run out of
> > stack space on short lists. :-)
>
> I wanted to post what I had right away, but I will now take the time
> to understand your code, so I can come up with own opinion about how
> we ought to proceed.
>
> --Chouser

Thanks. I definitely recommend the original paper --
http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf --
even if you don't know Haskell. It's short and to the point.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



(new user) - Problem passing a double[][] to Java constructor.

2008-11-18 Thread everyman

Hi All.

I have been experimenting with the Java interop in Clojure by trying
to talk to the matrix maths library Jama:
(http://math.nist.gov/javanumerics/jama/doc/)

I can create a new Matrix if I specify row col integers for the
constructor and I have been able to read and write to the embedded
double array successfully, but I am failing to create a new matrix
from a converted vector.

The signature for the Java constructor I am trying to use is:
; Matrix(double[][] A)

(ns clojure-matrix
  (:import (Jama Matrix)))

clojure-matrix=> (new Matrix (to-array-2d [[1.0 2.0] [3.0 4.0]])))

java.lang.ClassCastException: [[Ljava.lang.Object; cannot be cast to
[[D
java.lang.ClassCastException: [[Ljava.lang.Object; cannot be cast to
[[D
at clojure_matrix.eval__2370.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:3891)
at clojure.lang.Repl.main(Repl.java:75)
clojure-matrix=> java.lang.Exception: Unmatched delimiter: )
java.lang.Exception: ReaderError:(105,1) Unmatched delimiter: )
at clojure.lang.LispReader.read(LispReader.java:164)
at clojure.lang.Repl.main(Repl.java:68)
Caused by: java.lang.Exception: Unmatched delimiter: )
at clojure.lang.LispReader$UnmatchedDelimiterReader.invoke
(LispReader.java:831)
at clojure.lang.LispReader.read(LispReader.java:130)
... 1 more
clojure-matrix=>

If I inspect the array produced by to-array-2d from closure the
elements look correct and are reported as doubles.

The Clojure is version is 20080916 (download from the Closure site).

Should this have worked?
Do I need do unbox (?) the doubles or something?
Suggestions welcome.

Thanks.
Chris

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Can functions be decompiled?

2008-11-18 Thread Shawn Hoover
On Tue, Nov 18, 2008 at 12:37 PM, Konrad Hinsen
<[EMAIL PROTECTED]>wrote:

>
> Is there a way to recover readable source code from a compiled
> function in Clojure? Debugging things like "[EMAIL PROTECTED]" is
> not much fun. It would already be a great help to be able to find out
> from where in the source code the function was compiled.
>
> Konrad.


For functions defined in libs that you load into Clojure, you can find out
the file and line from the metadata. For functions you define in the REPL,
this trick won't help. Say you have (defn myfn [] :test) in the user
namespace. ^#'user/myfn gets the metadata from the var that holds the
function. To get the file try (:file ^#'user/myfn). And for the line number,
(:line ^#'user/myfn).

Shawn

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread [EMAIL PROTECTED]



On Nov 18, 1:20 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> Thanks for the advice. I think this works for show-list-children:
>
> (defn insert-line [x y]
>   (doc-concat x (doc-concat (doc-line) y)))
>
> (defn show-list-children [x]
>   (cond (empty? x)
>         (doc-nil)
>         (= (count x) 1)
>         (show (first x))
>         true
>         (reduce insert-line (map show x

or maybe
(defn show-list-children [x]
  (if (empty? x)
(doc-nil)
(reduce insert-line (map show x

:-p

-- Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Adapting a functional pretty-printer to Clojure

2008-11-18 Thread steve...@acm.org

On Nov 18, 12:03 pm, Chouser <[EMAIL PROTECTED]> wrote:
> On Tue, Nov 18, 2008 at 11:29 AM, [EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote:
>
> > I looked at Wadler's "A Prettier Printer" paper (http://
> > homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf) and did a
> > rote translation of it into Clojure. Then I wrote printing routines
> > for sequences and maps -- very barebones. They work OK:
>
> I started working on a pretty-printer as well.  I wouldn't show it to
> anybody yet, but I also don't want any unnecessary duplicated effort.
> So I'll go ahead and show what I've got so far, and then we can decide
> how to proceed. I have no interest in pursuing my solution if it's not
> a good approach, or if anyone else would rather pursue it.
>
> That is, I want to use a pretty printer, not necessarily write one. :-)

I feel the same way, mostly.

I'm very new to Clojure and not all that experienced in Lisp or
functional programming in general. That's why I started with a port of
an existing skeletal implementation. I think the main advantage of
Wadler's approach -- not to be confused with my port, which I am sure
is in need of fixing-- is that it is bounded -- i.e. the decision to
print horizontally or vertically is made after looking ahead W
characters (W being the line width).

Your implementation needs to get the whole value of pr-str before
deciding that it is too long to put on a single line. But then, your
implementation actually works and doesn't run out of stack space on
short lists. :-)

On that topic, my pp function makes no sense -- it should use doseq to
take advantage of the laziness.

(defn pp
  ([obj width]
 (doseq char (pretty width (show obj))
   (print char)))
  ([obj]
 (pp obj 80)))



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (new user) - Problem passing a double[][] to Java constructor.

2008-11-18 Thread Chouser

On Tue, Nov 18, 2008 at 11:44 AM, everyman <[EMAIL PROTECTED]> wrote:
>
> The signature for the Java constructor I am trying to use is:
> ; Matrix(double[][] A)
>
> (ns clojure-matrix
>  (:import (Jama Matrix)))
>
> clojure-matrix=> (new Matrix (to-array-2d [[1.0 2.0] [3.0 4.0]])))
>
> java.lang.ClassCastException: [[Ljava.lang.Object; cannot be cast to
> [[D

Java arrays are a bit tricky because of the various types involved.
What you created is an array of Objects, each of which is an array of
Objects, each of which is a (big-D) Double, or a [[Ljava.lang.Object.
What you want to create is a [[D, or an array of Objects, each of
which is an array of (small-d) doubles.

This should build what you want:
user=> (def my-tricky-array (into-array (map #(into-array Double/TYPE
%) [[1 2][3 4]])))
#'user/my-tricky-array

Take a look at it, and see that the type signature looks good:
user=> my-tricky-array
#

To unpack it into Clojure seqs again:
user=> (map seq my-tricky-array)
((1.0 2.0) (3.0 4.0))

--Chouser

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure.contrib.test-is changes

2008-11-18 Thread Stuart Sierra

On Nov 18, 10:14 am, mb <[EMAIL PROTECTED]> wrote:
> This leads me to another question: Is it possible to look into
> pluggable harnesses? That is: can we separate the tests
> from the result reporting?

Yes, that's an important feature I want to add.  There will probably
be a reporting function that can be dynamically rebound.
-S
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Yegge would "probably" prefer Clojure

2008-11-18 Thread Stuart Sierra

Steve Yegge tried to implement JavaScript in Emacs Lisp:
http://steve-yegge.blogspot.com/2008/11/ejacs-javascript-interpreter-for-emacs.html

Choice parts:

"In the end, it comes down to personal choice. I've now written at
least 30,000 lines of serious code in both Emacs Lisp and
JavaScript, ...

"And I prefer JavaScript over Emacs Lisp.

"That said, I suspect I would *probably* prefer Clojure over Rhino
[JavaScript on the JVM], if I ever get a chance to sit down with the
durn thing and use it, so it's not so much "JavaScript vs. Lisp" as it
is vs. Emacs Lisp."

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Eager map?

2008-11-18 Thread Robert Ewald

On Tuesday 18 November 2008 08:20:15 mb wrote:
> Hi,
>
> On 18 Nov., 03:01, Adam Jones <[EMAIL PROTECTED]> wrote:
> > I'm in the middle of writing some code to extract sql results, which
> > means I'm doing a *lot* of forcing right now. It's almost enough for
> > me to wish there was a convention (and provided definitions) for
> > denoting lazy/strict versions of functions. (e.g. (map f ...) is a
> > lazy seq, (map! f ...) is strict)
>
> For what it's worth: I use the following convention.
>
> - For code which is purely done for side-effects, I use doseq. eg.
> (doseq [x some-seq] (println x))
>
> - In case I want to have the seq in memory, or there are side-effects
>   and I need the actual results, I use doall.
> (doall (map some-f some-seq))
>
> On the other hand: you can simply create your own map!.
>   (def map! (comp doall map))
>
> Just my 0.02€.
>
> Sincerely
> Meikel

Right, but this is precisely the reason for my asking. I was aware you could 
create a macro, but if I do that a lot nobody could read my code any longer. 
Everyone creating his own set of misguided utilities has been an argument 
against lisp, and I think this is a function of communication inside the 
community.

Using a ! to signify forcing is interesting, even though I am reserved because 
scheme is using it to signify side effects and clojure is not free from side 
effects.

Anyway, I suppose that doseq is the right idiom for communicating that you 
want throw away the results.

--
Robert Ewald

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (new user) - Problem passing a double[][] to Java constructor.

2008-11-18 Thread Shawn Hoover
On Tue, Nov 18, 2008 at 1:50 PM, Chouser <[EMAIL PROTECTED]> wrote:

>
> On Tue, Nov 18, 2008 at 11:44 AM, everyman <[EMAIL PROTECTED]>
> wrote:
> >
> > The signature for the Java constructor I am trying to use is:
> > ; Matrix(double[][] A)
> >
> > (ns clojure-matrix
> >  (:import (Jama Matrix)))
> >
> > clojure-matrix=> (new Matrix (to-array-2d [[1.0 2.0] [3.0 4.0]])))
> >
> > java.lang.ClassCastException: [[Ljava.lang.Object; cannot be cast to
> > [[D
> This should build what you want:
> user=> (def my-tricky-array (into-array (map #(into-array Double/TYPE
> %) [[1 2][3 4]])))
> #'user/my-tricky-array
>
> Take a look at it, and see that the type signature looks good:
> user=> my-tricky-array
> #
>

Here's a slight tweak using double-array instead of nested calls to
into-array (double-array isn't mentioned in clojure.org/java_interop page,
but it is in the full API listing):

user=> (into-array (map double-array [[1.0] [2.0]]))
#

Shawn

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (new user) - Problem passing a double[][] to Java constructor.

2008-11-18 Thread Chouser

On Tue, Nov 18, 2008 at 2:23 PM, Shawn Hoover <[EMAIL PROTECTED]> wrote:
>
> Here's a slight tweak using double-array instead of nested calls to
> into-array (double-array isn't mentioned in clojure.org/java_interop page,
> but it is in the full API listing):
>
> user=> (into-array (map double-array [[1.0] [2.0]]))
> #

Ah, nice.  Thanks.

--Chouser

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Can functions be decompiled?

2008-11-18 Thread Konrad Hinsen

On 18.11.2008, at 19:32, Shawn Hoover wrote:

> For functions defined in libs that you load into Clojure, you can  
> find out the file and line from the metadata. For functions you  
> define in the REPL, this trick won't help. Say you have (defn myfn  
> [] :test) in the user namespace. ^#'user/myfn gets the metadata  
> from the var that holds the function. To get the file try (:file  
> ^#'user/myfn). And for the line number, (:line ^#'user/myfn).

Thanks, that sounds useful already. Normally everything I have is  
defined in the REPL (through clojure-mode in Emacs), but I will  
happily load a bunch of functions from a file if that helps me  
debugging!

Konrad.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Can functions be decompiled?

2008-11-18 Thread Rich Hickey



On Nov 18, 2:48 pm, Konrad Hinsen <[EMAIL PROTECTED]> wrote:
> On 18.11.2008, at 19:32, Shawn Hoover wrote:
>
> > For functions defined in libs that you load into Clojure, you can
> > find out the file and line from the metadata. For functions you
> > define in the REPL, this trick won't help. Say you have (defn myfn
> > [] :test) in the user namespace. ^#'user/myfn gets the metadata
> > from the var that holds the function. To get the file try (:file
> > ^#'user/myfn). And for the line number, (:line ^#'user/myfn).
>
> Thanks, that sounds useful already. Normally everything I have is
> defined in the REPL (through clojure-mode in Emacs), but I will
> happily load a bunch of functions from a file if that helps me
> debugging!

You'll also get line numbers and local variable names in the
classfiles, for use by a Java debugger.

Rich

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Eager map?

2008-11-18 Thread Adam Jones



On Nov 18, 11:18 am, Robert Ewald <[EMAIL PROTECTED]> wrote:
> On Tuesday 18 November 2008 08:20:15 mb wrote:
>
>
>
> > Hi,
>
> > On 18 Nov., 03:01, Adam Jones <[EMAIL PROTECTED]> wrote:
> > > I'm in the middle of writing some code to extract sql results, which
> > > means I'm doing a *lot* of forcing right now. It's almost enough for
> > > me to wish there was a convention (and provided definitions) for
> > > denoting lazy/strict versions of functions. (e.g. (map f ...) is a
> > > lazy seq, (map! f ...) is strict)
>
> > For what it's worth: I use the following convention.
>
> > - For code which is purely done for side-effects, I use doseq. eg.
> >     (doseq [x some-seq] (println x))
>
> > - In case I want to have the seq in memory, or there are side-effects
> >   and I need the actual results, I use doall.
> >     (doall (map some-f some-seq))
>
> > On the other hand: you can simply create your own map!.
> >   (def map! (comp doall map))
>
> > Just my 0.02€.
>
> > Sincerely
> > Meikel
>
> Right, but this is precisely the reason for my asking. I was aware you could
> create a macro, but if I do that a lot nobody could read my code any longer.
> Everyone creating his own set of misguided utilities has been an argument
> against lisp, and I think this is a function of communication inside the
> community.
>
> Using a ! to signify forcing is interesting, even though I am reserved because
> scheme is using it to signify side effects and clojure is not free from side
> effects.

I used it as a shorthand for a similar bit of syntax in Haskell. There
$! is defined such that f $! x forces the evaluation of x before
handing it to f. map$! would be ugly, but I see your point about !.
(in fact, Clojure already uses this for set! on threadlocal vars)
Maybe map$ would be a good choice; it even sort of conveys the idea
that needlessly forcing a computation can be (spatially) expensive! =)

Ultimately the choice of a character to signify "this function is not
lazy" isn't a big issue, so long as it is 1. not confusing and 2.
vaguely memorable. Maybe Rich can step in with an opinion and settle
this.

-Adam

>
> Anyway, I suppose that doseq is the right idiom for communicating that you
> want throw away the results.
>
> --
> Robert Ewald
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (new user) - Problem passing a double[][] to Java constructor.

2008-11-18 Thread everyman


That has worked out very well, and its fast.
Thanks very much.

:-))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Test Coerced-BigDecimal in clojure.contrib.test-clojure throws an Exception

2008-11-18 Thread Jarkko Oranen

As stated in the subject line, the last test in numbers.clj
throws an exception because it is trying to cast an integer
into a BigDecimal, which is not possible.

This is on Mac OS X 10.5.5 with Java 1.5, the exception it fails with
is:
java.lang.IllegalArgumentException: No matching method found: valueOf

I don't think the exception itself is a bug. It seems coercing
Integers into bigdecimals
is something you're not supposed to do.

I can't submit a patch as I have no CA, but this would be trivial to
fix eg. by coercing a
double literal instead of an integer literal.

--
Jarkko
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Clojure in MathRider (an easy way for newbies to experiment with Clojure code)

2008-11-18 Thread Ted Kosan

I am in the process of developing a mathematics-oriented IDE called
MathRider and I have recently added Clojure to it.  One nice thing
about MathRider is that it provides a way for Clojure newbies to
quickly start experimenting with Clojure inside an IDE by downloading
and extracting a single file.  I have included some small example
Clojure programs in MathRider and I will be adding more in the future
(if anyone has additional example programs they would like to see
added to MathRider, send them to me and I will include them.)

MathRider can be downloaded from:

http://mathrider.org

Ted Kosan
ted.kosan at gmail.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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-11-18 Thread bc

In order to help prevent others from having problems with the slime
setup instructions in my earlier weblog post (http://bc.tech.coop/blog/
081023.html), I've added an update at the bottom of the post. I never
intended that post to be a tutorial for others to follow, it was
simply a recounting of what I did to get going with Clojure. I have
also written a new post which describes a simpler "newbie" set of
instructions that doesn't include SLIME (http://bc.tech.coop/blog/
081118.html).

--
Bill Clementson
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Test Coerced-BigDecimal in clojure.contrib.test-clojure throws an Exception

2008-11-18 Thread Stephen C. Gilardi
I think Clojure should change to allow (bigdec 3) to succeed.  
BigDecimal has a valueOf method that accepts a long. It has a  
constructor that accepts an int. I haven't made a bug report on this  
yet, but here it is.

Here are another thing that came up during testing of numbers:

I think the identity "(inc x) = (+ x 1)" should hold true for all  
Clojure numbers and the corresponding rule should hold for dec.

I've found there are a few cases where they don't:

user=> (+ Integer/MAX_VALUE 1)
2147483648
user=> (inc Integer/MAX_VALUE)
java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0)
user=> (- Integer/MIN_VALUE 1)
-2147483649
user=> (dec Integer/MIN_VALUE)
java.lang.ArithmeticException: integer overflow (NO_SOURCE_FILE:0)
user=> (+ Long/MAX_VALUE 1)
9223372036854775808
user=> (inc Long/MAX_VALUE)
-9223372036854775808
user=> (- Long/MIN_VALUE 1)
-9223372036854775809
user=> (dec Long/MIN_VALUE)
9223372036854775807
user=>

I was also going to request that integer? be true for Shorts and Bytes  
but I'm pleased to see that change has already been made.

Thanks,

--Steve

On Nov 18, 2008, at 4:46 PM, Jarkko Oranen wrote:

>
> As stated in the subject line, the last test in numbers.clj
> throws an exception because it is trying to cast an integer
> into a BigDecimal, which is not possible.
>
> This is on Mac OS X 10.5.5 with Java 1.5, the exception it fails with
> is:
> java.lang.IllegalArgumentException: No matching method found: valueOf
>
> I don't think the exception itself is a bug. It seems coercing
> Integers into bigdecimals
> is something you're not supposed to do.
>
> I can't submit a patch as I have no CA, but this would be trivial to
> fix eg. by coercing a
> double literal instead of an integer literal.
>
> --
> Jarkko
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: offtopic - where are you come from? (poll)

2008-11-18 Thread Jeff Rose

Originally from San Francisco, and now living in Amsterdam.   This has
been fun already.  I think Clojure is going to make it.

-Jeff

Chanwoo Yoo wrote:
> Seoul, South Korea, which LG and Samsung are belongs to (I know there
> is few who knows where South Korea is. ^_^; It is placed between China
> and Japan.)
> 
> On 10월22일, 오후10시07분, perdalum <[EMAIL PROTECTED]> wrote:
>> Aarhus, Denmark
>>
>> On 17 Okt., 11:27, "Rastislav Kassak" <[EMAIL PROTECTED]> wrote:
>>
>>> Hello Clojurians,
>>> I think after 1st year of Clojure life it's good to check how far has
>>> Clojure spread all over the world.
>>> So wherever are you come from, be proud and say it.
>>> I'm from Slovakia. :)
>>> RK
> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



General question, what are using for clojure?

2008-11-18 Thread BerlinBrown

What projects have you used clojure for?  Have you completed them? Are
they one-off projects.  Small big?  Is it web based, a GUI?

I am working on this, haven't made much progress but at least I
started.

http://code.google.com/p/botnodetoolkit/

And if you are interested, post your project here.  I am the
maintainer.

http://www.reddit.com/r/codeprojects/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: thanks, errata, and one gaffe

2008-11-18 Thread Christopher Taylor

Stuart,

I'd be very interested to see something on Ties 
(http://www.bitbucket.org/achimpassen/clojure-ties/wiki/Home 
), which while not being in clojure-contrib, shows lots of promise.

all the best,
   --Chris
On 17.11.2008, at 15:13, Stuart Halloway wrote:

>
> Hi Brian,
>
> The libraries chapter will cover a bunch of different libraries in
> Clojure-Contrib and elsewhere. Obviously, being only one chapter, it
> won't go terribly deep. I'd love to hear what folks want to see. I am
> planning on at least:
>
> * db
> * web apps
> * testing/BDD
> * zipper
>
>>
>> Stuart:
>>
>> I read through the table of contents. Are you planning on addressing
>> interacting with a database (preferably postgres or mysql) in
>> Clojure?
>>
>> Maybe the "Working with Java" chapter will be sufficient, but one of
>> the benefits of Clojure is "batteries included", so helping folks get
>> up to speed with a db example would be great.
>>
>> Brian
>>
>>>
>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure.contrib.test-is changes

2008-11-18 Thread Meikel Brandmeyer

Hello,

as previously threatened here the anatomy of my TAP library.

The testing and reporting is split in separate parts. The testing
part provides is as main interface. I first followed Perl's Test::More,
but thought it would be better to be closer to test-is. So I adopted
is, but - as I think - in slightly easier fashion.

The core is (as with test-is) the is macro, which is implemented
as a multimethod. Since there is no multimacro, we use is* for
the method.

(defmulti is* (fn [x & _] (if (seq? t) (first t) t)))
(defmacro is [t & desc] (is* t (first desc)))

Now we can start to define tests.

; (is (= actual expected) "description")
(defmethod is* '=
  [t desc]
  (let [actual (nth t 1)
exptd  (nth t 2)]
`(test-driver (fn [] ~actual)
  (quote ~actual)
  (fn [] ~exptd)
  ~desc
  (fn [e# a#] (= e# a#))
  (fn [e# a# r#]
(diag (.concat "Expected: " a#))
(diag (.concat "to be:" e#))
(diag (.concat "but was:  " r#))

Now this looks scary. So please let me explain. The first argument
packages about the "actual" expression. The second quotes it. The
third is the "expected" expression. It is also packaged up in a
closure. The fourth is the test description and the fifth the actual
test. The last argument is a callback, which is called in case the
test fails and which might be used to provide specialised diagnostic
message. I like having my tests tell me, why they failed.

While this seems quite complicated, I think it really is this essence
of a test. Everything else is boilerplate which is handled in the
test-driver function.

(defn test-driver
  [actual qactual exp desc pred diagnose]
  (try
(let [e (exp)
  a (actual)
  r (pred e a)]
  (report-result r desc)
  (when-not r
(let [es (pr-str e)
  as (pr-str qactual)
  rs (pr-str a)]
  (diagnose es as rs)))
  a)
(catch Exception e
  (report-result false desc)
  (diag (str "Exception was thrown: " e))
  `test-failed)))

So this is pretty straightforward. Fire up a try, evaluate the
expected and actual expression, run the predicate and check the
result. In case the test fails or an Exception is thrown, the
failure is reported and some diagnostics are printed.

So that completes the testing part. From the user point of
view one has function - is -, which handles all the testing.
To provide a new test form, one simply defines a new method.
In the method, one simply passes the work to test-driver which
takes care for reporting and proper test execution.

The reporting side already showed up here and there in form of
the diag and the report-result functions. Others are plan (for
TAP), get-result to retrieve the test results. They act on a
global Var *the-harness*. They can also be implemented as
multimethods. A TAP harness would produce TAP output, an
"interactive" harness would only report failures and maybe some
statistics, a "batch" harness just keeps book of failing tests
and diagnostics for recursive use.

Changing a harness is a simple matter of

(binding [*the-harness* (make-some-harness)]
  (do-some tests here))

Although this looks terribly complicated and is a hard to
digest bunch of stuff, I'd appreciate your comments. However,
how this can be made more functional... I have no clue.

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


strings

2008-11-18 Thread joejoe

hello all,
so I'm not only new to this group but I am new to Clojure.  I may be
going about this all wrong but here's what I got.  I want to simply
take a string and reverse it, ex: "I am cold" would become "cold am
I" (haha I just realized that's probably how yoda would say it).  So
for now I am hard coding my string, so "myString" ="I am cold".

How I am thinking of doing this is as follows:

(loop [i 0]
(when (< i (count myString))
//missing code
//
//
(recur (inc i

so this probably isn't a hard thing to do but like I said I am new to
this all.  I basically need to figure out a way to print each element
of myString one at a time, this would allow me to figure out how to
reverse it.

so to my simple question, is it possible it print each element of a
string independently?

I know about (first myString), which will give me I printed out three
times.  So it seems there has to be a way and I just can't seem to
figure it out.

thanks for any input!

-joejoe

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: offtopic - where are you come from? (poll)

2008-11-18 Thread Timothy Pratley

Hobart, Australia
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



(Newbie) Are lexically-scoped methods possible?

2008-11-18 Thread samppi

I'm trying to unit-test a library with which a user can define methods
on the library's multi-function to change its behavior. So I need to
be able to define lexically-scoped methods in each test. Is it
possible to use let to create a lexically-scoped method?

The problems I'm encountering are that, unlike for functions, there
doesn't seem to be a special-form for creating methods, and that even
if it could be defined it'd go in the current namespace instead of the
library's namespace. But does anyone know how I can test this anyway?

Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



clojure slime

2008-11-18 Thread islon

I checkouted the last clojure from svn, swank-clojure and clojure-mode
too.
When I start slime it give me the following errors:

Clojure
user=> (add-classpath "file:home/islon/opt/swank-clojure/")
nil
user=>
(require (quote swank))
java.lang.Exception: No such var: swank.util/gen-and-load-class
(core.clj:39)
user=>
(swank/ignore-protocol-version "2008-11-02")
java.lang.Exception: No such var: swank/ignore-protocol-version
(NO_SOURCE_FILE:5)
user=>
(swank/start-server "/tmp/slime.22694" :encoding "iso-latin-1-unix")
java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:
7)
user=>

It worked until I update clojure from svn.
Any ideas?

Regards.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure slime

2008-11-18 Thread Bill Clementson

On Tue, Nov 18, 2008 at 5:01 PM, islon <[EMAIL PROTECTED]> wrote:
>
> I checkouted the last clojure from svn, swank-clojure and clojure-mode
> too.
> When I start slime it give me the following errors:
>
> Clojure
> user=> (add-classpath "file:home/islon/opt/swank-clojure/")
> nil
> user=>
> (require (quote swank))
> java.lang.Exception: No such var: swank.util/gen-and-load-class
> (core.clj:39)
> user=>
> (swank/ignore-protocol-version "2008-11-02")
> java.lang.Exception: No such var: swank/ignore-protocol-version
> (NO_SOURCE_FILE:5)
> user=>
> (swank/start-server "/tmp/slime.22694" :encoding "iso-latin-1-unix")
> java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:
> 7)
> user=>
>
> It worked until I update clojure from svn.
> Any ideas?

There was a change done today to provide AOT/gen-class support.
Unfortunately, it breaks swank-clojure. So, your options are:

1. Grab an earlier version of Clojure from svn
2. Don't use slime in emacs (http://bc.tech.coop/blog/081118.html)
3. Fix the swank-clojure breakage

- Bill

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread islon

(defn string-reverse [s]
  (reduce #(str %1 " " %2) (reverse (seq (. s (split " "))

You're probably looking for something like this =)

On Nov 18, 9:00 pm, joejoe <[EMAIL PROTECTED]> wrote:
> hello all,
> so I'm not only new to this group but I am new to Clojure.  I may be
> going about this all wrong but here's what I got.  I want to simply
> take a string and reverse it, ex: "I am cold" would become "cold am
> I" (haha I just realized that's probably how yoda would say it).  So
> for now I am hard coding my string, so "myString" ="I am cold".
>
> How I am thinking of doing this is as follows:
>
> (loop [i 0]
> (when (< i (count myString))
> //missing code
> //
> //
> (recur (inc i
>
> so this probably isn't a hard thing to do but like I said I am new to
> this all.  I basically need to figure out a way to print each element
> of myString one at a time, this would allow me to figure out how to
> reverse it.
>
> so to my simple question, is it possible it print each element of a
> string independently?
>
> I know about (first myString), which will give me I printed out three
> times.  So it seems there has to be a way and I just can't seem to
> figure it out.
>
> thanks for any input!
>
> -joejoe
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure slime

2008-11-18 Thread Stephen C. Gilardi
SVN version 1110 of Clojure made a breaking change to a feature that  
swank-clojure is using. For now, I recommend moving back one rev by  
using:

svn up -r 1109

from within your checkout of clojure/trunk.

In the past, Jeff has updated swank-clojure very quickly on those rare  
occasions where Clojure changes enough to break it. Stay tuned.

--Steve

On Nov 18, 2008, at 8:01 PM, islon wrote:

>
> I checkouted the last clojure from svn, swank-clojure and clojure-mode
> too.
> When I start slime it give me the following errors:
>
> Clojure
> user=> (add-classpath "file:home/islon/opt/swank-clojure/")
> nil
> user=>
> (require (quote swank))
> java.lang.Exception: No such var: swank.util/gen-and-load-class
> (core.clj:39)
> user=>
> (swank/ignore-protocol-version "2008-11-02")
> java.lang.Exception: No such var: swank/ignore-protocol-version
> (NO_SOURCE_FILE:5)
> user=>
> (swank/start-server "/tmp/slime.22694" :encoding "iso-latin-1-unix")
> java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:
> 7)
> user=>
>
> It worked until I update clojure from svn.
> Any ideas?
>
> Regards.
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread Mark Volkmann

Here's another solution that came from help on the chat. Thanks Chouser!

(apply str (interpose " " (reverse (.split "I am cold" " "

On Tue, Nov 18, 2008 at 7:15 PM, islon <[EMAIL PROTECTED]> wrote:
>
> (defn string-reverse [s]
>  (reduce #(str %1 " " %2) (reverse (seq (. s (split " "))
>
> You're probably looking for something like this =)
>
> On Nov 18, 9:00 pm, joejoe <[EMAIL PROTECTED]> wrote:
>> hello all,
>> so I'm not only new to this group but I am new to Clojure.  I may be
>> going about this all wrong but here's what I got.  I want to simply
>> take a string and reverse it, ex: "I am cold" would become "cold am
>> I" (haha I just realized that's probably how yoda would say it).  So
>> for now I am hard coding my string, so "myString" ="I am cold".
>>
>> How I am thinking of doing this is as follows:
>>
>> (loop [i 0]
>> (when (< i (count myString))
>> //missing code
>> //
>> //
>> (recur (inc i
>>
>> so this probably isn't a hard thing to do but like I said I am new to
>> this all.  I basically need to figure out a way to print each element
>> of myString one at a time, this would allow me to figure out how to
>> reverse it.
>>
>> so to my simple question, is it possible it print each element of a
>> string independently?
>>
>> I know about (first myString), which will give me I printed out three
>> times.  So it seems there has to be a way and I just can't seem to
>> figure it out.
>>
>> thanks for any input!
>>
>> -joejoe
> >
>



-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread Kevin Downey

(apply str (reverse "I am cold"))

shorter and it does the same thing. no need to take out the spaces and
put them back in

On Tue, Nov 18, 2008 at 5:21 PM, Mark Volkmann
<[EMAIL PROTECTED]> wrote:
>
> Here's another solution that came from help on the chat. Thanks Chouser!
>
> (apply str (interpose " " (reverse (.split "I am cold" " "
>
> On Tue, Nov 18, 2008 at 7:15 PM, islon <[EMAIL PROTECTED]> wrote:
>>
>> (defn string-reverse [s]
>>  (reduce #(str %1 " " %2) (reverse (seq (. s (split " "))
>>
>> You're probably looking for something like this =)
>>
>> On Nov 18, 9:00 pm, joejoe <[EMAIL PROTECTED]> wrote:
>>> hello all,
>>> so I'm not only new to this group but I am new to Clojure.  I may be
>>> going about this all wrong but here's what I got.  I want to simply
>>> take a string and reverse it, ex: "I am cold" would become "cold am
>>> I" (haha I just realized that's probably how yoda would say it).  So
>>> for now I am hard coding my string, so "myString" ="I am cold".
>>>
>>> How I am thinking of doing this is as follows:
>>>
>>> (loop [i 0]
>>> (when (< i (count myString))
>>> //missing code
>>> //
>>> //
>>> (recur (inc i
>>>
>>> so this probably isn't a hard thing to do but like I said I am new to
>>> this all.  I basically need to figure out a way to print each element
>>> of myString one at a time, this would allow me to figure out how to
>>> reverse it.
>>>
>>> so to my simple question, is it possible it print each element of a
>>> string independently?
>>>
>>> I know about (first myString), which will give me I printed out three
>>> times.  So it seems there has to be a way and I just can't seem to
>>> figure it out.
>>>
>>> thanks for any input!
>>>
>>> -joejoe
>> >
>>
>
>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> >
>



-- 
The Mafia way is that we pursue larger goals under the guise of
personal relationships.
Fisheye

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread islon

It doesn't work:
(apply str (reverse "i am cold"))
"dloc ma i"

The correct output is "cold am i". You must reverse words not letters.

On Nov 18, 11:33 pm, "Kevin Downey" <[EMAIL PROTECTED]> wrote:
> (apply str (reverse "I am cold"))
>
> shorter and it does the same thing. no need to take out the spaces and
> put them back in
>
> On Tue, Nov 18, 2008 at 5:21 PM, Mark Volkmann
>
>
>
> <[EMAIL PROTECTED]> wrote:
>
> > Here's another solution that came from help on the chat. Thanks Chouser!
>
> > (apply str (interpose " " (reverse (.split "I am cold" " "
>
> > On Tue, Nov 18, 2008 at 7:15 PM, islon <[EMAIL PROTECTED]> wrote:
>
> >> (defn string-reverse [s]
> >>  (reduce #(str %1 " " %2) (reverse (seq (. s (split " "))
>
> >> You're probably looking for something like this =)
>
> >> On Nov 18, 9:00 pm, joejoe <[EMAIL PROTECTED]> wrote:
> >>> hello all,
> >>> so I'm not only new to this group but I am new to Clojure.  I may be
> >>> going about this all wrong but here's what I got.  I want to simply
> >>> take a string and reverse it, ex: "I am cold" would become "cold am
> >>> I" (haha I just realized that's probably how yoda would say it).  So
> >>> for now I am hard coding my string, so "myString" ="I am cold".
>
> >>> How I am thinking of doing this is as follows:
>
> >>> (loop [i 0]
> >>> (when (< i (count myString))
> >>> //missing code
> >>> //
> >>> //
> >>> (recur (inc i
>
> >>> so this probably isn't a hard thing to do but like I said I am new to
> >>> this all.  I basically need to figure out a way to print each element
> >>> of myString one at a time, this would allow me to figure out how to
> >>> reverse it.
>
> >>> so to my simple question, is it possible it print each element of a
> >>> string independently?
>
> >>> I know about (first myString), which will give me I printed out three
> >>> times.  So it seems there has to be a way and I just can't seem to
> >>> figure it out.
>
> >>> thanks for any input!
>
> >>> -joejoe
>
> > --
> > R. Mark Volkmann
> > Object Computing, Inc.
>
> --
> The Mafia way is that we pursue larger goals under the guise of
> personal relationships.
>     Fisheye
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure slime

2008-11-18 Thread islon

I'll not use slime right now (thanks Bill).
swank-clojure will be fixed anytime soon?

On Nov 18, 11:15 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> SVN version 1110 of Clojure made a breaking change to a feature that  
> swank-clojure is using. For now, I recommend moving back one rev by  
> using:
>
> svn up -r 1109
>
> from within your checkout of clojure/trunk.
>
> In the past, Jeff has updated swank-clojure very quickly on those rare  
> occasions where Clojure changes enough to break it. Stay tuned.
>
> --Steve
>
> On Nov 18, 2008, at 8:01 PM, islon wrote:
>
>
>
> > I checkouted the last clojure from svn, swank-clojure and clojure-mode
> > too.
> > When I start slime it give me the following errors:
>
> > Clojure
> > user=> (add-classpath "file:home/islon/opt/swank-clojure/")
> > nil
> > user=>
> > (require (quote swank))
> > java.lang.Exception: No such var: swank.util/gen-and-load-class
> > (core.clj:39)
> > user=>
> > (swank/ignore-protocol-version "2008-11-02")
> > java.lang.Exception: No such var: swank/ignore-protocol-version
> > (NO_SOURCE_FILE:5)
> > user=>
> > (swank/start-server "/tmp/slime.22694" :encoding "iso-latin-1-unix")
> > java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:
> > 7)
> > user=>
>
> > It worked until I update clojure from svn.
> > Any ideas?
>
> > Regards.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread joejoe

thanks guys( or gals!)  Yeah I got so fed up with trying to do it I
almost gave up, then I found the (reverse string).  Wow, one word does
what I was trying to do.  Oh well, I guess I'll try to finish doing it
the long way to learn it.  Thanks for the fast replies! :)

On Nov 18, 6:00 pm, joejoe <[EMAIL PROTECTED]> wrote:
> hello all,
> so I'm not only new to this group but I am new to Clojure.  I may be
> going about this all wrong but here's what I got.  I want to simply
> take a string and reverse it, ex: "I am cold" would become "cold am
> I" (haha I just realized that's probably how yoda would say it).  So
> for now I am hard coding my string, so "myString" ="I am cold".
>
> How I am thinking of doing this is as follows:
>
> (loop [i 0]
> (when (< i (count myString))
> //missing code
> //
> //
> (recur (inc i
>
> so this probably isn't a hard thing to do but like I said I am new to
> this all.  I basically need to figure out a way to print each element
> of myString one at a time, this would allow me to figure out how to
> reverse it.
>
> so to my simple question, is it possible it print each element of a
> string independently?
>
> I know about (first myString), which will give me I printed out three
> times.  So it seems there has to be a way and I just can't seem to
> figure it out.
>
> thanks for any input!
>
> -joejoe
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread Timothy Pratley

If your new to Clojure, such a succinct solution might be a little
confusing... so I've broken islon's solution down into its parts:

> (defn string-reverse [s]
>   (reduce #(str %1 " " %2) (reverse (seq (. s (split " "))

The main part of your problem is that you want to pick out words. In
the solution provided by islon this is done with the standard java
string function "split".
(. s (split " "))
Is one way to use the built in java interop to essenitally do this:
***java***   string words[] = s.split(" ");
you can also write this as
(.split s " ")  *** see clojure java interop section for more
info

This is pretty typical in clojure, most of the low level string etc
stuff you just use the java API as it has a ready made solution.

Clojure part:
(reverse (seq
Pretty obvious really, the array of strings is converted to a sequence
which is reversed, which is what you wanted to do with the words.
reverse is a common operation used on sequences. It is interesting to
note that you don't need (seq at all really... so you can just leave
that out. There is a heap of support for sequence operations in
Clojure that make things really simple and concise
user=> (reverse (.split "you will become jedi" " "))
("jedi" "become" "will" "you")

This is probably all you want to do, but its nice to put it in a
function
(defn word-reverse [s]
   (reverse (.split s " ")))

Now you can call your new function:
user=> (word-reverse "well done padawan")
("padawan" "done" "well")

(reduce #(str %1 " " %2) (reverse))
Hard on the eyes, but all this does is take the sequence of words and
glue them together into a single string... so that instead of
returning a list of words the function will return a string.
#(str %1 " " %2)   is a special form lambda function
ie: it is just a temporary inline function which is going to be passed
to another function
in this case the function takes 2 arguments and makes a string out of
them in the form
"%1 %2"  where %1 is arg1 and %2 is arg2
[http://clojure.org/reader] explains #(...)  in more detail
(reduce is a function which takes a function as its first argument
and calls that function on a supplied sequence. See the api doc for a
more correct definition... but for our purposes the code says:
(forallwords temporyjoinwordfunction allwords)
So calling this results in a single string
user=> (reduce #(str %1 " " %2) (reverse (.split "you will become
jedi" " ")))
"jedi become will you"
Notice that instead of getting separate words, you get a full string.

Temporary functions and passing functions to functions is one of the
really powerful parts of any Lisp, so it is worth learning about it in
detail and not be tempted to gloss over it.

Regards,
Tim.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: strings

2008-11-18 Thread Dave Newton

--- On Tue, 11/18/08, joejoe wrote:
> Yeah I got so fed up with trying to do it I
> almost gave up, then I found the (reverse string).

That doesn't actually do what your spec said, though.

Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



A request for clojure code critique

2008-11-18 Thread Scott Fleckenstein

So, I'm starting to get my feet wet with a real project written in
Clojure.  One of the first things needed in the project is a periodic
process to check an external server for updates, and so I wrote some
functions to help this.  The code is here:
http://pastie.textmate.org/private/1q0c0ydhvdjlzssc896k1w

I'm new to Clojure, for that matter any Lisp, so I'm wondering what I
could do better with that code.  Am I doing anything blatantly wrong?

Basically, there are four functions: send-after, send-off-after, send-
periodically, and send-off periodically.  They leverage the agent
system, and mirror the send/send-off functions.  The -after variants
are one shot sends that wait for a specified timeout and then send,
whereas the -periodically variants repeatedly send using the given
interval.

Thanks,
Scott Fleckenstein
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: General question, what are using for clojure?

2008-11-18 Thread Allen Rohner

On Nov 18, 5:16 pm, BerlinBrown <[EMAIL PROTECTED]> wrote:
> What projects have you used clojure for?  Have you completed them? Are
> they one-off projects.  Small big?  Is it web based, a GUI?
>
> I am working on this, haven't made much progress but at least I
> started.
>
> http://code.google.com/p/botnodetoolkit/
>
> And if you are interested, post your project here.  I am the
> maintainer.
>
> http://www.reddit.com/r/codeprojects/

I am working on a startup webapp written in clojure and compojure,
using statistics and simple AI techniques. It's not done yet, but I'll
definitely post it here once it's public.

Allen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (Newbie) Are lexically-scoped methods possible?

2008-11-18 Thread Allen Rohner


On Nov 18, 6:48 pm, samppi <[EMAIL PROTECTED]> wrote:
> I'm trying to unit-test a library with which a user can define methods
> on the library's multi-function to change its behavior. So I need to
> be able to define lexically-scoped methods in each test. Is it
> possible to use let to create a lexically-scoped method?
>
> The problems I'm encountering are that, unlike for functions, there
> doesn't seem to be a special-form for creating methods, and that even
> if it could be defined it'd go in the current namespace instead of the
> library's namespace. But does anyone know how I can test this anyway?
>
> Thanks in advance!

Yes, this is all possible.

fn is the special form that creates new functions.

(fn [x] (* x x)) returns an anonymous function.

You can also use let to assign names to the anonymous functions:

(let [foo (fn [x] (* x x))
(println (foo 3))

defn is a macro that translates to

(def name (fn [args] ...))

Allen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (Newbie) Are lexically-scoped methods possible?

2008-11-18 Thread samppi

Yes, but I meant creating methods rather than regular functions, in a
lexical scope. Is it possible to create methods using fn?

On Nov 18, 10:47 pm, Allen Rohner <[EMAIL PROTECTED]> wrote:
> On Nov 18, 6:48 pm, samppi <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to unit-test a library with which a user can define methods
> > on the library's multi-function to change its behavior. So I need to
> > be able to define lexically-scoped methods in each test. Is it
> > possible to use let to create a lexically-scoped method?
>
> > The problems I'm encountering are that, unlike for functions, there
> > doesn't seem to be a special-form for creating methods, and that even
> > if it could be defined it'd go in the current namespace instead of the
> > library's namespace. But does anyone know how I can test this anyway?
>
> > Thanks in advance!
>
> Yes, this is all possible.
>
> fn is the special form that creates new functions.
>
> (fn [x] (* x x)) returns an anonymous function.
>
> You can also use let to assign names to the anonymous functions:
>
> (let [foo (fn [x] (* x x))
>     (println (foo 3))
>
> defn is a macro that translates to
>
> (def name (fn [args] ...))
>
> Allen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: General question, what are using for clojure?

2008-11-18 Thread Geoffrey Teale
2008/11/19 Allen Rohner <[EMAIL PROTECTED]>

>
> On Nov 18, 5:16 pm, BerlinBrown <[EMAIL PROTECTED]> wrote:
> > What projects have you used clojure for?  Have you completed them? Are
> > they one-off projects.  Small big?  Is it web based, a GUI?
> >
> > I am working on this, haven't made much progress but at least I
> > started.
> >
> > http://code.google.com/p/botnodetoolkit/
> >
> > And if you are interested, post your project here.  I am the
> > maintainer.
> >
> > http://www.reddit.com/r/codeprojects/
>
> I am working on a startup webapp written in clojure and compojure,
> using statistics and simple AI techniques. It's not done yet, but I'll
> definitely post it here once it's public.
>
> My first serious project was a fairly mundane database maintenance
application.   It's live, but there are still new requirements coming in.  I
made the decision to try porting it to use a Qt a couple of weeks ago as I
rediscovered how much I hate Swing.

Along the way I have found out a little about how to interact with Java
libraries and I've gained a little knowledge about vars, refs and agents.
So far this has been a thoroughly worthwhile project, but I would like to do
something with more concurrency next.

-- 
Geoff

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (Newbie) Are lexically-scoped methods possible?

2008-11-18 Thread Allen Rohner


On Nov 18, 11:53 pm, samppi <[EMAIL PROTECTED]> wrote:
> Yes, but I meant creating methods rather than regular functions, in a
> lexical scope. Is it possible to create methods using fn?
>

What do you mean by methods as distinct from functions? In clojure
there are only functions. Are you referring to Java methods?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure slime

2008-11-18 Thread Jeffrey Chu

Sorry for the inconvenience. It's been fixed. - Jeff

On Nov 18, 5:41 pm, islon <[EMAIL PROTECTED]> wrote:
> I'll not use slime right now (thanks Bill).
> swank-clojure will be fixed anytime soon?
>
> On Nov 18, 11:15 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
>
> > SVN version 1110 of Clojure made a breaking change to a feature that  
> > swank-clojure is using. For now, I recommend moving back one rev by  
> > using:
>
> > svn up -r 1109
>
> > from within your checkout of clojure/trunk.
>
> > In the past, Jeff has updated swank-clojure very quickly on those rare  
> > occasions where Clojure changes enough to break it. Stay tuned.
>
> > --Steve
>
> > On Nov 18, 2008, at 8:01 PM, islon wrote:
>
> > > I checkouted the last clojure from svn, swank-clojure and clojure-mode
> > > too.
> > > When I start slime it give me the following errors:
>
> > > Clojure
> > > user=> (add-classpath "file:home/islon/opt/swank-clojure/")
> > > nil
> > > user=>
> > > (require (quote swank))
> > > java.lang.Exception: No such var: swank.util/gen-and-load-class
> > > (core.clj:39)
> > > user=>
> > > (swank/ignore-protocol-version "2008-11-02")
> > > java.lang.Exception: No such var: swank/ignore-protocol-version
> > > (NO_SOURCE_FILE:5)
> > > user=>
> > > (swank/start-server "/tmp/slime.22694" :encoding "iso-latin-1-unix")
> > > java.lang.Exception: No such var: swank/start-server (NO_SOURCE_FILE:
> > > 7)
> > > user=>
>
> > > It worked until I update clojure from svn.
> > > Any ideas?
>
> > > Regards.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (Newbie) Are lexically-scoped methods possible?

2008-11-18 Thread mb

Hi,

On 19 Nov., 06:53, samppi <[EMAIL PROTECTED]> wrote:
> Yes, but I meant creating methods rather than regular functions, in a
> lexical scope. Is it possible to create methods using fn?

(ns foo)

(defmulti bar ...)

(ns foo.test)

(defmethod foo/bar ...)

One can also use the MultiFn Java methods directly, although
I don't know, in how far this is allowed.

(.addMethod foo/bar :MyDispatch (fn [x] ))

Hope this helps.

Sincerely
Meikel


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---