Dear Friends,
I am thinking about porting my existing program to clojure. Is there
any way of designing equivalents to classes with simple inheritance?
For e.g. if I have base class fruit and derived classes apple and
orange. The OOP design gives me a possibility to handle those object
in the same
I think the easiest way to port OO code would be to use Clojure's
multimethods, dispatching on the type of the first argument.
--
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 post
On 17 Aug 2010, at 21:21, Steve Molitor wrote:
> Sorry my message got truncated. Let's try again:
>
> Fuzzy completion (ac-source-slime-fuzzy) isn't working for me. It complains
> that the function slime-fuzzy-completions is not defined. I'm using slime.el
> version 2010404, which does not d
On Aug 17, 12:14 am, Lee Spector wrote:
> On Aug 16, 2010, at 4:13 PM, Meikel Brandmeyer wrote:
>
> > Every descent editor should provide a comment-selected-text functionality.
> I've worked in several editors that have comment-selected-text, but I don't
> see it in Eclipse/Counterclockwise
I'v
Dear all,
I have a simple problem I can't manage to solve.
I have a library of multiple namespaces( a b c) that I want to include
in one namespace lib, so user of
the library can only use/require lib and have access to all the
functions i a, b and c.
What is the standard way to do that?
Best,
Hi,
On 18 Aug., 11:49, Nicolas Oury wrote:
> I have a library of multiple namespaces( a b c) that I want to include
> in one namespace lib, so user of
> the library can only use/require lib and have access to all the
> functions i a, b and c.
>
> What is the standard way to do that?
There is no
+1 Neat idea. Starting a Google group "Clojure web development" might
be a solution.
Regards,
Shantanu
On Aug 18, 2:05 am, Rasmus Svensson wrote:
> I think there's a lot of questions that a Clojure programmer faces
> when doing web programming, not only regarding how the libraries work,
> but al
That helps a lot. Thank you very much.
That is not very nice though. I quite would like a :reexport option to use.
Best,
Nicolas.
On Wed, Aug 18, 2010 at 11:17 AM, Meikel Brandmeyer wrote:
> There is no standard way of doing that. There is immigrate of an old
> Compojure version, which is a h
Great idea. I'm trying to figure out web development in Clojure atm and a
group to specifically talk about this area would be great.
On 18 August 2010 11:20, Shantanu Kumar wrote:
> +1 Neat idea. Starting a Google group "Clojure web development" might
> be a solution.
>
> Regards,
> Shantanu
>
>
Hi Nicolas,
I've done a bit of manipulation of namespaces for dynamic loading and
executing of functions in a web app context which might give you some
ideas...
Here ns-nm and ipath have been extracted from a url. Then...
(let [ .
ipath (if (or (nil? ipath) (= ipath "")) "root" ipath)
ip
If you intern all the ns-public variable of a namespace, they will be
reexoprted?
Will there be an indirection at runtime or the JVM can sort that out?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googl
I'm experiencing the exact same problem. Haven't found a way to fix
this yet.
On 17 Aug., 04:38, Stefan Kamphausen wrote:
> Hi,
>
> just yesterday I took a first look at auto-complete together with your
> slime auto completion sources.
>
> I'm encountering some Exceptions, though,
>
> If I'm in a
On Aug 18, 2:42 am, Michael Wood wrote:
> "nils replace nils when there are fewer substitutions than nil
> positions" was one of the requirements.
>
> From the first post:
>
> > If nil is encountered in the first sequence and the second sequence is
> > exhaused, nil will be returned:
>
> > e.g. u
On 18 Aug 2010, at 13:51, MHOOO wrote:
> I'm experiencing the exact same problem. Haven't found a way to fix
> this yet.
I've fixed the problem in my fork of swank-clojure and requested that Phil pull
the commit into the master repo:
http://github.com/purcell/swank-clojure/commit/7172c275f
This works
(deftype A [a])
(.a (A. 5))
This don't
(deftype A [^{:volatile-mutable true} a])
(.a (A. 5))
Is this normal? Is this a bug?
How could I access the field?
Best,
Nicolas.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to thi
On Wed, Aug 18, 2010 at 10:06 AM, Nicolas Oury wrote:
> This works
>
> (deftype A [a])
>
> (.a (A. 5))
>
> This don't
>
> (deftype A [^{:volatile-mutable true} a])
>
> (.a (A. 5))
>
> Is this normal? Is this a bug?
>
> How could I access the field?
>
> Best,
>
> Nicolas.
>
It's not a bug. You nee
Consider the following bit of code:
(let [ x (new java.lang.Boolean false) ] (if x "trouble" "ok"))
As you might guess from the fact that I'm calling it's a trick question, the
above code returns "trouble", not "ok". From experimentation, it looks like
clojure's if takes the second branch if the
(defmacro fat-if)
On Wed, Aug 18, 2010 at 4:09 PM, Brian Hurt wrote:
> Consider the following bit of code:
>
> (let [ x (new java.lang.Boolean false) ] (if x "trouble" "ok"))
>
> As you might guess from the fact that I'm calling it's a trick question, the
> above code returns "trouble", not "
And they need to be in an interface 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 unsub
On Wed, Aug 18, 2010 at 11:09 AM, Brian Hurt wrote:
> This is, however, more than a little bit surprising and depressing.
> Somewhere, in my 10K lines of clojure code, boolean values are getting boxed
> in exactly that way. I've fixed the current problem (dropping in a call to
> .booleanValue in
Here's an approach that might work...
; app1.clj
(ns app1)
(defn myinc[x] (inc x))
(defn mydec[x] (dec x))
(defn .)
;app2.clj
(ns app2)
(defn mysq[x] (* x x))
then you have a mylib.clj which is your public "user" module;
(ns mylib)
(require 'app1 'app2)
(defn exports[]
(refer 'app1 :only
On Wed, Aug 18, 2010 at 11:09 AM, Brian Hurt wrote:
> Consider the following bit of code:
>
> (let [ x (new java.lang.Boolean false) ] (if x "trouble" "ok"))
The Javadoc for Boolean has something to say on this subject[1]
as does the following excerpt from Fogus' book The Joy of
Clojure:
Don't c
And is the one that works (for non-mutable fields) reliable or just an
implementation accident that could change in the future?
On Wed, Aug 18, 2010 at 4:27 PM, Nicolas Oury wrote:
> And they need to be in an interface first?
>
--
You received this message because you are subscribed to the Goog
This is a helpful hint, and probably one that others are already
using, but seemed good to share.
If you're sorting a list of maps on one field, you can use
(sort-by :community list-of-residents)
But sorting on two (or more) fields seems to require a little more
coding:
(sort-by :communit
On Wed, Aug 18, 2010 at 11:41 AM, Nicolas Oury wrote:
> And is the one that works (for non-mutable fields) reliable or just an
> implementation accident that could change in the future?
I'm assuming it's reliable for 1.2.0.
--
You received this message because you are subscribed to the Google
On Wed, Aug 18, 2010 at 11:34 AM, David Nolen wrote:
> On Wed, Aug 18, 2010 at 11:09 AM, Brian Hurt wrote:
>
>> This is, however, more than a little bit surprising and depressing.
>> Somewhere, in my 10K lines of clojure code, boolean values are getting boxed
>> in exactly that way. I've fixed t
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 (...)) a)
(dec b)
)
)
)
--
You received this message becau
Hi,
I noticed that when I define a record (using defrecord) in a namespace
having hyphen in its name (like abc.d-ef) and compile the clj file using
AOT, a class file corresponding to the record defined is created in the
package with the name same as the namespace it is defined in, with hyphen
(in t
Ok, thanks for the answer.
I actually have Leiningen installed, and I've just done a "lein
update" - it's now on 1.2.0 as it says. Is this actually "clojure
1.2.0", or just a stand-alone leiningen version?
But I'm in the progress of just learning, so I don't want to have
projects (yet). Because o
Hi,
I am a post-grad student looking for a cool compiler - project to do.
I am getting comfortable with clojure and would really like to help
Ideas anyone?
or, Is there a to-do list where can i start?
Cheers
Sreeraj
--
You received this message because you are subscribed to the Google
Groups "
On Wed, Aug 18, 2010 at 2:09 AM, michele wrote:
> Wouldn't that make it easier to keep track of them.
It would make it easier for people to keep track of them. However,
keeping track of parentheses is not something people should be doing
since it's menial, repetitive, error-prone work. Computer p
My take is almost identical but I used the same length arguments for
the collections which means that the difference in the if branch are
easier to spot, at the cost of more cryptic argument names. This
version will not blow the stack, and its easy to wrap in lazy-seq.
(defn nil-coalesce [s1 s2]
On Wed, Aug 18, 2010 at 11:09 AM, Brian Hurt wrote:
> Consider the following bit of code:
>
> (let [ x (new java.lang.Boolean false) ] (if x "trouble" "ok"))
I consider the fact that Boolean has a public constructor a bug. It
can only ever represent 2 values.
However, if you do (let [x (java.lan
On Wed, Aug 18, 2010 at 11:58 AM, Brian Hurt wrote:
> For the record, no where in my code am I deliberately creating Boolean
> objects. Why the hell would I write (new java.lang.Boolean false) when I
> can just as easily write false? And I have looked through the code to see
> if something stup
I am not an expert. Is it possible on some JDK to put a breakpoint on
Boolean constructor and look at the stack?
Or you can't put a breakpoint on standard library?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to cl
No, you can put a breakpoint on any class, regardless of where it's
been loaded from.
In this case, I'd suggest not relying on the line numbers shown in
source dumps. At least in my experience, line numbers in the standard
library source differ from what is shown at runtime. All three Java
IDEs
On Wed, Aug 18, 2010 at 2:09 AM, michele wrote:
> (defn myfn-b [a b]
> (if (zero? b)
> a
> (recur
> (afn (bfn (...)) a)
> (dec b)
> )
> )
> )
I started out trying to do that but it ended up being far more work
that it was worth - as Phil said, computer programs (IDEs / editor
I have a solution :
(defn unfold [f & as]
(if-let [[hd new-as] (apply f as)]
(lazy-seq
(cons hd (apply unfold f new-as)))
()))
unfold could be called co-reduce or coreduce. It is the dual operation
of reduce, in category theory.
Instead of reducing a seq to create a value, it
its a good idea, so here it is:
Congratulations: you've successfully created your Google Group, Clojure Web
Development.
Here are the essentials:
* Group name: Clojure Web Development
* Group home page: http://groups.google.com/group/clojure-web-dev
* Group email address clojure-web-...@googleg
auto-indentation and parens highlighting are better than lines with
only one parens.
At least for me.
There is no law. Do what is best for you.
You might, or not, change your mind when you have more practice with
all those parens.
--
You received this message because you are subscribed to the
Would suggest to consider this:
(let [ x (true? (new java.lang.Boolean false)) ] (if x "trouble"
"ok"))
Regards,
Shantanu
On Aug 18, 10:05 pm, Chas Emerick wrote:
> No, you can put a breakpoint on any class, regardless of where it's
> been loaded from.
>
> In this case, I'd suggest not relying
On Wed, Aug 18, 2010 at 1:11 PM, Sean Corfield wrote:
> On Wed, Aug 18, 2010 at 2:09 AM, michele wrote:
>> (defn myfn-b [a b]
>> (if (zero? b)
>> a
>> (recur
>> (afn (bfn (...)) a)
>> (dec b)
>> )
>> )
>> )
>
> I started out trying to do that but it ended up being far more wo
Putting them on separate lines put the focus on the wrong element of
the code. You do not want to be focusing on the parentheses, you want
to be focusing on the structure of the code. The idiomatic lisp
formatting style uses indentation to reveal the large scale structure
of the code, and so the
On Wed, Aug 18, 2010 at 10:28 AM, Shantanu Kumar
wrote:
> Would suggest to consider this:
>
> (let [ x (true? (new java.lang.Boolean false)) ] (if x "trouble"
> "ok"))
Ah, but that wouldn't work for a new Boolean set to true:
(let [ x (true? (new java.lang.Boolean true)) ] (if x "ok" "trouble"))
You can create a new project, even if you don't use it:
lein new experiments
inside it will create a project.clj.
Checks the dependencies look like that:
:dependencies [[org.clojure/clojure "1.2.0-RC3"]
[org.clojure/clojure-contrib "1.2.0-RC3"]
Type lein deps in the directo
I can get rid of those errors by evaling this in the repl. Does this
work for you as well?:
(do
(require 'clojure.contrib.with-ns)
(clojure.contrib.with-ns/with-ns
'swank.commands.basic
(defn- describe-to-string [var]
{:pre [(var? var)]}
(with-out-str
(print-doc var)
On 8/18/10 1:32 PM, Brian Goslinga wrote:
> Putting them on separate lines put the focus on the wrong element of
> the code. You do not want to be focusing on the parentheses, you want
> to be focusing on the structure of the code. The idiomatic lisp
> formatting style uses indentation to reveal
Three reasons.
First, "code density", that is the number of
(/ number-of-lines-of-code number-of-lines-on-screen) should
approach 1 so that every line on the screen is code.
Second, real editors paren-bounce to show matching parens.
Third, "real lispers" don't exit the thought process until the
It's almost purely community convention that has been adopted from Lisp.
You may be interested in this link:
http://gregslepak.posterous.com/on-lisps-readability
There is much discussion about this topic there.
Cheers,
Greg
On Aug 18, 2010, at 2:09 AM, michele wrote:
> Wouldn't that make it e
Hi,
I have uploaded source code (Apache 2 license) for SQLRat - a library
for Clojure 1.2 to access relational databases using DataTypes
(entities). It also lets you define relations between entities and
navigate them. While this is a part of what typically Object-
Relational Mapping (ORM) framewo
The indentation is enough of a hint to get it right. For example, in
myfn-a, because you've indented it correctly I can easily tell that
(dec b) is the second argument to recur, without looking at the
parentheses at all. Isolating close-parens would probably help a
little with this task, but the lo
All~
Boolean.valueOf() was added in 1.4. While that seems ancient, some older
libraries use 'new Boolean()' because they maintain 1.2 compatibility. It
seems like Clojure should take more care when it unboxes Booleans...
Matt
On Wed, Aug 18, 2010 at 12:57 PM, Nicolas Oury wrote:
> I am not an
On Aug 18, 2010, at 1:38 PM, Greg wrote:
> http://gregslepak.posterous.com/on-lisps-readability
That article is dishonest. The author changes indentation widths between
examples, while focusing entirely on the trailing-parens. He claims in a
comment that "the post is not solely about trailing p
On Aug 18, 2010, at 12:07 PM, Michael Gardner wrote:
> On Aug 18, 2010, at 1:38 PM, Greg wrote:
>
>> http://gregslepak.posterous.com/on-lisps-readability
>
> That article is dishonest.
Speaking as the author, I'm a bit offended.
Yes, the indentation width was changed, and this was acknowledged
Hi,
Am 18.08.2010 um 11:09 schrieb michele:
> (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 (...)) a)
> (dec b)
>)
> )
> )
I find it interesting, that peop
I don't see what the concern may be. Can you elaborate?
On Aug 18, 10:04 am, Matt Fowles wrote:
> All~
>
> Boolean.valueOf() was added in 1.4. While that seems ancient, some older
> libraries use 'new Boolean()' because they maintain 1.2 compatibility. It
> seems like Clojure should take more c
A more serious answer is that when I code in Java I use the
brace-on-a-line kind of indentation. When I code in Lisp I
never write single-line parens of any kind.
I find that I think differently in each language.
My Java code is always a pile of declare-this, do-this, do-this, return
Thus I find
On Aug 18, 2010, at 2:49 PM, Greg wrote:
> On Aug 18, 2010, at 12:07 PM, Michael Gardner wrote:
>
>> On Aug 18, 2010, at 1:38 PM, Greg wrote:
>>
>>> http://gregslepak.posterous.com/on-lisps-readability
>>
>> That article is dishonest.
>
> Speaking as the author, I'm a bit offended.
Too bad. I
I should qualify my response though to say that I am not advocating that
everyone switch their preferred style of code.
Just simply giving reasons for why some prefer one style over another. It's a
personal thing, and I do not wish to engage in a flame war over it.
Best,
Greg
On Aug 18, 2010,
While I think Clojure is an impressive achievement, I would not have
thought that the Clojure compiler (or Lisp compilers in general)
would be interesting for a post-grad student to work on. After all,
Lisps are known for their simple syntax and grammar, and Clojure
compiles to Java byte codes, s
On Wed, Aug 18, 2010 at 1:36 PM, Greg wrote:
> Attached is a screenshot of some code from the wonderful Incanter library. I
> think it's a great illustration of how confusing stacking parenthesis can be
> (there are many functions in there that are like this).
Again, that's quite a straw man--t
Actually, to be honest the short C++ example with lisp bracket style I
find a lot easier to read: I don't need to scan all the page to find
what belongs where...
2010/8/18 Greg :
>> Now the question you're asking is, why don't lispers write
>> (MyFactory somearg
>> )
>> which makes me cringe.
>
On Wed, Aug 18, 2010 at 1:36 PM, Greg wrote:
> Attached is a screenshot of some code from the wonderful Incanter library. I
> think it's a great illustration of how confusing stacking parenthesis can be
> (there are many functions in there that are like this).
But the indentation is broken in t
Greg wrote:
Now the question you're asking is, why don't lispers write
(MyFactory somearg
)
which makes me cringe.
That's not at all what's being suggested -- you'll find that both in the OP's
code and in the link below, there are many locations where closing parenthesis
are ended on
> Yes, I read the link. I'm going to hazard a guess that lisp is not your
> native language :-)
I consider Lisp to be one of my favorite languages (if not my favorite), and
I've been coding in it for several years.
It's rather silly to assume something about someone's programming experience
ba
> Too bad. If you wanted to focus on the trailing-parens (which you clearly did
> in that article), you should have kept everything else the same between your
> examples.
Perhaps I should, then I wouldn't have to respond to your emails. :-p
As I've said multiple times now, now indentation width
> so presumably the Clojure compiler does
not include an optimizer.
So write an optimizing Clojure compiler! Or do type inference for
Clojure. Or partial evaluation. Or a compiler that targets LLVM.
On Aug 18, 10:46 pm, ".Bill Smith" wrote:
> While I think Clojure is an impressive achievement, I
Or a Clojure to Javascript compiler. So many interesting projects!
On Aug 19, 12:36 am, Jules wrote:
> > so presumably the Clojure compiler does
>
> not include an optimizer.
>
> So write an optimizing Clojure compiler! Or do type inference for
> Clojure. Or partial evaluation. Or a compiler that
I wrote a post about this very thread.
http://blog.fogus.me/2010/07/12/wadlers-law-extended-to-clojure/
:f
--
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
Hi people!
Related to Clojure to Javascript
http://github.com/richhickey/clojure-contrib/tree/master/clojurescript/
Angel "Java" Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez
On Wed, Aug 18, 2010 at 7:37 PM, Jules wrote:
> Or a Clojure to Javascript compiler. So many interesting pro
+1 for an optimizer
--
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,
Or a native dalvik compiler!
--
Pull me down under...
On Thu, Aug 19, 2010 at 10:37 AM, Jules wrote:
> Or a Clojure to Javascript compiler. So many interesting projects!
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, s
The Incanter example is confusing for the same reason that the
Leiningen example from the blog post is confusing, and I don't think
paren style matters at all. The functions have grown over time,
they're now too big, and they need to be refactored into several
smaller functions. The paren style is
Write a compiler routine to detect tail recursion.
It is my (limited) understanding that Java can perform
tail recursion elimination but only under limited
conditions.
Is there a way to detect tail recursion in Clojure and
dynamically rewrite the code to do real recursion rather
than using recur
> However, if you do (let [x (java.lang.Boolean/getBoolean "false")] (if
> x :trouble :ok)) you're fine, which obviously isn't helpful in your
> situation.
Boolean.getBoolean() is pretty evil, too. It was featured in one of
Joshua Bloch's java puzzlers (which might have been borrowed from
somewhe
I've rarely found these coding style discussions to be productive, and have
wondered why source control systems don't just store code in a whitespace
normalized format and automatically format the code to your own taste when
you check it out, because, let's face it, formatting is semantically
irrel
I'm reminded gigamonkey's footnote about when functions get too big:
"A friend of mine was once interviewing an engineer for a programming job and
asked him a typical interview question: how do you know when a function or
method is too big? Well, said the candidate, I don't like any method to b
On Wed, 18 Aug 2010 22:48:07 -0400
Paul Stadig wrote:
> Then I move on to thinking it best for a language designer to just legislate
> fomatting and make it a compiler error, but that would probably generate
> more discussion than otherwise, so I've just written the whole thing off as
> a lose-los
On Aug 18, 2010, at 7:48 PM, Paul Stadig wrote:
> It may help *you* grasp the meaning more quickly, but the opposite may be
> true for others. But I guess automatic formatting would totally destroy the
> ability to talk about line 16 of a particular file.
>
This is a nifty point and idea.
I thi
only in the cases already handled by recur.
jvm's goto instruction only works within method bodies
On Wed, Aug 18, 2010 at 6:24 PM, Tim Daly wrote:
> Write a compiler routine to detect tail recursion.
>
> It is my (limited) understanding that Java can perform
> tail recursion elimination but onl
It isn't helpful at all to me. My eyes bleed when I see code written
like that.
It may be helpful to some people, but I don't see the point when I
have an editor that can match parens for me without any real work on
my part. The parens aren't something I feel I need to "maintain",
because between
Could the compiler insert phantom "method bodies" around classes?
Or does the JVM insist that you can't "lie about the code structure"?
Am I being too lispish for the JVM? Clearly the JVM needs to look up
some factoid out of the method body in order to recur so I'm suggesting
that the whole set of
There is a size limit on methods on the jVM.
partial-evaluator would be a cool project, I think.
On Thu, Aug 19, 2010 at 6:38 AM, Tim Daly wrote:
> Could the compiler insert phantom "method bodies" around classes?
> Or does the JVM insist that you can't "lie about the code structure"?
> Am I bei
83 matches
Mail list logo