Documentation tools

2010-09-05 Thread Mark Engelberg
I spent some time recently documenting a large clojure project. The approach I used was a combination of doc-strings, comments throughout my code, and a project-wide emacs-org-mode file summarizing the point of each file, the important functions in each file categorized by purpose, and an overview

Re: Question about `binding'

2010-09-05 Thread Phil Hagelberg
On Sun, Sep 5, 2010 at 3:32 PM, Michał Marczyk wrote: > Calls going through Vars in clojure.core receive special treatment for > speed, which is why you can't rebind them. Actually this was backed out before 1.2 was released. Now only definline functions and (in 1.3) static functions behave this

Re: matching with wild-cards in clojure multi-methods

2010-09-05 Thread Mark Rathwell
You can add essentially one more level of indirection to your dispatch function logic and return an integer (or string or whatever) and match on that. So, with your example, when you want "method1" called, return 1 from the dispatch function, when you want "method2" return 2, you get the idea: (d

Re: Lisp/Scheme Style Guide

2010-09-05 Thread Daniel Gagnon
> > I think it would be great if an official "clojure-fmt" tool existed. > I have no interest in forcing people to use it who don't want to. But > I think it would set a great baseline for IDEs and would be helpful to > the people and teams who like having coding standards. I would be one > of a

Re: Lisp/Scheme Style Guide

2010-09-05 Thread Mark Engelberg
On Sun, Sep 5, 2010 at 1:08 PM, Daniel Gagnon wrote: > I'd be all for having clojure-fmt that would format clojure code in the way > Rich prefers it so that when I get random code I could convert it to a nice > and predictable format. It should be even simpler to write for a lisp than > other lang

Re: Clojure macros

2010-09-05 Thread ingokr
Ah! Thanks a lot, Michał -- that clarifies a lot for me. Best regards, Ingolf -- 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 pat

matching with wild-cards in clojure multi-methods

2010-09-05 Thread Sunil S Nandihalli
Hello everybody, It is awesome that we can specify our own dispatch functions and corresponding values.. However, I feel we should also have control over the functions that is used to match the value of the dispatch function with that of the one specified in the defmethod. For instance if my dis

Re: Extending Clojure's STM with external transactions

2010-09-05 Thread Alyssa Kwan
Thanks, Constantine! Your work on cupboard is awesome! I'll take a look at the deadlock detection to see if I can help. Any thoughts on how to marshal functions? What about vars and dynamic binding? Thanks! Alyssa On Sep 5, 11:02 am, Constantine Vetoshev wrote: > On Aug 30, 5:02 pm, nchubrich

Re: Extending Clojure's STM with external transactions

2010-09-05 Thread Alyssa Kwan
> > How about introducing a second part to the api? (store) creates a > > wrapper for the persistent address, and refp then takes one of those > > wrappers and the name? > > I like that.  I would go one step further and say refp should have a > default data store that is used unless you specify any

Re: Typical usage of Compojure

2010-09-05 Thread Wilson MacGyver
For me, I'm using compojure/ring mostly for building web services. I use html whenever I need some simple html templates. But since it's a web service, I use XML and JSON far more often. So in the end, compojure/ring just serves as a way to invoke the functions to get output. There isn't AJAX roun

Announcement: secrets of monad fu, revealed

2010-09-05 Thread David Cabana
I had too much time on my hands, and put together a Clojure-based monad tutorial. If that kind of thing is your cup of tea, I'd love to get some feedback on it. Here's the link http://erl.nfshost.com/2010/09/05/bind-unit-and-all-that-2/ David -- You received this message because you are subscrib

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Michał Marczyk
On 6 September 2010 02:01, CuppoJava wrote: > Ah that makes sense! Thanks Michal! Great! :-) > I have looked through Lisp in Small Pieces, and didn't find it very > well written. I think a lot was lost through the translation. Oh, that's unfortunate. Perhaps I should step up my French-learning

Re: Lisp/Scheme Style Guide

2010-09-05 Thread Tim Daly
> I'd be all for having clojure-fmt that would format clojure code > in the way Rich prefers it so that when I get random code I could > convert it to a nice and predictable format. It should be even > simpler to write for a lisp than other languages. See Guy Steele "Common Lisp, The Language" pp

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread CuppoJava
Ah that makes sense! Thanks Michal! I have looked through Lisp in Small Pieces, and didn't find it very well written. I think a lot was lost through the translation. Besides SICP, the other great lisp book I read was actually "The Scheme Programming Language". The chapter on continuations is mind-b

Re: Clojure macros

2010-09-05 Thread Michał Marczyk
On 6 September 2010 01:11, ingokr wrote: > Patrick & Meikel: thanks! Your solutions do produce almost what I > need; the idea is with > > (tm a b) > > I should get back > > {:a a :b b} > > Your solutions produce sth equivalent to {:a (eval a) :b (eval b)} in > this case. Actually Meikel's solutio

Re: Clojure macros

2010-09-05 Thread ingokr
Hi again -- First, let me thank all of you for you kind and instructive comments. Kent: thanks for the explanation of the relationships between reader and macro expansion. Patrick & Meikel: thanks! Your solutions do produce almost what I need; the idea is with (tm a b) I should get back {:a a

Re: Clojure macros

2010-09-05 Thread Andrew Gwozdziewycz
On Sun, Sep 5, 2010 at 5:18 PM, Kent wrote: > When clojure evaluates a piece of code it goes through several steps. > First the reader takes the string representation of your code and > turns it into the clojure data structures represented by your code. > Those data structures are then sent to the

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Michał Marczyk
In the presence of macros, it's best to think "Lisp compilation = evaluation of all forms". So, you do two things at the same time: (1) accumulate object code to be output as the result of the compilation and (2) actually execute the programme, so that you can call functions and examine variables w

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread CuppoJava
Thanks for all the replies! SICP is one of my favorite books actually, I have read through it many times already. My question is particularly concerning expanding macros during compilation. If your source has NO use of macros. Then it's trivial to compile. Just compile each form one by one. The

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Michał Marczyk
On 5 September 2010 18:46, CuppoJava wrote: > I'm writing a simple lisp for educational purposes, and I can't figure > out how to do compilation. The final chapter of SICP [1] deals with compilation of Scheme code down to a kind of assembly language (also introduced in the book). It's fantastical

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Daniel Gagnon
On Sun, Sep 5, 2010 at 5:11 PM, Stuart Sierra wrote: > Clojure compiles sources to Java ".class" files. To create a .class > file that can be run at the command line, you need a namespace with a > (:gen-class) directive and a function named "-main". Here's an > example: > I think the question wa

Re: Question about `binding'

2010-09-05 Thread Michał Marczyk
On 5 September 2010 07:48, Yang Dong wrote: > That sounds reasonable. But how would you explain `pmap'? This > function is not inlined. In fact, every function in clojure.core can't > be bound without a declare (as far as I have tried). And it seems this > problem only exists when I tried to bind

Re: Clojure macros

2010-09-05 Thread Kent
When clojure evaluates a piece of code it goes through several steps. First the reader takes the string representation of your code and turns it into the clojure data structures represented by your code. Those data structures are then sent to the compiler for compilation, including possible macro e

Re: Clojure macros

2010-09-05 Thread Meikel Brandmeyer
Hi, Am 05.09.2010 um 23:10 schrieb CuppoJava: > (defmacro tm [& args] > `(hash-map ~@(mapcat (fn [x] (list (keyword x) x)) args))) Or you return the map directely: (defmacro tm [& args] (apply hash-map (mapcat (juxt keyword identity) args))) Sincerely Meikel -- You received this message

Re: Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread Stuart Sierra
Clojure compiles sources to Java ".class" files. To create a .class file that can be run at the command line, you need a namespace with a (:gen-class) directive and a function named "-main". Here's an example: (ns com.example.myapp (:gen-class)) (defn -main [] (println "Hello

Re: Clojure macros

2010-09-05 Thread CuppoJava
I'm not sure if this is intended behavior or not, since unquote- splicing was originally meant for splicing into lists. But for now anyway, you can use this as a workaround? (defmacro tm [& args] `(hash-map ~@(mapcat (fn [x] (list (keyword x) x)) args))) Hope that helps -Patrick On Sep 5, 3:

Re: Clojure macros

2010-09-05 Thread Andrew Gwozdziewycz
This seems like a bug to me. user> `[~@(mapcat #(list (keyword %) (str %)) '(a b c))] [:a "a" :b "b" :c "c"] user> `(~@(mapcat #(list (keyword %) (str %)) '(a b c))) (:a "a" :b "b" :c "c") user> `#{~@(mapcat #(list (keyword %) (str %)) '(a b c))} #{"a" "b" "c" :a :c :b} user> `{~@(mapcat #(list (k

Re: Lisp/Scheme Style Guide

2010-09-05 Thread Daniel Gagnon
> >a) Python doesn't really have this problem > Python doesn't have this problem because the canonical style is define by PEP 8 and Pythonistas love simplicity through conventions. PEP 8: http://www.python.org/dev/peps/pep-0008/ I think it's actually a great feature of the language, I almost

Re: Typical usage of Compojure

2010-09-05 Thread HB
It is public idea in Ruby community that Sinatra is best used for rapid prototyping and creating API for web application. Maybe because it isn't MVC framework, I don't know. Any way I though since Compojure is similar to Sinatra it will be used for the same purposes. On Sep 5, 5:21 pm, James Reeve

Re: Lisp/Scheme Style Guide

2010-09-05 Thread sitkack
In an effort to paint the shed until it crumbles I will stoke the engine of discourse with starter fluid. I see a couple issues that probably *should* be resolved within the community and once resolved can be pointed to as Canon of Clojure Conventional Conformity (). bla bla wadler's law ..

Re: Extending Clojure's STM with external transactions

2010-09-05 Thread Alyssa Kwan
OK... This question is probably better directed at clojure-dev, but my membership is still pending. I'm having trouble interpreting LockingTransaction.run. Where exactly are read-locks for ensures set? And what precisely is in the commutes map and sets set? Why does membership in sets short-circuit

Re: Question about `binding'

2010-09-05 Thread Yang Dong
That sounds reasonable. But how would you explain `pmap'? This function is not inlined. In fact, every function in clojure.core can't be bound without a declare (as far as I have tried). And it seems this problem only exists when I tried to bind the core functions. It's ok for me to substitute the

Re: Why so?

2010-09-05 Thread Bob Shock
I've been programming in large OO applications since about 1993. One problem is that a lot of useful code gets buried way deep in an OO class hierarchy, where you are forced to create lots of intermediate objects just to get to the useful functions. This really hurts the re-usability, unit testab

Clojure macros

2010-09-05 Thread ingokr
Hello -- I am trying to gain a better understanding of Clojure's macro language. The output I am aiming for (and which is to be used as code in another macro) is as follows: {:a a :b b :c c :d d} The attempt I made is as follows: (defmacro tm [& args] `{~@(mapcat (fn [x] (list (keyword x) x)

Can Clojure compile a source-file? How does it do it?

2010-09-05 Thread CuppoJava
Hi everyone, I'm writing a simple lisp for educational purposes, and I can't figure out how to do compilation. In particular, I can't figure out how I can get a compiled file to run in the same way as if it were loaded. I read on the webpage that Clojure can do this. Does anyone know how Clojure do

Re: Extending Clojure's STM with external transactions

2010-09-05 Thread Constantine Vetoshev
On Aug 30, 5:02 pm, nchubrich wrote: > Persistence libraries always end up warping the entire codebase; I've > never succeeded in keeping them at bay.  Using data with Incanter is > different from ClojureQL, which is different from just using > contrib.sql, and all of it is different from dealing

Re: Why so?

2010-09-05 Thread Lee Hinman
On Fri, Sep 3, 2010 at 10:01 AM, Alan wrote: > A very handy web page to have around; thanks for mentioning it. It > looks nice too, but the accessibility is a bit poor - when I look at > it with an increased text size, the CSS quickly falls apart and > renders it confusing and/or unreadable. So if

Re: Typical usage of Compojure

2010-09-05 Thread James Reeves
On 4 September 2010 16:44, HB wrote: > If Compojure is micro web framework like Sinatra, does this means it > is not suitable for large web applications? The "micro" refers to how much the framework does for you, rather than the size of the application. The advantage of a framework like Ruby on

Re: A secretly Clojure web framework?

2010-09-05 Thread Abhishek Reddy
On Sun, Sep 5, 2010 at 4:56 PM, Martin DeMello wrote: > On Sat, Sep 4, 2010 at 11:23 PM, Abhishek Reddy wrote: > > More generally, the fragmented state of support -- too many separate and > > underused mailing lists, IRC channels, websites, each for small, > composable > > components. > > This is

Re: union using a comparison function

2010-09-05 Thread Thomas
I assume you have to vectors, v1 and v2, and you want to add all the elements from v1 that doesn't equal any element from v2 to v2. In that case you're probably best of using filter to extract the elements from v1 that are not equal to any element in v2. concat the result with v2. Thomas On Sep 2