Re: Mapping a function to a map

2010-09-07 Thread Thomas
I've also been using my own version of a map-to-values function
extensively and it would be really nice to have something like that,
either in contrib or in core. It comes in handy surprisingly often.

Best,

Thomas

On Sep 6, 5:40 pm, Nicolas Oury  wrote:
> Dear all,
>
> is there a function to map a function to all values in a map, keeping
> the same keys?
> Reducing from the seqed map seems a bit slower that what could be done
> directly...
>
> Best,
>
> Nicolas.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: "Binding" and temporary global state

2010-09-07 Thread Michael Wood
On 6 September 2010 23:22, Cameron Pulsford  wrote:
[...]
> Changing my declares to defs did the trick did though and learning

Does this break it again?

(do (def *macros*))

Because that's all that declare does:

user=> (macroexpand-1 '(declare *macros*))
(do (def *macros*))

-- 
Michael Wood 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Mark Engelberg
Docstrings seem designed for fairly terse comments about the nature of
the function.  It's great for providing little hints about how the
function works to jog one's memory by typing (doc ...) in the REPL, or
for searching with find-doc.  But I just don't think I can fit the
kind of full documentation I want all into a docstring without ruining
its REPL usefulness.

My instinct is to put those sorts of things into comments. I think
adding a huge Clojure metadata map in front of the var would hinder
code readability.  Hmmm, I wonder if maybe there would be a way to use
a macro to add metadata to the var separate from the function?  E.g.,
(document my-function metadata)  That might make the metadata approach
more palatable...

As a side note, I wish Clojure had some sort of block commenting
capability.  Both (comment ...) and #_ require well formed code to
follow and sometimes it's just nice to be able to comment out a block
of text.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Laurent PETIT
Hi,

2010/9/7 Mark Engelberg :
> Docstrings seem designed for fairly terse comments about the nature of
> the function.  It's great for providing little hints about how the
> function works to jog one's memory by typing (doc ...) in the REPL, or
> for searching with find-doc.  But I just don't think I can fit the
> kind of full documentation I want all into a docstring without ruining
> its REPL usefulness.

Indeed. Though the docstring for e.g. gen-class is quite extensive and
could serve as a counter-example.
Javadoc has an interesting property: it considers that the first
sentence serves as a summary for the doc. The "sentence" delimiter is
just the point in the case of javadoc.
Out of my head: instead of writing doc in several places, maybe
something "like that" could be used. it could be associated with some
clojure.core/*short-docstring* global var that (doc), (find-doc) could
use for displaying the short or full form ?

> My instinct is to put those sorts of things into comments. I think
> adding a huge Clojure metadata map in front of the var would hinder
> code readability.  Hmmm, I wonder if maybe there would be a way to use
> a macro to add metadata to the var separate from the function?  E.g.,
> (document my-function metadata)  That might make the metadata approach
> more palatable...

Sure. A lot of things are already placed as metadata of the var and
not of the function the var is holding, anyway.

> As a side note, I wish Clojure had some sort of block commenting
> capability.  Both (comment ...) and #_ require well formed code to
> follow and sometimes it's just nice to be able to comment out a block
> of text.

I remember having seen #|  |# block commenting reader macro to be
on the todo list of Rich, many months ago.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: agents, await and Swing thread

2010-09-07 Thread Mark Nutter
Just a quick thought (and before I've had my coffee no less!), but I
think what I'd do is replace the boolean *end-search* with a
*search-state* var that could be either :idle, :running or :stopping.
Then in search-stops, just set *search-state* to :stopping -- you
don't need to actually wait for the agents to finish, you just need to
know that the current condition is "waiting for the search to end" so
you don't quit the app or start a new search until the cleanup is
finished. Then when you do hit some task that needs to wait until the
agents are done, you can go ahead and await the agents (i.e. if you're
quitting and it doesn't matter if there's a hang), or spawn a thread
that will await the agents before starting the new search. You could
also run a cleanup thread that would check the state of your search
agents and set the *search-state* from :stopping back to :idle once
all the search agents had finished.

Mark

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: external clojure lib >

2010-09-07 Thread Abraham Varghese
Hello Sunil ,

Using windows xp , just got into clojure , not much knowledge

Thanks
AV

On Sep 6, 8:00 pm, Sunil S Nandihalli 
wrote:
> Hi Abraham,
>  Make sure that the jar file of the "external" library you are referring to
> is in path. If you are developing clojure code .. I would strongly advice
> you to use leiningen which takes care of a lot of these things for you. Btw.
> what is the "development environment" you are using? ..
>
> Try to be a little more elaborate when you ask questions like these..
> Sunil.
>
> On Mon, Sep 6, 2010 at 3:50 PM, Abraham Varghese wrote:
>
>
>
> > Dear all ,
>
> > How to get external clojure libs workng in my system? like
> > clojure.contrib , etc?
>
> > Thanks in advance
> > AV
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com > >
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure Image/video processing?

2010-09-07 Thread Sean Grove
> I'd be happy to show my frame-hash implementation as long
> as you won't laugh too hard at it. I'll throw it up on github sometime
> soon after I clean it up a bit. I like it because a video treated as
> just a sequence of hash-maps which flows through an image processing
> pipeline.
Sounds excellent - please post it at your earliest convenience :)

> I have to say I've been surprised at the state of video in java. It's
> time to make it better with a clojure library devoted to pulling
> together the best of all these different methods.
Sounds good to me. I'm just starting on a rather complex project pulling in 
(currently) webcam input and processing the video, and need access to this 
anyway. If there's nothing out there, time to roll up my sleeves and get on it.

Let me know if you're looking to start on it any time soon.

-- Sean Grove

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: agents, await and Swing thread

2010-09-07 Thread Alessio Stalla
On Sep 6, 5:48 pm, "K."  wrote:
> Hello,
>
> I've got a concurrency problem and it's not really clear to me how to
> solve it. I have a Swing GUI doing a search in background with agents
> and the results are displayed one after the other, also in background.
>
> Here is, largely simplified, how I do it:
>
> (defvar- *end-search* (atom false))
>
> ;; this will be called from a Swing listener, when the user clicks on
> the 'Search' button
> ;; so this is called from the swing thread
> (defn on-search-begins []
>    ;;
>    (reset! *end-search* false)
>    (send *search-agent* do-search))
>
> (defn do-search [state]
>    ;; while (deref *end-search*) is false and while there are results
> for the search, do
>    (do-swing
>      ;; we are not in a swing thread within the agent, so we need to
> call do-swing
>      (display-result swingview result)
>
>      ;; search ends? yes, then
>      (do-swing
>        (display-search-is-ended swingview)))
>
> When the user clicks on the 'Stop' button, the following function will
> be called from the Swing thread:
>
> (defn search-stops []
>   (reset! *end-search* true)
>   ;; NOW we need to wait for the agents to stop
>   (await *search-agent*))
>
> The problem is: the call to await results in a deadlock. I suspect
> this is because the call to await is made from the Swing thread, and
> once the value of the *end-search* atom is set to true the agent try
> to access the Swing thread but can't because the thread is waiting.
>
> What solution would you propose to solve this problem?

My 2 cents: move the processing of user actions off the Swing thread
(the EDT) and leave there only the stuff that interacts with the GUI
(which I suppose is what your do-swing already does). Even without a
deadlock it's bad practice to make long blocking calls in the EDT
because that will freeze the GUI.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Leiningen + dropbox

2010-09-07 Thread Karol Adamiec
Hello,

I am trying to set up an env that would be hosted on my dropbox or usb stick
so i can access it anywhere.

Problem is that it works at home, but at work lein deps is unable to fetch
the jars.

C:\TEMP\My Dropbox\dev\hello-www>lein deps
Downloading: org/clojure/clojure/1.2.0/clojure-1.2.0.pom from central
Downloading: org/clojure/clojure/1.2.0/clojure-1.2.0.pom from clojure

and so on, and maven exceptions at the end.

I have write access only to Temp directory. Where lein is keeping its stuff
that it downloads?

Or maybe some network access issue? Any ideas how i can check for that?

Best regards,
Karol Adamiec

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: agents, await and Swing thread

2010-09-07 Thread Laurent PETIT
Hi,

Several questions / thoughts:

2010/9/6 K. :
> Hello,
>
> I've got a concurrency problem and it's not really clear to me how to
> solve it. I have a Swing GUI doing a search in background with agents
> and the results are displayed one after the other, also in background.
>
> Here is, largely simplified, how I do it:
>
> (defvar- *end-search* (atom false))
>
> ;; this will be called from a Swing listener, when the user clicks on
> the 'Search' button
> ;; so this is called from the swing thread
> (defn on-search-begins []
>   ;;
>   (reset! *end-search* false)
>   (send *search-agent* do-search))

Mmm, an agent without state always rings a bell in my head. There's a
smell of "abuse" of the agent concept here. Aren't you just using it
for its commodity to "start a new thread". If so, you could as well
just use a future, for example, and then you'll have simpler
semantics. Or you could just (Thread/start) your fn (but then you
introduce java clearly in the code, so maybe just using a future is
"the right balance").
Agents carry with them a lot of semantics, so readers of you code may
have unsatisfied expectations on your usage ... until they "get it"
and think: "ok it's just an 'agent abuse'".

> (defn do-search [state]
>   ;; while (deref *end-search*) is false and while there are results
> for the search, do
>   (do-swing
>     ;; we are not in a swing thread within the agent, so we need to
> call do-swing
>     (display-result swingview result)

As said by others, I suppose result is computed outside the do-swing
form so that the Swing thread is blocked as few as possible

>
>     ;; search ends? yes, then
>     (do-swing
>       (display-search-is-ended swingview)))
>
>
> When the user clicks on the 'Stop' button, the following function will
> be called from the Swing thread:
>
> (defn search-stops []
>  (reset! *end-search* true)
>  ;; NOW we need to wait for the agents to stop
>  (await *search-agent*))

It would be interested to know in the first place why you have to add
this call to await at all ?

Anyway, to just answer your question, maybe your
(display-search-is-ended swingview) call could be placed right after
the (await) call, but in another thread ? As in
(defn search-stops []
  (reset! *end-search* true)
  (future (await *search-agent*) (display-search-is-ended swingview)))


But all in all, I'm not sure the overall smells indicate that there
must be another way, probably radically differently structured, to do
all this. I'm thinking about something with watchers on refs /
atoms...

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Leiningen + dropbox

2010-09-07 Thread Karol Adamiec
Solved.

The problem was maven proxy settings.

After  adding settings.xml file to home works like a charm. I am answering
here for future googlers.

Best regards,
Karol Adamiec

On Tue, Sep 7, 2010 at 12:44 PM, Karol Adamiec wrote:

> Hello,
>
> I am trying to set up an env that would be hosted on my dropbox or usb
> stick so i can access it anywhere.
>
> Problem is that it works at home, but at work lein deps is unable to fetch
> the jars.
>
> C:\TEMP\My Dropbox\dev\hello-www>lein deps
> Downloading: org/clojure/clojure/1.2.0/clojure-1.2.0.pom from central
> Downloading: org/clojure/clojure/1.2.0/clojure-1.2.0.pom from clojure
>
> and so on, and maven exceptions at the end.
>
> I have write access only to Temp directory. Where lein is keeping its stuff
> that it downloads?
>
> Or maybe some network access issue? Any ideas how i can check for that?
>
> Best regards,
> Karol Adamiec
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

can't def m-bind because namespace

2010-09-07 Thread MohanR
java.lang.Exception: Name conflict, can't def m-bind because
namespace: user refers to:#'clojure.contrib.monads/m-bind

What namespace help doc. should I read to resolve this issue ? Maybe I
should not read about monads first.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: can't def m-bind because namespace

2010-09-07 Thread Nicolas Oury
http://clojure.org/namespaces

You should require clojure.contrib.monad and bot use it.

(ns my-namespace
 (:require (clojure.contrib.monad :as m))

m/m-bind, for example.

Then you can define your own m-bind without conflict with an existing one.

On Tue, Sep 7, 2010 at 1:13 PM, MohanR  wrote:
> java.lang.Exception: Name conflict, can't def m-bind because
> namespace: user refers to:#'clojure.contrib.monads/m-bind
>
> What namespace help doc. should I read to resolve this issue ? Maybe I
> should not read about monads first.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: defrecord with default values

2010-09-07 Thread anthonyghr
Awesome! Thanks so much!

Anthony


On Sep 7, 2:10 am, Meikel Brandmeyer  wrote:
> Hi,
>
> first of all we should start with the form we finally want to have:
>
> (defrecord Foo [a b c])
>
> (defn make-Foo
>   [& {:keys [a b c] :or {a :x c :z}}]
>   (Foo. a b c))
>
> ; Use as: (make-Foo :b :f) => (Foo. :x :f :z)
>
> The only annoying part is the boilerplate of defining make-Foo.
> What we would like to write is:
>
> (defrecord+ Foo [[a :x] b [c :z]])
>
> So how do we get from the lower form to the upper form? Basically
> you have that already, but you should not make the constructor
> a macro, but a function.
>
> General note: You want to use almost always vectors instead of lists
> to group things. Vectors are the Right Tool here. Lists are much less
> in important in Clojure than in other Lisp-like languages. Besides
> their
> role in code representation. (Note: a seq is not a list)
>
> Then we have to define the constructor function. Here we exploit
> the "old" new operator to save us from modifying the type symbol.
> Well, and that's basically it. There is no need for eval and related
> dark magic.
>
> (defmacro defrecord+
>   [record-name fields-and-values & record-body]
>   (let [fields-and-values (map #(if (vector? %) % [% nil]) fields-and-
> values)
>         fields            (vec (map first fields-and-values))
>         default-map       (into {} fields-and-values)]
>     `(do
>        (defrecord ~record-name
>          ~fields
>         �...@record-body)
>        (defn ~(symbol (str "make-" (name record-name)))
>          [& {:keys ~fields :or ~default-map}]
>          (new ~record-name ~...@fields)
>
> And the result:
>
> user=> (defrecord+ Foo [[a :x] b [c :z]])
> #'user/make-Foo
> user=> (make-Foo :b :f)
> #:user.Foo{:a :x, :b :f, :c :z}
> user=> (macroexpand-1 '(defrecord+ Foo [[a :x] b [c :z]]))
> (do
>   (clojure.core/defrecord Foo [a b c])
>   (clojure.core/defn make-Foo
>     [& {:or {a :x, b nil, c :z}, :keys [a b c]}]
>     (new Foo a b c)))
>
> (macroexpand output formatted for readability)
>
> This can be easily extended, that the constructor also allows
> arbitrary
> other keywords, besides the usual defined fields. This is left to the
> astute reader as an excerise. ;) Hint: there is also :as in
> destructuring.
>
> Bottom line: Avoid macros at all cost! If a function does the job, use
> a function! They are easier to write, can be passed around, can be
> apply'd, ...
>
> 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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: can't def m-bind because namespace

2010-09-07 Thread Jacek Laskowski
On Tue, Sep 7, 2010 at 2:13 PM, MohanR  wrote:

> Maybe I should not read about monads first.

...and report your findings here or blog somewhere if you don't mind
:) I've been reading a lot about monads lately and can't get my head
around it yet so any help appreciated (I'm coming from Java and
Clojure is my first real functional language - that's why it causes
headaches, I believe).

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://jaceklaskowski.pl
http://twitter.com/jaceklaskowski

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: can't def m-bind because namespace

2010-09-07 Thread Nicolas Oury
> ...and report your findings here or blog somewhere if you don't mind
> :) I've been reading a lot about monads lately and can't get my head
> around it yet so any help appreciated (I'm coming from Java and
> Clojure is my first real functional language - that's why it causes
> headaches, I believe).
>


I have no blog so I will try an explanation here.
I think monad are quite difficult to grasp, so the more different
explanations you read, the better.
Monads are made to represent computations in an abstract way.
Sometimes the basic computation laws are not those you want
and then you want to introduce other computation laws.
Monad is one way to do so (among other like applicative functors or
Kieisli arrows)
Monad corresponds to the computations that are best described as an
imperative program.

So a monad is a type transformer: M for all A , in Java words.
Something of type M is a computation in the world of computation M
that returns values of type A.

(M for example can be
  IO: the computations that do input/outputs to find their results,
  State: the computations that use a and update an internal state
  List: more surprisingly, the non-deterministic computations: each
computation yeilds a list of possible results)

There are a few operators you need for a monad:
- return : A -> M . It says that any computation model must be able
to handle the lack of computation. "Do nothing and return this value"
-  bind : M -> (A -> M) -> M
"If I give you a computation that gives back values in A and for each
values in A I tell you how to compute a value in B,
 then you can compute a value in B. "
That's a strong assumption, because it allows to use the whole power
of Clojure to construct a computation from the result of the first
computation.
Some model of computations are more restrictive than monad on that.


>From this two operators you can define two others:
- map : (A -> B) -> M -> M
"If I give you a function from A to B, then you can transform a
computation that returns value in A in computation that returns values
in B."
(map f compA = (bind compA (fn [x] (return (f x)

- join : M> -> M
"I can run a subprogram" This is again something quite specific to
monad as computation devices. (Bind can be constructed from join and
map)
They are dynamic programs that can compute a program and run it.
join compMA = (bind compMA identity)

bind compA f = (join  (map f compA))

All these operators must respect some laws, that are quite natural.
Like returning a value and starting a computation is the same as starting a
computation directly from the value:

- (bind (return a) f) = (f a)



To work out an example, the state monad is a computation that can use
and modify a state, so: M = S -> [S, A] . I need a state and return
a new state and a value A.
return a = (fn [s] -> [s a])
bind compA f =
  (fn [s1]  ->
; we give the state to the first comutation
   (let [[s2 a] (compA s1)
  ; we compute the next computation
 compB (f a)]
 ; we give the state to the second computation
 (compB s2)))

Hope that helps.

Nicolas.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Extending Clojure's STM with external transactions

2010-09-07 Thread Constantine Vetoshev
On Sep 5, 8:56 pm, Alyssa Kwan  wrote:
> Any thoughts on how to marshal functions? What about vars and dynamic
> binding?

I don't think marshaling closures will ever happen without changes to
Clojure itself. I haven't looked into how much work it would require,
or how much it would impact Clojure's performance. It always seemed
like an excessively lofty goal anyway: if I could save plain Clojure
data structures (all primitives, all fully-evaluated collections, and
all records), I would be happy with it. In truth, I always wanted to
extend Cupboard to support some kind of semi-magical distributed
storage (like Oracle Coherence, but with better persistence guarantees
— database-like rather than cache-like), but wanted to get single-node
basics working properly first. The latest BDB JE has some replication
built-in, and I planned to use it.

As for dynamic binding, I'm not sure what you mean. The bound value
will evaluate using Clojure's normal rules when cupboard.core/make-
instance runs, and go into the database. cupboard.core/query will then
read it and make the value part of the returned map (it should really
be a Clojure 1.2 record). The code doesn't do anything except save and
restore fully-evaluated data structures.

Incidentally, Cupboard wraps BDB transactions, and does not attempt to
work with Clojure's STM subsystem. I always considered this a
weakness, but a difficult one to resolve. To counterbalance it, I
planned to avoid mixing STM and on-disk data structures in the same
code.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: can't def m-bind because namespace

2010-09-07 Thread Jacek Laskowski
On Tue, Sep 7, 2010 at 4:04 PM, Nicolas Oury  wrote:

> Hope that helps.

It did. Thanks. Would you share some examples of its use in Clojure
apps? I'd love seeing more examples where a monad-based solution is
contrasted/compared to its more traditional, common approach. I wonder
why monads are not extensively used? Is the category theory the reason
to its little use (= people don't understand monads' value?).

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://jaceklaskowski.pl

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Typical usage of Compojure

2010-09-07 Thread James Reeves
On 5 September 2010 20:53, HB  wrote:
> It is public idea in Ruby community that Sinatra is best used for
> rapid prototyping and creating API for web application.

This opinion tends to come from developers used to larger web
frameworks like Ruby on Rails. I don't agree with this. RoR makes
certain assumptions about what you want to build, and doesn't work
well if you're doing something different.

There is also a trend away from large frameworks that do everything,
to modular frameworks that allow you to pick and choose. Look at Rails
3; they've factored out a lot of ActiveRecord into the more generic
ActiveModel interface, and a lot of their server code has been removed
and instead replaced with greater Rack integration.

Web development in Clojure is tending toward this ideal. One has a
basic framework that abstracts the underlying HTTP server (Ruby has
Rack, Clojure has Ring), and then different libraries are used to
augment that. The end result is the same, but you have more choice in
how you put your application.

That said, choice isn't always good, and I expect at some point people
will create a thin layer that pulls together several libraries and a
directory structure. For example, Leiningen, Compojure, Ring, Hiccup
and Carte have equivalent functionality to most of Ruby on Rails.

- James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: can't def m-bind because namespace

2010-09-07 Thread Joop Kiefte
Monads are mostly used because they are necessary in Haskell. In
Clojure the urgent need is not there. However, you can sure get some
cleaner and/or more composable code if you use monads in your
advantage.

2010/9/7 Jacek Laskowski :
> On Tue, Sep 7, 2010 at 4:04 PM, Nicolas Oury  wrote:
>
>> Hope that helps.
>
> It did. Thanks. Would you share some examples of its use in Clojure
> apps? I'd love seeing more examples where a monad-based solution is
> contrasted/compared to its more traditional, common approach. I wonder
> why monads are not extensively used? Is the category theory the reason
> to its little use (= people don't understand monads' value?).
>
> Jacek
>
> --
> Jacek Laskowski
> Notatnik Projektanta Java EE - http://jaceklaskowski.pl
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004

Demandoj en aŭ pri Esperanto? Questions about Esperanto? Vragen over
Esperanto? Perguntas sobre o Esperanto? - http://demandoj.tk

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Mark Fredrickson
Perhaps you would be interested in postdoc:

http://github.com/markmfredrickson/postdoc

Postdoc allows structured documentation, runnable examples, and
related items based on namespaced identifiers. One  was to allow for
separate files that included the documentation away from the code, so
as not to clutter up the source with more information than necessary.
Coders still write short doc strings. Additional information is
included in a separate namespace and is only an (import ...) away.

E.g.

--- foo.clj
(ns foo)

(def add1 "adds one to its argument" [x] (+ 1 x))
(def add2 "adds two to its argument" [x] (add1 (add1 x)))

--- foo/doc.clj
(ns foo.doc
  (:use postdoc))

(postdoc add1
:examples ["; (add1 3) => 4\\n(add1 3)"]
:categories [:example-functions :arithmetic]
:references [["Wikipedia Entry" "http://en.wikipedia.org/wiki/
Foo"]
 "http://www.example.com";]
:see-also [#'add2])



Right now, the postdoc function stuffs everything into the docstring,
but it would be easy enough to have a global option for that and an
(extended-doc) function to spit out the additional info on request.

I started this project was to make the Incanter docs accessible to
scrapping. It is an example of another large project that is well
documented. The docs are detailed and comprehensive, but contained
entirely in docstrings (usually well structured).  I spent some time
moving them over to the postdoc format, but I haven't pushed the
Incanter community to accept the postdoc format.

Here's an example of a real file, documented:

http://github.com/markmfredrickson/incanter/blob/postdoc/modules/incanter-core/src/incanter/doc/core.clj

-Mark


On Sep 7, 3:25 am, Mark Engelberg  wrote:
> Docstrings seem designed for fairly terse comments about the nature of
> the function.  It's great for providing little hints about how the
> function works to jog one's memory by typing (doc ...) in the REPL, or
> for searching with find-doc.  But I just don't think I can fit the
> kind of full documentation I want all into a docstring without ruining
> its REPL usefulness.
>
> My instinct is to put those sorts of things into comments. I think
> adding a huge Clojure metadata map in front of the var would hinder
> code readability.  Hmmm, I wonder if maybe there would be a way to use
> a macro to add metadata to the var separate from the function?  E.g.,
> (document my-function metadata)  That might make the metadata approach
> more palatable...
>
> As a side note, I wish Clojure had some sort of block commenting
> capability.  Both (comment ...) and #_ require well formed code to
> follow and sometimes it's just nice to be able to comment out a block
> of text.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: external clojure lib >

2010-09-07 Thread Abraham
still i am not getting , i meant to say that , i want to use
clojure.contrib. libraries , how to make it work with my system . from
where this lib has to copied and which directory to copy...
may be lib is clj's files

Anybody'
Thanks in advance
AV


On Sep 7, 11:02 am, Abraham Varghese  wrote:
> Hello Sunil ,
>
> Using windows xp , just got into clojure , not much knowledge
>
> Thanks
> AV
>
> On Sep 6, 8:00 pm, Sunil S Nandihalli 
> wrote:
>
>
>
> > Hi Abraham,
> >  Make sure that the jar file of the "external" library you are referring to
> > is in path. If you are developing clojure code .. I would strongly advice
> > you to use leiningen which takes care of a lot of these things for you. Btw.
> > what is the "development environment" you are using? ..
>
> > Try to be a little more elaborate when you ask questions like these..
> > Sunil.
>
> > On Mon, Sep 6, 2010 at 3:50 PM, Abraham Varghese 
> > wrote:
>
> > > Dear all ,
>
> > > How to get external clojure libs workng in my system? like
> > > clojure.contrib , etc?
>
> > > Thanks in advance
> > > AV
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Clojure" group.
> > > To post to this group, send email to clojure@googlegroups.com
> > > Note that posts from new members are moderated - please be patient with
> > > your first post.
> > > To unsubscribe from this group, send email to
> > > clojure+unsubscr...@googlegroups.com > >  >
> > > For more options, visit this group at
> > >http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Eric Schulte
Hi,

I'd recommend looking at how plt-scheme solved this problem (see [1]).
They actually defined alternative readers in which either prose or code
can be the default input mechanism (with the other escaped in some way).
I don't know if Clojure's reading system is quite flexible enough to
support something like this.

In the case of Clojure's documentation it seems the main decision is
whether the extended documentation and examples should live intermingled
with the source code, or should later be applied to the core function
symbols from some external location.

Cheers -- Eric

Also,
  Probably not appropriate to the immediate need at hand, but (to self
  promote) if you happen to use Emacs and you would like a robust
  literate-programming / reproducible-research tool for Clojure,
  Org-mode now supports weaving, tangling, and inline execution of
  embedded code [2] in many languages [3] including Clojure [4].

Laurent PETIT  writes:

> Hi,
>
> 2010/9/7 Mark Engelberg :
>> Docstrings seem designed for fairly terse comments about the nature of
>> the function.  It's great for providing little hints about how the
>> function works to jog one's memory by typing (doc ...) in the REPL, or
>> for searching with find-doc.  But I just don't think I can fit the
>> kind of full documentation I want all into a docstring without ruining
>> its REPL usefulness.
>
> Indeed. Though the docstring for e.g. gen-class is quite extensive and
> could serve as a counter-example.
> Javadoc has an interesting property: it considers that the first
> sentence serves as a summary for the doc. The "sentence" delimiter is
> just the point in the case of javadoc.
> Out of my head: instead of writing doc in several places, maybe
> something "like that" could be used. it could be associated with some
> clojure.core/*short-docstring* global var that (doc), (find-doc) could
> use for displaying the short or full form ?
>
>> My instinct is to put those sorts of things into comments. I think
>> adding a huge Clojure metadata map in front of the var would hinder
>> code readability.  Hmmm, I wonder if maybe there would be a way to use
>> a macro to add metadata to the var separate from the function?  E.g.,
>> (document my-function metadata)  That might make the metadata approach
>> more palatable...
>
> Sure. A lot of things are already placed as metadata of the var and
> not of the function the var is holding, anyway.
>
>> As a side note, I wish Clojure had some sort of block commenting
>> capability.  Both (comment ...) and #_ require well formed code to
>> follow and sometimes it's just nice to be able to comment out a block
>> of text.
>
> I remember having seen #|  |# block commenting reader macro to be
> on the todo list of Rich, many months ago.

Footnotes: 
[1]  http://lambda-the-ultimate.org/node/4017
 http://docs.racket-lang.org/scribble/index.html

[2]  http://orgmode.org/worg/org-contrib/babel/index.php

[3]  http://orgmode.org/worg/org-contrib/babel/languages.php#langs

[4]  http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.php

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: JSON lib of choice?

2010-09-07 Thread Michael Ossareh
On Mon, Sep 6, 2010 at 19:50, Wilson MacGyver  wrote:

> I figure enough time has passed that I want to bring this up again.
>
> For JSON, are you using clojure.contrib.json or clj-json? Why?
>


We use org.danlarkin.json, because it encodes and decodes (contrib.json
didn't when we made our decision) and it was the first hit in the google
listings for "clojure json".

If anyone gets around to doing some real world perf analysis and there is a
significant winner then we may switch.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: external clojure lib >

2010-09-07 Thread Alan
You've seen a lot of recommendations for Leiningen. I suggest you try
it out: everyone seems to think it will solve your problem (Hint: it
will). But even if you have no idea what it is, the fact that everyone
is suggesting it means you should try it out before you simply repeat
the question you've asked already.

On Sep 7, 8:36 am, Abraham  wrote:
> still i am not getting , i meant to say that , i want to use
> clojure.contrib. libraries , how to make it work with my system . from
> where this lib has to copied and which directory to copy...
> may be lib is clj's files
>
> Anybody'
> Thanks in advance
> AV
>
> On Sep 7, 11:02 am, Abraham Varghese  wrote:
>
> > Hello Sunil ,
>
> > Using windows xp , just got into clojure , not much knowledge
>
> > Thanks
> > AV
>
> > On Sep 6, 8:00 pm, Sunil S Nandihalli 
> > wrote:
>
> > > Hi Abraham,
> > >  Make sure that the jar file of the "external" library you are referring 
> > > to
> > > is in path. If you are developing clojure code .. I would strongly advice
> > > you to use leiningen which takes care of a lot of these things for you. 
> > > Btw.
> > > what is the "development environment" you are using? ..
>
> > > Try to be a little more elaborate when you ask questions like these..
> > > Sunil.
>
> > > On Mon, Sep 6, 2010 at 3:50 PM, Abraham Varghese 
> > > wrote:
>
> > > > Dear all ,
>
> > > > How to get external clojure libs workng in my system? like
> > > > clojure.contrib , etc?
>
> > > > Thanks in advance
> > > > AV
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Clojure" group.
> > > > To post to this group, send email to clojure@googlegroups.com
> > > > Note that posts from new members are moderated - please be patient with
> > > > your first post.
> > > > To unsubscribe from this group, send email to
> > > > clojure+unsubscr...@googlegroups.com > > >  >
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/clojure?hl=en
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: external clojure lib >

2010-09-07 Thread Mike Meyer
On Tue, 7 Sep 2010 08:36:27 -0700 (PDT)
Abraham  wrote:

> still i am not getting , i meant to say that , i want to use
> clojure.contrib. libraries , how to make it work with my system . from
> where this lib has to copied and which directory to copy...
> may be lib is clj's files

As other have pointed out, the usual way to deal with this is with
"java infrastructure" tools (maven and leiningen) or your IDE. If you
really want to start using clojure without having to deal with the
java infrastructure, my writeup at
http://www.mired.org/home/mwm/papers/simple-clojure.html covers the
basics. I've recently updated it to include data on generating jar
files, more for completeness sake than anything else, as you wouldn't
want to do that on a regular basis.

  http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Phil Hagelberg
On Tue, Sep 7, 2010 at 1:25 AM, Mark Engelberg  wrote:
> Docstrings seem designed for fairly terse comments about the nature of
> the function.  It's great for providing little hints about how the
> function works to jog one's memory by typing (doc ...) in the REPL, or
> for searching with find-doc.

I think this is true of function-level docstrings. However, don't
forget that namespaces can have docstrings as well. That's where I
like to put overview-type documentation.

> Javadoc has an interesting property: it considers that the first
> sentence serves as a summary for the doc. The "sentence" delimiter is
> just the point in the case of javadoc.

Emacs docstrings work this way too; the first line must stand alone
and provide a summary. I think this would be a great convention to
adapt for Clojure, but that cat may already be out of the bag.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


How to :use a defrecord from another source file and namespace?

2010-09-07 Thread Chris Jenkins
I'm having trouble writing code in one namespace that instantiates a type
that is defined in another namespace.

I have two source files:


other.clj defines a function called my-fn and a type called huss:

(ns my-project.other)

(defrecord huss [x y z])

(defn my-fn []
  (println "my-fn"))


core.clj can successfully call my-fn from the other file but I try to
instantiate huss and I get an ClassNotFoundException

(ns my-project.core
  (:use [my-project.other]))

(my-fn)

; doesn't work... gives java.lang.IllegalArgumentException: Unable to
resolve classname: huss
(println (huss. 1 2 3))


What's the reason for this? Is it intended to work like this and what can I
do in order to define a type in one source file (and namespace) and use it
in another?

Cheers,

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to :use a defrecord from another source file and namespace?

2010-09-07 Thread Michał Marczyk
Types created by deftype & defrecord are Java classes and you'd have
to use :import to bring them into another namespace:

(ns ...
  (:import my-project.other.huss))

Or if you have multiple types,

(:import [foo.bar Wibble Wobble])

It might be simpler to define a factory function and use that (through
:use / :require):

;; in my-project.other
(defn make-huss [x y z]
  (huss. x y z))
;; ...then use make-huss in project.core

Sincerely,
Michał

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: cool compiler-project?

2010-09-07 Thread Sreeraj a
Hi,
I'm trying to develop a clojure compiler for LLVM.

may need a small nudge in the right direction.
anyone who can mentor me on this project?

Thanks
Sreeraj.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: How to :use a defrecord from another source file and namespace?

2010-09-07 Thread Chris Jenkins
Hi Michał,

Thanks for the explanation. I hadn't made the connection between the fact
that defrecord creates a "proper" java type and the fact that a Java class
would need to be :import-ed. I agree that creating a make-huss function
might be simpler. Part of me is thinking "why don't I fall back on defstruct
and defmulti, at least until performance becomes important" so I might do
that.

Cheers,

Chris




On 7 September 2010 22:46, Michał Marczyk  wrote:

> Types created by deftype & defrecord are Java classes and you'd have
> to use :import to bring them into another namespace:
>
> (ns ...
>  (:import my-project.other.huss))
>
> Or if you have multiple types,
>
> (:import [foo.bar Wibble Wobble])
>
> It might be simpler to define a factory function and use that (through
> :use / :require):
>
> ;; in my-project.other
> (defn make-huss [x y z]
>  (huss. x y z))
> ;; ...then use make-huss in project.core
>
> Sincerely,
> Michał
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: RFC: updated c.c.logging with some breaking changes

2010-09-07 Thread ka
These seem like good changes to me!  Any plans to push?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How to :use a defrecord from another source file and namespace?

2010-09-07 Thread Michał Marczyk
On 7 September 2010 23:56, Chris Jenkins  wrote:
> "why don't I fall back on defstruct
> and defmulti, at least until performance becomes important"

I believe defrecord was meant to supersede defstruct, but apparently
defstruct is not (yet?) marked as deprecated in 1.2, so sure, that
might be a reasonable way to go at least for now. Of course, you could
also just use regular maps (switching to something more suited to the
task when the app's performance and/or memory profile requires that).

Sincerely,
Michał

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


clojure.contrib.trace not working on 1.2?

2010-09-07 Thread Scott Jaderholm
Why does c.c.trace give different output on 1.2 than it did on 1.1?

>From 
>http://learnclojure.blogspot.com/2010/02/slime-2009-10-31-user-defn-fib-n-if-n-2.html

On 1.1

user> (dotrace (fib) (fib 3))

TRACE t1880: (fib 3)
TRACE t1881: |(fib 2)
TRACE t1882: ||(fib 1)
TRACE t1882: ||=> 1
TRACE t1883: ||(fib 0)
TRACE t1883: ||=> 0
TRACE t1881: |=> 1
TRACE t1884: |(fib 1)
TRACE t1884: |=> 1
TRACE t1880: => 2
2
user>

On 1.2

user> dotrace (fib) (fib 3))

TRACE t11624: (fib 3)
TRACE t11624: => 2

Thanks,
Scott

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.trace not working on 1.2?

2010-09-07 Thread Michał Marczyk
Hm, I would guess that the self-call gets "hard-wired", since if you
define fib thus:

(defn fib [n]
  (if (#{0 1} n)
n
(+ (#'fib (- 2 n)) (#'fib (dec n)

then it works as you expect.

Not that I'm really sure what's happening; just a conjecture. Also, I
believe I already bumped into this behaviour when playing with
alternative tracing schemes, but never realised its new to 1.2...
interesting.

Sincerely,
Michał

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


2 lein swank instances on same project and compiling src from emacs

2010-09-07 Thread HiHeelHottie

I have two lein swanks going on different ports against the same
project.  I open up two slime-connect's in emacs.  How can I compile
(C-c C-k) my core.clj to the two different slime-connect's.

hhh

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: 2 lein swank instances on same project and compiling src from emacs

2010-09-07 Thread Robert McIntyre
I don't think you can do that,
but you can connect to the same swank instance twice with M-x slime-connect
and function updates will be reflected in both repls.

--Robert McIntyre

On Tue, Sep 7, 2010 at 8:54 PM, HiHeelHottie  wrote:
>
> I have two lein swanks going on different ports against the same
> project.  I open up two slime-connect's in emacs.  How can I compile
> (C-c C-k) my core.clj to the two different slime-connect's.
>
> hhh
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


ANN: Indyvon - GUI library

2010-09-07 Thread Mikhail Kryshen
Hi,

I have recently published Indyvon -- an experimental multithreaded GUI
library for Clojure. The main idea behind the library is that base UI
element (called "layer") does not define any state (has no location,
size, parent element). Dynamic layout of layers is captured at the
rendering time and remembered for event processing until the next
repaint is complete. Java 2D API is used for rendering.

Source code:
http://bitbucket.org/kryshen/indyvon/src

See README there for a more detailed description.
src/net/kryshen/indyvon/demo.clj contains runnable example.

Currently only some basic layers are implemented (no normal widgets)
and I have no plan to build a complete GUI toolkit. I am using the
library in another project for graph visualization.

Expect bad English style (I am not native speaker) in readme and
docstrings, corrections are welcome.

--
Mikhail

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Eric Schulte
Phil Hagelberg  writes:

> On Tue, Sep 7, 2010 at 1:25 AM, Mark Engelberg  
> wrote:
[...]
>> Javadoc has an interesting property: it considers that the first
>> sentence serves as a summary for the doc. The "sentence" delimiter is
>> just the point in the case of javadoc.
>
> Emacs docstrings work this way too; the first line must stand alone
> and provide a summary. I think this would be a great convention to
> adapt for Clojure, but that cat may already be out of the bag.
>

+1 for complete sentences on the first line of a doc-string (whether
period or newline delimited).

Another elisp convention which I find very useful is using `' to quote
function names e.g. `map'.  Documentation browsers can then link these
names to the documentation of the quoted function.  This is especially
useful in a functional languages where function composition is the norm.

Clojure is certainly young enough for new conventions to emerge,
especially with some buttressing from documentation tools.

Best -- Eric

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Sean Corfield
On Tue, Sep 7, 2010 at 1:25 AM, Mark Engelberg  wrote:
> Docstrings seem designed for fairly terse comments about the nature of
> the function.  It's great for providing little hints about how the
> function works to jog one's memory by typing (doc ...) in the REPL, or
> for searching with find-doc.  But I just don't think I can fit the
> kind of full documentation I want all into a docstring without ruining
> its REPL usefulness.

I'm watching this thread and I'm wondering what kind of documentation
people are talking about here. I've always been used to using
self-documenting function / variable names and short comments for
documenting everything. Clearly you guys are talking about something
much bigger than this and I'd like a bit more insight into that. Who
are you writing this documentation for? How detailed does it need to
be? Why are good function and variable names and a short summary not
enough?

Genuinely curious about this.
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


giws a window for people using c/c++ into clojure ..

2010-09-07 Thread Sunil S Nandihalli
Hello everybody,
 I recently came across giws

http://www.scilab.org/products/other/giws

a tool to call java code from c/c++ all it really needs to generate all the
jni-wrappers is a simple xml file which indicates the class name and the
member functions .. some thing as simple as ...


  





  
  


  


  

  


given clojure's power of macros .. it should be possible to automate the
creation of this xml for every clojure-structure and function by redefining
the *defstruct* and *defn * and other similar macros .. I would like to give
it a shot .. I am kind of new to all these things .. so would like to hear
what the clojure community has to say about this...

Thanks in advance,
Sunil.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: external clojure lib >

2010-09-07 Thread Sean Corfield
On Tue, Sep 7, 2010 at 8:36 AM, Abraham  wrote:
> still i am not getting , i meant to say that , i want to use
> clojure.contrib. libraries , how to make it work with my system . from
> where this lib has to copied and which directory to copy...
> may be lib is clj's files

One word: Leiningen :)
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Documentation tools

2010-09-07 Thread Mark Engelberg
On Tue, Sep 7, 2010 at 10:23 PM, Sean Corfield  wrote:
> I'm watching this thread and I'm wondering what kind of documentation
> people are talking about here. I've always been used to using
> self-documenting function / variable names and short comments for
> documenting everything. Clearly you guys are talking about something
> much bigger than this and I'd like a bit more insight into that. Who
> are you writing this documentation for? How detailed does it need to
> be? Why are good function and variable names and a short summary not
> enough?

A few things off the top of my head:

Functions:
What pre-conditions need to be met by the inputs?
What invariants are maintained by the function?
What are the performance guarantees of the function?
Examples of how to use the function and why you'd want to use the function.
What other functions are needed to create the structures consumed by
this function, and what functions use the structures it outputs?  In
other words, is this function truly indpendent, or is it typically
used as part of a chain of function calls?
What external dependencies does it have? (e.g., if it depends on
another library, tool, file format, database etc, and that library
changes, you'd better take another look at this function to make sure
it still works and delivers the same guarantees it did before).

Files:
Many times there are dozens of functions that are interrelated.  Only
one or two of them are the crucially important "entry points" that
provide the high-level API.  The rest are mostly helper functions that
implement the lower-level details.  They are made public because in
some situations, you might want to have access to those lower-level
details, but 99% of the time, you can ignore them.  By default, all of
these functions will show up in an auto-generated API listing.  Good
documentation will direct you to the important functions.

What is the organization scheme that determines how the functions are
split across files?  In other words, how do you go about finding the
namespace that implements the functionality you're looking for.

Often, large projects accumulate a certain amount of functions that
were produced as some sort of dead-end or deprecated approach.  The
functions are kept around to support consumers who use them, but they
are no longer the "right way" to do things.  Good documentation makes
it clear what is "the right way".

The list goes on.  And these are only the things that are important to
consumers of your code.  If you want to comment your code for other
people to maintain it, that's even more challenging.  You have to make
a convincing case that the function actually works the way you intend
it, and other people will need to understand it enough to change it
without breaking it (and to be sure the change won't break something
else that depends on it).

Who do I write for?  Usually I write for myself two years down the
road.  That's enough of an incentive to make me want to keep my code
well-organized, although I don't have to go a great deal into my
implementation decisions and details because I can probably
reconstruct that if I need to.  Also, I'm pretty familiar with my own
style for naming variables, so there's no need to go into that.  When
I write code for other people to read, I find I have to be even more
rigorous in my documentation since the things that are obvious to me
will be not so obvious to them.  One person's concept of
"self-documenting names" doesn't necessarily correspond to another's.

A great quote:

"Always code as if the guy who ends up maintaining your code will be a
violent psychopath who knows where you live." -- John F. Woods

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Strange Loop reminder...

2010-09-07 Thread Alex Miller
Hey all, I know everyone is excited about the first clojure-conj and I
will be there myself! BUT, I would also like to draw your attention to
the Strange Loop conference Oct 14-15th in St. Louis.  Strange Loop
will feature 8 talks on Clojure (http://strangeloop2010.com/tag/
Clojure ) as well as a keynote by Guy Steele.

Strange Loop also has a slew of talks about other languages (Scala,
Groovy, Ruby, JavaScript, Java, Lua, F#, Perl 6, Go), nosql dbs
(MongoDB, Cassandra, Riak, Mark Logic, HyperGraphDB), web (HTML 5,
semantic web), mobile (Android), and more.  Full schedule:
http://strangeloop2010.com/calendar

Hope you can make it!  Tickets are $190 through Sept and $100 for
students.

Alex Miller

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: RFC: updated c.c.logging with some breaking changes

2010-09-07 Thread ataggart
It's been in contrib's master branch for a while now.  Here's the
updated doc:
http://clojure.github.com/clojure-contrib/branch-master/logging-api.html

On Sep 7, 3:01 pm, ka  wrote:
> These seem like good changes to me!  Any plans to push?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en