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
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
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
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
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
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
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
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,
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
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
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
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
> 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
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
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
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
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
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
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
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
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
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
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
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
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..
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
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
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
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 (...
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'
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
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
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
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
> 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
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
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
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
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. -
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 :
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
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
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
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
> 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.,
60 matches
Mail list logo