Re: Multimethods and multiple bodies method

2010-09-01 Thread Miki
Functions (methods as you call them) can have several bodies depending on the number of arguments, for example: (defn stupid-max ([a] a) ([a b] (if (> a b) a b)) ([a b c] (stupid-max (stupid-max a b) c))) Mutlimethods decided which function to call depending on the value of a dispatch functi

Re: Java app invoking Clojure dynamically

2010-09-01 Thread Sean Corfield
On Wed, Sep 1, 2010 at 8:56 PM, Wilson MacGyver wrote: > http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java Awesome! Thank you! I have this working. Just need to tidy up classpath issues to allow the .clj scripts to be wherever I want. And then I need t

Re: Multimethods and multiple bodies method

2010-09-01 Thread Meikel Brandmeyer
Hi, On 2 Sep., 06:26, HB wrote: > How a multimethod in Clojure differs from a method that have multiple > bodies? The latter can only dispatch based on the number of arguments and cannot be extended later on. Compare: (defmulti foo-multi type) (defmethod foo-multi String ...) (defmethod f

Multimethods and multiple bodies method

2010-09-01 Thread HB
Hey, How a multimethod in Clojure differs from a method that have multiple bodies? When to use each approach? Thanks. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from ne

Re: Web Development - templating?

2010-09-01 Thread Phil Hagelberg
On Wed, Sep 1, 2010 at 4:45 PM, David Nolen wrote: > While Enlive has it problems (not enough friendly error reporting about > structural issues in the template, missing HTML files, etc.), I think it's > pretty great leap forward for HTML templating. Agreed. I still get confused sometimes with En

Re: Java app invoking Clojure dynamically

2010-09-01 Thread Wilson MacGyver
if you must dynamic load it. you can do it from a file and use the clojure runtime import clojure.lang.RT; import clojure.lang.Var; full code example at http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java On Wed, Sep 1, 2010 at 10:51 PM, Sean Corfield

Re: Why Jetty? (web development)

2010-09-01 Thread Wilson MacGyver
On Wed, Sep 1, 2010 at 10:46 PM, Sean Corfield wrote: > (so the underlying question is: what's the raw Servlet implementation > that folks use to power Clojure-based web apps on containers other > than Jetty?) I use ring.util.servlet, and gen-class to create a servlet. I wrote something up on th

Re: Why Jetty? (web development)

2010-09-01 Thread Bruce Wang
On Thu, Sep 2, 2010 at 12:46 PM, Sean Corfield wrote: > On Wed, Sep 1, 2010 at 2:00 AM, Shantanu Kumar > wrote: > > Jetty can be easily embedded in a Java app and ring-jetty adapter does > > this job well, so all examples of Clojure web frameworks based on ring > > use Jetty in development mode.

Re: Why Jetty? (web development)

2010-09-01 Thread gary ng
On Wed, Sep 1, 2010 at 7:46 PM, Sean Corfield wrote: > If not, how do you build a Clojure web app that runs on Tomcat / JBoss / etc? > > (so the underlying question is: what's the raw Servlet implementation > that folks use to power Clojure-based web apps on containers other > than Jetty?) > -- T

Java app invoking Clojure dynamically

2010-09-01 Thread Sean Corfield
Let's suppose I have a Java application (or some other language running on the JVM). I want to write some logic in Clojure and call it from Java. I know that I can compile Clojure code to .class files. I've used lein to create a JAR that I've deployed as part of a Java app and I've successfully ca

Re: Why Jetty? (web development)

2010-09-01 Thread Sean Corfield
On Wed, Sep 1, 2010 at 2:00 AM, Shantanu Kumar wrote: > Jetty can be easily embedded in a Java app and ring-jetty adapter does > this job well, so all examples of Clojure web frameworks based on ring > use Jetty in development mode. To deploy to Tomcat/JBoss/others you > can create a WAR file (usi

Re: Web Development - templating?

2010-09-01 Thread David Nolen
On Wed, Sep 1, 2010 at 5:32 PM, Sean Corfield wrote: > On Wed, Sep 1, 2010 at 1:26 PM, Saul Hazledine wrote: > > A good tutorial can be found at: > > http://github.com/swannodette/enlive-tutorial > > It was that tutorial that made me not want to use Enlive. Having *all* > the code completely outs

Re: Web Development - templating?

2010-09-01 Thread Sean Corfield
On Wed, Sep 1, 2010 at 2:14 PM, Saul Hazledine wrote: > Fleet is also worth mentioning as it is an all Clojure solution that > seems to follow the approach you are most comfortable with: > > http://github.com/Flamefork/fleet That looks very interesting, thanx Saul. The documentation is a bit spar

Re: Web Development - templating?

2010-09-01 Thread Sean Corfield
On Wed, Sep 1, 2010 at 1:26 PM, Saul Hazledine wrote: > A good tutorial can be found at: > http://github.com/swannodette/enlive-tutorial It was that tutorial that made me not want to use Enlive. Having *all* the code completely outside the template means a lot of extra work wiring up even the sim

Re: Web Development - templating?

2010-09-01 Thread Saul Hazledine
On Sep 1, 9:09 am, Sean Corfield wrote: > This may be better suited for the new clojure-web-dev list but I'm > used to building web apps with primarily HTML views that have some > embedded scripting. Is there anything similar for Clojure? > Fleet is also worth mentioning as it is an all Clojure s

Re: Web Development - templating?

2010-09-01 Thread Saul Hazledine
On Sep 1, 7:57 pm, Sean Corfield wrote: > On Wed, Sep 1, 2010 at 12:33 AM, Laurent PETIT > wrote: > The ideal setup, in my opinion, after using all sorts of different web > frameworks and languages over the last 14 years, is to have all the > HTML in the template - code never generates HTML - an

Re: Bug in clojure.java.io

2010-09-01 Thread Stuart Halloway
Yes please. > Hi, > I noticed a bug in the clojure.java.io namespace at Line 57: > URL > > > (as-url [u] u) > > > (as-file [u] > > > (if (= "file" (.getProtocol u)) > > > (as-file (.getPath u)) > > > -- (throw (IllegalArgumentException. "Not a file: " u

Re: Web Development - templating?

2010-09-01 Thread gary ng
On Wed, Sep 1, 2010 at 11:58 AM, Laurent PETIT wrote: >> The ideal setup, in my opinion, after using all sorts of different web >> frameworks and languages over the last 14 years, is to have all the >> HTML in the template - code never generates HTML - and to have *some* >> markup in the HTML temp

Re: Web Development - templating?

2010-09-01 Thread Laurent PETIT
2010/9/1 Sean Corfield : > On Wed, Sep 1, 2010 at 12:33 AM, Laurent PETIT > wrote: >> Can you expand your thoughts ? > > Sure :) > > But I just read the link Greg posted about Gulliver and that's pretty > much what I was thinking about. > > Some approaches to generating web apps in some languages

Re: Web Development - templating?

2010-09-01 Thread Sean Corfield
On Wed, Sep 1, 2010 at 12:33 AM, Laurent PETIT wrote: > Can you expand your thoughts ? Sure :) But I just read the link Greg posted about Gulliver and that's pretty much what I was thinking about. Some approaches to generating web apps in some languages / framework lean toward doing it in code

Re: Problem with installing and running labrepl in Eclipse

2010-09-01 Thread Peter Stahl
Hi Laurent, thanks for your feedback. In fact, it seems to be a problem with the m2eclipse plugin. By the way, I was wrong about the missing dependencies on my machine. Maven correctly installed everything into an invisible folder in my home directory. That's why I couldn't find those files at fir

Re: Web Development - templating?

2010-09-01 Thread Michael Ossareh
I highly recommend using Google Closure Templates. Clojure's java interop lets you script up creating a page from the soy files very efficiently and quickly (yay clojure!!). Also the fact that you can run the templates on the server and client mean if your idea scales up you can XHR data to and fro

Re: Web Development - templating?

2010-09-01 Thread Greg
You might be interested in this this project: http://github.com/brool/gulliver See this blog post for more info: http://www.brool.com/index.php/a-modest-proposal It's essentially PHP-ified web development for Clojure. - Greg On Sep 1, 2010, at 12:24 AM, Sean Corfield wrote: > On Wed, Sep 1,

Re: Lisp/Scheme Style Guide

2010-09-01 Thread Alan
I'm afraid if I write my code while this thread is going on, I'll just have to reformat all of it once the discussion has settled this decades-old argument. On Sep 1, 9:45 am, ataggart wrote: > This is so terribly boring.  Don't you guys have any code to write? -- You received this message beca

Re: Lisp/Scheme Style Guide

2010-09-01 Thread Greg
On Sep 1, 2010, at 9:45 AM, ataggart wrote: > This is so terribly boring. Don't you guys have any code to write? A similar question may be asked of you. Do you not have anything better to do than complain? If you find this thread boring, why are you 1) reading it, and 2) replying to it and th

Re: Lisp/Scheme Style Guide

2010-09-01 Thread ataggart
This is so terribly boring. Don't you guys have any code to write? -- 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 y

Re: Lisp/Scheme Style Guide

2010-09-01 Thread Greg
On Sep 1, 2010, at 8:33 AM, David Nolen wrote: > Comparing code formatting to painting practice is a poor metapor at best. The comparison is between programming and painting. Code formatting is being compared to the various artistic decisions involved in painting. I think it is a very apt metap

Re: Game development in Clojure

2010-09-01 Thread tsuraan
> How would that have helped? The problem lay in the fact that there > could be many subclasses of Document, but only one specific subclass, > Attachment, could go into the attachments[] field. So if we had to > split the code into two files, we'd have > > class Attachment(Document) # <-- attachmen

Re: Lisp/Scheme Style Guide

2010-09-01 Thread David Nolen
On Wed, Sep 1, 2010 at 11:07 AM, Greg wrote: > Fogus, I believe it is you who is confused. > > The painter is responsible for everything about the painting. Where the > brush strokes are placed, how they are used, the medium that is used, the > brush widths, and everything else. If his point was

Re: Lisp/Scheme Style Guide

2010-09-01 Thread Greg
Fogus, I believe it is you who is confused. The painter is responsible for everything about the painting. Where the brush strokes are placed, how they are used, the medium that is used, the brush widths, and everything else. If his point was to paint a bridge he could have done it through a var

Re: Game development in Clojure

2010-09-01 Thread Laurent PETIT
A little bit OT, but for files where you prefer to write your declarations "top down" rather than "bottom up": (defmacro top-down [ & body ] `(do ~@(reverse body))) then (defn utility-fn []) (defn high-level-fn [] (utility-fn)) becomes (top-down (defn high-level-fn [] (utility-fn)) (defn u

Re: reflection warnings with defprotocol/deftype with type hints

2010-09-01 Thread Adrian Cuthbertson
Addendum to my previous post; (set! *warn-on-reflection* true) true user=> (.compareTo myComp :d) Reflection warning, NO_SOURCE_PATH:10 - call to compareTo can't be resolved. 1 user=> (.compareTo ^Comparable myComp :d) 1 user=> (class myComp) user$reify__1 (instance? Comparable myComp) true On

Re: reflection warnings with defprotocol/deftype with type hints

2010-09-01 Thread Adrian Cuthbertson
Have a look at Stuart Halloway's video on protocols; http://vimeo.com/11236603 and also clojure.core.protocols.clj in the 1.2 source code. A general google on clojure protocols also brings up some blogs in which various people have some good examples and explanations. Also note that deftype of cou

Bug in clojure.java.io

2010-09-01 Thread abhinav sarkar
Hi, I noticed a bug in the clojure.java.io namespace at Line 57: URL (as-url [u] u) (as-file [u] (if (= "file" (.getProtocol u)) (as-file (.getPath u)) -- (throw (IllegalArgumentException. "Not a file: " u ++ (throw (IllegalArgumentException. (str "Not a fi

Re: How to use Java array of primitive types as key of Clojure map?

2010-09-01 Thread Stuart Halloway
Be super-careful doing this. Java's array equality and hashCode are correct: since arrays are mutable, they are not values. So equals and hashCode are correctly identity-based. Also, 1.2's vector-of lets you have vectors of primitives, which may give you the perf you need. But, if you can ensu

Re: Lisp/Scheme Style Guide

2010-09-01 Thread Cyrus Harmon
I guess much of this comes down to style. I find xml-http-request easier to read and consistent with the english language practice of using hyphens to join words in compound modifiers. But my point regarding XMLHttpRequest was regarding the seemingly arbitrary and difficult to remember (for me

Re: How to use Java array of primitive types as key of Clojure map?

2010-09-01 Thread Nicolas Oury
Multiple things: the internal type name for int arrays is [I So you should try something like: (deftype T [^"[I" keys ] ) then you are looking to overload equals and hashCode from the Object interface (deftype T [^"[I" keys ] Object (equals [x other] (java.util.Arrays/equals key (.key othe

Re: reflection warnings with defprotocol/deftype with type hints

2010-09-01 Thread Albert Cardona
Hi Adrian, Thanks for the explanations. Indeed I was assuming a protocol would work like an interface, so I may just as well use definterface directly. To date, protocols confuse me a bit--I have no reference for it in my head. I see how you use them like multimethods and that's very neat. Thanks

Re: Web Development - templating?

2010-09-01 Thread Remco van 't Veer
On 2010/09/01 09:24, Sean Corfield wrote: > On Wed, Sep 1, 2010 at 12:16 AM, Meikel Brandmeyer wrote: >> I have good experiences with enlive[1]. There you write your templates >> in normal HTML files and modify them from Clojure via CSS-style >> selectors. > > That's pretty horrible. > > I guess

Re: clojure and jogl and jReality

2010-09-01 Thread Sunil S Nandihalli
Hi David, Thanks for your response. I actually didn't know which is the correct jogl.jar to use .. So, I tried various things 1. searched for all the jogl on the clojars and added them to my project (it turns out that all the dependencies were pushed by Mozinator) .. but it does not seem to work..

Re: Keep getting this error "No implementation of method: :arraySet of protocol"

2010-09-01 Thread Jarl Haggerty
I seem to be talking to myself but I've been told that if I find a solution to a problem I should share it. I understand that deftype, defprotocol, and defrecord are pretty volatile in development and my eclipse plugin is simply using an old version of clojure. On Aug 31, 11:37 am, Jarl Haggerty

Re: Keep getting this error "No implementation of method: :arraySet of protocol"

2010-09-01 Thread Jarl Haggerty
If it's of interest to anyone this isn't a problem for me outside of Eclipse. -- 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 pati

Re: Web Development - templating?

2010-09-01 Thread Tim Clark
On Sep 1, 10:06 am, Shantanu Kumar wrote: > On Sep 1, 12:24 pm, Sean Corfield wrote: > > > On Wed, Sep 1, 2010 at 12:16 AM, Meikel Brandmeyer wrote: > > > I have good experiences with enlive[1]. There you write your templates > > > in normal HTML files and modify them from Clojure via CSS-styl

Re: What is the reason Lisp code is not written with closing parenthesis on new lines?

2010-09-01 Thread nemoniac
On Aug 18, 11:09 am, michele wrote: > Wouldn't that make it easier to keep track of them. > > Example: > > (defn myfn-a [a b] >   (if (zero? b) >     a >     (recur >       (afn (bfn (...)) a) >       (dec b > > (defn myfn-b [a b] >   (if (zero? b) >     a >     (recur >       (afn (bfn (...

How to use Java array of primitive types as key of Clojure map?

2010-09-01 Thread John Fingerhut
If you don't do anything special, and create several Java array of bytes (for example) and use them as keys in a Clojure map, the default hashCode and equals implementation will cause two arrays with identical contents to be treated as different keys in the map, unless they are also == in Java. I'

Re: Question re Mikael Sundberg's Getting started with compojure

2010-09-01 Thread Mikael Sundberg
Hi thanks for the great question, and the answer! i have updated the post to contain the information. http://cleancode.se/2010/08/30/getting-started-with-compojure.html /Micke 2010/8/31 Michał Marczyk : > On 31 August 2010 16:52, Jacek Laskowski wrote: >> As we're at it, how does people reload

Re: Web Development - templating?

2010-09-01 Thread Shantanu Kumar
On Sep 1, 12:24 pm, Sean Corfield wrote: > On Wed, Sep 1, 2010 at 12:16 AM, Meikel Brandmeyer wrote: > > I have good experiences with enlive[1]. There you write your templates > > in normal HTML files and modify them from Clojure via CSS-style > > selectors. > > That's pretty horrible. You can

Re: Why Jetty? (web development)

2010-09-01 Thread Shantanu Kumar
On Sep 1, 12:25 pm, Sean Corfield wrote: > On Wed, Sep 1, 2010 at 12:14 AM, Joop Kiefte wrote: > > You can just as well use those. Jetty is just more practical for > > development, as you don't need to deploy to be able to test it. > > That doesn't exactly help answer my question :) Jetty can b

Re: Lisp/Scheme Style Guide

2010-09-01 Thread Mark Engelberg
On Tue, Aug 31, 2010 at 3:38 PM, Cyrus Harmon wrote: > XMLHttpRequest vs. xml-http-request. I rest my case. I'm not even sure what case you're making, let alone what side you're "resting" for. :-/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: reflection warnings with defprotocol/deftype with type hints

2010-09-01 Thread Nicolas Oury
> Clojure is a dynamically typed language. I don't think that putting > types on protocols is very interesting. Type hints should be a low- > level construct put into low-level functions when perfomance needs > dictate it. Otherwise type hints should be omitted. Clojure gives the > developer every

Re: Why Jetty? (web development)

2010-09-01 Thread Remco van 't Veer
On 2010/09/01 09:12, Sean Corfield wrote: > It seems that all the Clojure web frameworks expect you to be using > Jetty - what about deploying to Tomcat or Resin or JBoss or...? I've used Jetty in the past for development because it was (probably still is?) the smallest, lightweight, no nonsense

Re: Why Jetty? (web development)

2010-09-01 Thread Joop Kiefte
Sorry, non-native English. The "What about" got me confused. You mean more like how to get it done? 2010/9/1 Sean Corfield : > On Wed, Sep 1, 2010 at 12:14 AM, Joop Kiefte wrote: >> You can just as well use those. Jetty is just more practical for >> development, as you don't need to deploy to be

Re: Web Development - templating?

2010-09-01 Thread Laurent PETIT
2010/9/1 Sean Corfield > On Wed, Sep 1, 2010 at 12:16 AM, Meikel Brandmeyer wrote: > > I have good experiences with enlive[1]. There you write your templates > > in normal HTML files and modify them from Clojure via CSS-style > > selectors. > > That's pretty horrible. > Can you expand your thou

Re: Why Jetty? (web development)

2010-09-01 Thread Sean Corfield
On Wed, Sep 1, 2010 at 12:14 AM, Joop Kiefte wrote: > You can just as well use those. Jetty is just more practical for > development, as you don't need to deploy to be able to test it. That doesn't exactly help answer my question :) -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -

Re: Web Development - templating?

2010-09-01 Thread Sean Corfield
On Wed, Sep 1, 2010 at 12:16 AM, Meikel Brandmeyer wrote: > I have good experiences with enlive[1]. There you write your templates > in normal HTML files and modify them from Clojure via CSS-style > selectors. That's pretty horrible. I guess I've been spoiled with CFML as a templating language :

Re: Web Development - templating?

2010-09-01 Thread Meikel Brandmeyer
Hi, On 1 Sep., 09:09, Sean Corfield wrote: > So far, all the web frameworks I've seen mentioned in Clojure seem to > expect you to write some sort of "HTML" markup in Clojure itself... I have good experiences with enlive[1]. There you write your templates in normal HTML files and modify them fr

Re: Why Jetty? (web development)

2010-09-01 Thread Joop Kiefte
You can just as well use those. Jetty is just more practical for development, as you don't need to deploy to be able to test it. 2010/9/1 Sean Corfield : > It seems that all the Clojure web frameworks expect you to be using > Jetty - what about deploying to Tomcat or Resin or JBoss or...? > -- > S

Why Jetty? (web development)

2010-09-01 Thread Sean Corfield
It seems that all the Clojure web frameworks expect you to be using Jetty - what about deploying to Tomcat or Resin or JBoss or...? -- 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, y

Web Development - templating?

2010-09-01 Thread Sean Corfield
This may be better suited for the new clojure-web-dev list but I'm used to building web apps with primarily HTML views that have some embedded scripting. Is there anything similar for Clojure? So far, all the web frameworks I've seen mentioned in Clojure seem to expect you to write some sort of "H

Re: reflection warnings with defprotocol/deftype with type hints

2010-09-01 Thread Adrian Cuthbertson
> There are probably ways of creating types on protocols, but I haven't > tried that yet. Sorry, what I meant to say was... > There are probably ways of creating deftypes on protocols, but I haven't > tried that yet. On Wed, Sep 1, 2010 at 8:35 AM, Meikel Brandmeyer wrote: > Hi, > > On 1 Sep.,