Re: require :require

2013-12-06 Thread Jonathan Fischer Friberg
Inside the ns form they are the same. Outside the ns form, only (require
'[a.b]) works (with quoting, as Kelker said).

Jonathan


On Fri, Dec 6, 2013 at 10:24 AM, Kelker Ryan theinter...@yandex.com wrote:

 I believe one is a directive and the other is a function.

 :require doesn't need the values to be quoted

 (:require xyz)

 require needs values to be quoted so that they're not evaluated when
 passed as arguments

 (require 'xyz)

 I could be wrong though.

 06.12.2013, 18:17, BillZhang jingege...@gmail.com:

 hi all,
 What's the differences between those two snippets?
 1.
 (ns a
   (require [a.b]))

 2.
 (ns a
   (:require [a.b]))

 They all works in my code!

 thx~


 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Like if, but it composes functions

2013-02-20 Thread Jonathan Fischer Friberg
Function composition similar to that has been explored a lot in the haskell
world. See:

http://www.haskell.org/haskellwiki/Arrow

I also made a small library to implement some of the operators:

https://github.com/odyssomay/clj-arrow

I think the reason arrows are so interesting in haskell is because they
generalize monads.
However, in clojure I have found them to make code harder to write/read
rather than easier,
so I kind of gave up the concept after a while (and haven't updated the
library). Although
it's possible that they are actually highly useful and I've just missed
something.

Jonathan


On Wed, Feb 20, 2013 at 3:55 PM, James MacAulay jmacau...@gmail.com wrote:

 Ben: of course, haha...making it a macro seems rather silly now :P

 Alan: I didn't know about useful before, thanks for the pointer! fix and
 to-fix look great.

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: features expression

2013-03-07 Thread Jonathan Fischer Friberg
Isn't it possible to solve this with a simple macro?

(case-dialect
   :clojure (... clojure code ...)
   :clojurescript (... clojurescript code ...))

Then, in jvm clojure, it could be implemented as:
(defmacro case-dialect [ {:keys [clojure]}] clojure)

and in clojurescript:
(defmacro case-dialect [ {:keys [clojurescript]}] clojurescript)

Alternatively, we could have a def, say *clojure-dialect*, then:
(defmacro case-dialect [ {:as m}] (get m *clojure-dialect*))

(although the dialect should probably be part of *clojure-version* ... you
get the idea)

Jonathan


On Thu, Mar 7, 2013 at 10:04 AM, Akhil Wali akhil.wali...@gmail.com wrote:

 IMHO features expressions should be evaluated at read-time only.
 Putting it off till the compilation phase only complicates things.
 So I'm actually favoring a preprocessing step like here -
 http://dev.clojure.org/display/design/Feature+Expressions?focusedCommentId=6390066#comment-6390066

 The idea is simple; when the reader parses a sexpr, and if there's a
 feature expression,then  only use the part that's relevant to the current
 Clojure dialect.
 The only complication with this scheme is that all information in
 *clojure-version* is related to the version numbers only; however, this
 could be changed easily.



 On Thu, Mar 7, 2013 at 7:46 AM, Brent Millare brent.mill...@gmail.comwrote:

 +1

 Isn't is possible to accomplish all these efforts using tagged literals?
 https://github.com/miner/wilkins

 This way the facilities for read-time code generation can be customized
 and any reader that supports tagged-literals will support this. All of this
 is data provided as arguments, no evaluation. Evaluation happens from the
 tag function.

 On Wednesday, March 6, 2013 8:24:15 PM UTC-5, Brian Goslinga wrote:

 Do we really need new syntax for feature expressions? Although it would
 be more ugly than CL's feature expressions, we could use a reader literal.
 For example #feature [feature expression value]. Using a reader literal
 is simple, compatible with EDN, and allows for the feature expressions to
 be backported to an older version of Clojure using a library.

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 Akhil Wali

 # http://github.com/darth10 https://github.com/darth10
 # http://darth10.github.com

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: features expression

2013-03-07 Thread Jonathan Fischer Friberg
The macro doesn't have that problem - as long as the code is inside the
macro.

I.e. this works (in clojure):
(case-dialect :clojurescript some.class/PROP)

But this doesn't:
(defn get-PROP [] some.class/PROP)

(case-dialect :clojurescript (get-PROP))

If I'm not mistaken, the proposed expressions has the same problem.

Jonathan


On Thu, Mar 7, 2013 at 4:10 PM, Andy Fingerhut andy.finger...@gmail.comwrote:

 I may be wrong, but I think this, and anything else that tries to solve
 this problem after read time, will fail for one of the primary uses of
 feature macros: Java packages/namespaces that exist for Clojure/JVM but not
 ClojureScript, and JavaScript namespaces that exist for ClojureScript but
 not Clojure/JVM.  Each of those would cause a compilation error for the
 other, I believe.

 e.g. java.lang.Long and java.util.Date don't exist in ClojureScript, and
 are the kinds of things you would want to conditionally compile on for
 Clojure/JVM.

 Andy


 On Thu, Mar 7, 2013 at 5:44 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 Isn't it possible to solve this with a simple macro?

 (case-dialect
:clojure (... clojure code ...)
:clojurescript (... clojurescript code ...))

 Then, in jvm clojure, it could be implemented as:
 (defmacro case-dialect [ {:keys [clojure]}] clojure)

 and in clojurescript:
 (defmacro case-dialect [ {:keys [clojurescript]}] clojurescript)

 Alternatively, we could have a def, say *clojure-dialect*, then:
 (defmacro case-dialect [ {:as m}] (get m *clojure-dialect*))

 (although the dialect should probably be part of *clojure-version* ...
 you get the idea)

 Jonathan


 On Thu, Mar 7, 2013 at 10:04 AM, Akhil Wali akhil.wali...@gmail.comwrote:

 IMHO features expressions should be evaluated at read-time only.
 Putting it off till the compilation phase only complicates things.
 So I'm actually favoring a preprocessing step like here -
 http://dev.clojure.org/display/design/Feature+Expressions?focusedCommentId=6390066#comment-6390066

 The idea is simple; when the reader parses a sexpr, and if there's a
 feature expression,then  only use the part that's relevant to the current
 Clojure dialect.
 The only complication with this scheme is that all information in
 *clojure-version* is related to the version numbers only; however, this
 could be changed easily.



 On Thu, Mar 7, 2013 at 7:46 AM, Brent Millare 
 brent.mill...@gmail.comwrote:

 +1

 Isn't is possible to accomplish all these efforts using tagged
 literals? https://github.com/miner/wilkins

 This way the facilities for read-time code generation can be customized
 and any reader that supports tagged-literals will support this. All of this
 is data provided as arguments, no evaluation. Evaluation happens from the
 tag function.

 On Wednesday, March 6, 2013 8:24:15 PM UTC-5, Brian Goslinga wrote:

 Do we really need new syntax for feature expressions? Although it
 would be more ugly than CL's feature expressions, we could use a reader
 literal. For example #feature [feature expression value]. Using a
 reader literal is simple, compatible with EDN, and allows for the feature
 expressions to be backported to an older version of Clojure using a 
 library.

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 Akhil Wali

 # http://github.com/darth10 https://github.com/darth10
 # http://darth10.github.com

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 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

Re: Windows Installation

2013-03-09 Thread Jonathan Fischer Friberg
My experience:

1. Download lein.bat
2. Run it

Jonathan



On Sat, Mar 9, 2013 at 10:23 AM, BJG145 benmagicf...@gmail.com wrote:

 Perhaps this general anti-Windows attitude is what Windows-based newcomers
 to Clojure find off-putting...


 On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley wrote:

 Since I've seen a few recent posts about this experience, I figured I'd
 share mine:

 0a) Install cygwin. I don't understand how any programmer stuck using
 windows can get by without it
 1) Install the Oracle JDK
 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside
 cygwin in a directory that was already in my
 PATH: ~/bin)
 2) Download the lein install script as text from the leiningen home
 page.
 3) Copy it over to my cygwin directory
 4) Search/replace to replace the HTML entities with the real thing. I
 think this was a matter of amp; and gt;
 5) It was already executable, so just run it (naming it lein.sh rather
 than lein.bat was important). I got errors about
 certificates and permissions. They mentioned instructions about setting
 up an environment variable (something
 about something like `export DOWNLOAD=curl --trusting %1`...that wasn't
 it, but it was along the same lines).
 I believe that it's some weirdness in the account settings (I have other
 issues along the same lines in totally
 unrelated packages), but I suppose I could have just installed some
 horrible virus. Oh, well.
 6) Create a new project
 7) Change project.clj to use clojure 1.5
 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all
 windows-style, which confused cygwin. So
 basic clojure.core pieces weren't found.
 8a) I suspect I could have set up, say, powershell, to make this work.
 But that's stupid, and I don't have time
 to waste on it.
 9) nrepl-jack-in inside emacs worked fine.
 9a) I'm using an init.el from other systems that already have clojure set
 up. But there isn't anything fancy or
 special or customized about it. Just standard configuration stuff that
 I've found on bare-minimal blog posts
 10) Add a symlink to lein in ~/bin.

 I guess that probably looks big and scary. Windows users are used to a
 pretty GUI that they ignore and click
 Next a lot. I dont have a lot of sympathy.

 I haven't done anything meaningful here at all. But the bare-bones part
 of the installation process Just Worked.

 Thank you *so* much to all the people who have worked so hard to make
 this as simple as it is!

 Respectfully,
 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
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: :use an entire namespace full of protocols or stick with :require?

2013-03-10 Thread Jonathan Fischer Friberg
I would say using :require :as is in almost all cases better.
However, I think :use is preferred if almost everything done
in the current namespace depends on the used namespace.
Though, no more than one namespace should ever be imported
with :use in the same namespace.

In your case I think it's acceptable to :use the namespace with
protocols - but no more. Also, :use :only is to be avoided almost
as much as :use. I tend to use :use :only for common functions
that are not in core. clojure.java.io/resource being the most common
one.

Jonathan


On Sun, Mar 10, 2013 at 1:40 PM, Alex Baranosky 
alexander.barano...@gmail.com wrote:

 From experience in your case (300+) I'd use require/as with a small prefer
 like p/ .


 On Sun, Mar 10, 2013 at 5:10 AM, Jim - FooBar(); jimpil1...@gmail.comwrote:

 On 10/03/13 12:03, Marko Topolnik wrote:

 I came to prefer one-letter prefix for a common ns over no prefix at
 all. Once you get accustomed to it, prefixless fns start looking wrong,
 and the overhead of two chars is something we can live with.

 yes I agree with you 100%...this is my approach as well for 'useful'
 namespaces...for example a hypothetical utilities.clj is good if it's
 aliased uniformly across namespaces as 'ut'...do you do the same with your
 abstractions? do you always alias your protocols.clj? my question is
 specific to protocols as they will only be used in a couple of places,
 mainly in the 'concretions' namespace...to be honest, at the moment I'm
 using :refer :all simply because I'd need the characters 'pro/' more than
 300 times in that namespace...it would actually make readability worse in
 my opinion...


 Jim

 --
 --
 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 --- You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to 
 clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .



  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What's the point of - ?

2013-03-11 Thread Jonathan Fischer Friberg
- and - are for some reason really hard to grasp for
many when starting out - me included.

On Mon, Mar 11, 2013 at 11:58 AM, edw...@kenworthy.info wrote:

 So I understand that:

 (- foo bar wibble)

 is equivalent to

 (wibble (bar (foo)))


Correct, but that misses the point. Thinking about - in terms
of what the expansion is is not going to work. Think about
it like this: (imperative - I know, but explains it better I think)

We are going to execute (- foo bar wibble).
We have a variable 'current-value', then:

1. Set current-value to foo
2. Set current-value to (bar current-value)
3. Set current-value to (wibble current-value)
4. Return current-value

Another example:
(- {}
  (assoc :hello 3)
  (assoc :world 4)
  (dissoc :world)
  :hello
  inc)

We get:

1. Set current-value to {}
2. Set current-value to (assoc current-value :hello 3) i.e. {:hello 3}
3. Set current-value to (assoc current-value :world 4) i.e. {:hello 3
:world 4}
4. Set current-value to (dissoc current-value :world) i.e. {:hello 3}
5. Set current-value to (:hello current-value) i.e. 3
6. Set current-value to (inc current-value) i.e. 4
7. Return current-value
Result: 4

- is not implemented imperatively like that, but the point is that you
shouldn't think about it in terms of expansion. You should think of it as
we take the initial value,
run the first function on the initial value and store the result,
apply the second function on the stored value and store the result,
...

Hope this clear things up.

Jonathan

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: ANN Validateur 1.4 is released

2013-03-12 Thread Jonathan Fischer Friberg
We recommend all users to upgrade to
1.7.0https://clojars.org/com.novemberain/validateur/versions/1.7.0
.

I'm guessing it should be 1.4.0?

Jonathan



On Tue, Mar 12, 2013 at 8:58 PM, Michael Klishin 
michael.s.klis...@gmail.com wrote:

 Validateur is a functional validations library inspired by Ruby's
 ActiveModel.

 Release notes for 1.4:

 http://blog.clojurewerkz.org/blog/2013/03/12/validateur-1-dot-4-0-is-released/

 1. http://clojurevalidations.info
 --
 MK

 http://github.com/michaelklishin
 http://twitter.com/michaelklishin

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Java interop with dynamic proxies

2013-03-12 Thread Jonathan Fischer Friberg
I think you can simply use 'Fred' instead of 'Fred.class'.

Since, in the repl:

(class Integer)
;= java.lang.Class

I.e. just by using the name, we get a Class object, which should correspond
to .class in java.
In other words, you should be able to run:

(let [f (Factory/createInstance)
  fred (.create f Fred)]
  (.setName fred Fred))

Might be wrong though. :)

Jonathan


On Wed, Mar 13, 2013 at 12:08 AM, Brian Goslinga
brian.gosli...@gmail.comwrote:

 Do you want to know how to define Fred, or how to translate the above code
 snippet?

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: doing a Google search from Clojure?

2013-03-22 Thread Jonathan Fischer Friberg
Found some info here:

http://stackoverflow.com/questions/3727662/how-can-you-search-google-programmatically-java-api

Jonathan


On Fri, Mar 22, 2013 at 8:32 AM, Cedric Greevey cgree...@gmail.com wrote:

 Change your code to it spoofs a common browser user-agent, change your
 DHCP-assigned IP address, and try again. They're probably trying to
 obstruct bots from making overwhelming numbers of requests or something. As
 long as you don't flood them with requests at a higher rate than a human
 would generate by clicking, I don't see any ethical issue with
 circumventing their countermeasures, especially not if the search will be
 triggered by a user input to your application anyway.


 On Fri, Mar 22, 2013 at 3:09 AM, Rich Morin r...@cfcl.com wrote:

 I've been successfully using slurp and laser to harvest and pull
 apart some web pages.  However, I can't figure out how to use
 Google Search from my code.

 My first thought was to use the Google Search API, but after
 a lot of frustration in trying to get and use an API key, I
 gave up on that.

 My next thought was to slurp in a page from the interactive
 Google Search facility, using the URL from Advanced Search:

   http://www.google.com/search?hl=enas_q=...;

 However, this gives me a 403 nastygram:

   IOException Server returned HTTP response code: 403 for URL:
   https://www.google.com/search?hl=enas_q=as_epq=...
   sun.net.www.protocol.http.HttpURLConnection.getInputStream
   (HttpURLConnection.java:1436)

 Has anyone here, by chance, been able to do this sort of thing?

 -r

  --
 http://www.cfcl.com/rdmRich Morin
 http://www.cfcl.com/rdm/resume r...@cfcl.com
 http://www.cfcl.com/rdm/weblog +1 650-873-7841

 Software system design, development, and documentation


 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: a bug?

2013-03-27 Thread Jonathan Fischer Friberg
The problem is probably too much nested laziness.

Try:
(reduce (fn [a b] (doall (map + [1 1] a))) [1 1] (range 1500))

Related:
https://groups.google.com/d/msg/clojure/-d8m7ooa4c8/pmaO7QubhosJ

Jonathan



On Wed, Mar 27, 2013 at 8:48 PM, Michael Klishin 
michael.s.klis...@gmail.com wrote:


 2013/3/27 larry google groups lawrencecloj...@gmail.com

 The error says the type is clojure.lang.PersistentVector and not lazyseq


 The error says it is clojure.lang.PersistentVector$ChunkedSeq. You can
 learn
 more about what chunking is for in
 http://clojure-doc.org/articles/language/laziness.html.

 Something in this code holds on to the seq's head.
 --
 MK

 http://github.com/michaelklishin
 http://twitter.com/michaelklishin

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: a bug?

2013-03-27 Thread Jonathan Fischer Friberg
I don't think it's fixed in 1.5.1.

In both 1.5.0 and 1.5.1, (range 1500) is not enough to cause
the overflow for me. However, (range 2000) successfully
overflows in both versions.

Jonathan


On Wed, Mar 27, 2013 at 8:53 PM, Timothy Baldridge tbaldri...@gmail.comwrote:

 Holding on to the head would result in a out of memory error, not a stack
 overflow. IIRC this was a bug that was fixed in 1.5 (I'll try to find the
 JIRA ticket). Anyways, it works in 1.5.1:

 user= (clojure-version)
 1.5.1
 user= (reduce (fn [a b] (map + [1 1] a)) [1 1] (range 1500))
 (1501 1501)
 user=


 On Wed, Mar 27, 2013 at 1:48 PM, Michael Klishin 
 michael.s.klis...@gmail.com wrote:


 2013/3/27 larry google groups lawrencecloj...@gmail.com

 The error says the type is clojure.lang.PersistentVector and not lazyseq


 The error says it is clojure.lang.PersistentVector$ChunkedSeq. You can
 learn
 more about what chunking is for in
 http://clojure-doc.org/articles/language/laziness.html.

 Something in this code holds on to the seq's head.
 --
 MK

 http://github.com/michaelklishin
 http://twitter.com/michaelklishin

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 “One of the main causes of the fall of the Roman Empire was that–lacking
 zero–they had no way to indicate successful termination of their C
 programs.”
 (Robert Firth)

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
It's because the #() syntax always calls the content as a function.

So #(...) is the same as (fn [] (...)). In your case,
#({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})
is the same as:
(fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}))
Note the extra () around {}. In other words, your map is called
as a function.

Maps can normally be called as functions, like this:
({:hello :world} :hello)
= :world
That's why you get the Wrong number of args error
(and not a a map is not a function error).
Hope that makes sense.

Btw, hyphen is normally used instead of underscore
in both variables and keywords. Just a slight style
issue, but maybe you had your reasons. :)

Jonathan


On Thu, Mar 28, 2013 at 10:16 PM, Ryan arekand...@gmail.com wrote:

 Hello!

 I am having a small issue with a hash-map initialization and I am failing
 to understand why. I have the following situation:

 (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value}))


 (defn my-function [foo-id a-keyword a-list]

   (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list))


 So, by running the above function like this:

 (my-function 5 my_keyword a-list)


 I get the following error:

 *clojure.lang.ArityException: Wrong number of args (0) passed to:
 PersistentArrayMap*


 I am trying to get the following result:

 ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword another-value})

 Any ideas? I have played around in repl for the last 2 hrs but I haven't
 found the proper way to do this.

 Thank you for your time :)

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
It can still be done with the #(), with for example the hash-map function.
It's basically the same as the {} but as a function, like this:
(hash-map :a 3 :b 4)
= {:a 3, :b 4}

So you should be able to write the function as:
#(hash-map :foo_id foo-id (keyword a-keyword) (:BAR_KEY %))

I think you should use the standard (fn []) syntax though, since it's
shorter.

 Hyphens is my preferred way as well, but, those keys represent sql
columns which they use underscore so I gotta go with underscores in order
code to match them :)
I see. :)

Jonathan


On Thu, Mar 28, 2013 at 10:51 PM, Ryan arekand...@gmail.com wrote:

 Thanks for your explanation Jonathan. I am still a bit confused however
 what is the proper solution here. Should i use an anonymous function
 instead to do what I want or can it be done with the #() syntax?

 Hyphens is my preferred way as well, but, those keys represent sql columns
 which they use underscore so I gotta go with underscores in order code to
 match them :)

 Ryan

 On Thursday, March 28, 2013 11:24:38 PM UTC+2, Jonathan Fischer Friberg
 wrote:

 It's because the #() syntax always calls the content as a function.

 So #(...) is the same as (fn [] (...)). In your case,
 #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})
 is the same as:
 (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}))
 Note the extra () around {}. In other words, your map is called
 as a function.

 Maps can normally be called as functions, like this:
 ({:hello :world} :hello)
 = :world
 That's why you get the Wrong number of args error
 (and not a a map is not a function error).
 Hope that makes sense.

 Btw, hyphen is normally used instead of underscore
 in both variables and keywords. Just a slight style
 issue, but maybe you had your reasons. :)

 Jonathan


 On Thu, Mar 28, 2013 at 10:16 PM, Ryan areka...@gmail.com wrote:

 Hello!

 I am having a small issue with a hash-map initialization and I am
 failing to understand why. I have the following situation:

 (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value}))


 (defn my-function [foo-id a-keyword a-list]

   (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list))


 So, by running the above function like this:

 (my-function 5 my_keyword a-list)


 I get the following error:

 *clojure.lang.ArityException: Wrong number of args (0) passed to:
 PersistentArrayMap*


 I am trying to get the following result:

 ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword
 another-value})

 Any ideas? I have played around in repl for the last 2 hrs but I haven't
 found the proper way to do this.

 Thank you for your time :)

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: hash-map initialization issue

2013-03-28 Thread Jonathan Fischer Friberg
No problem, glad to be of help. :)

Jonathan



On Thu, Mar 28, 2013 at 11:19 PM, Ryan arekand...@gmail.com wrote:

 Thanks for all your help Jonathan :) I went with the standard fn syntax,
 its a two-liner anyway so not a big of deal :)
 The important part here was that I learned that #() executes the content
 as a function, very helpful!

 Ryan


 On Friday, March 29, 2013 12:08:04 AM UTC+2, Jonathan Fischer Friberg
 wrote:

 It can still be done with the #(), with for example the hash-map function.
 It's basically the same as the {} but as a function, like this:
 (hash-map :a 3 :b 4)
 = {:a 3, :b 4}

 So you should be able to write the function as:
 #(hash-map :foo_id foo-id (keyword a-keyword) (:BAR_KEY %))

 I think you should use the standard (fn []) syntax though, since it's
 shorter.

  Hyphens is my preferred way as well, but, those keys represent sql
 columns which they use underscore so I gotta go with underscores in order
 code to match them :)
 I see. :)

 Jonathan


 On Thu, Mar 28, 2013 at 10:51 PM, Ryan areka...@gmail.com wrote:

 Thanks for your explanation Jonathan. I am still a bit confused however
 what is the proper solution here. Should i use an anonymous function
 instead to do what I want or can it be done with the #() syntax?

 Hyphens is my preferred way as well, but, those keys represent sql
 columns which they use underscore so I gotta go with underscores in order
 code to match them :)

 Ryan

 On Thursday, March 28, 2013 11:24:38 PM UTC+2, Jonathan Fischer Friberg
 wrote:

 It's because the #() syntax always calls the content as a function.

 So #(...) is the same as (fn [] (...)). In your case,
 #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)})
 is the same as:
 (fn [%] ({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}))
 Note the extra () around {}. In other words, your map is called
 as a function.

 Maps can normally be called as functions, like this:
 ({:hello :world} :hello)
 = :world
 That's why you get the Wrong number of args error
 (and not a a map is not a function error).
 Hope that makes sense.

 Btw, hyphen is normally used instead of underscore
 in both variables and keywords. Just a slight style
 issue, but maybe you had your reasons. :)

 Jonathan


 On Thu, Mar 28, 2013 at 10:16 PM, Ryan areka...@gmail.com wrote:

 Hello!

 I am having a small issue with a hash-map initialization and I am
 failing to understand why. I have the following situation:

 (def a-list '({:BAR_KEY bar-value}, {:BAR_KEY another-value}))


 (defn my-function [foo-id a-keyword a-list]

   (map #({:foo_id foo-id (keyword a-keyword) (:BAR_KEY %)}) a-list))


 So, by running the above function like this:

 (my-function 5 my_keyword a-list)


 I get the following error:

 *clojure.lang.ArityException: Wrong number of args (0) passed to:
 PersistentArrayMap*


 I am trying to get the following result:

 ({:foo_id 5 :my_keyword bar-value}, {:foo_id 5 :my_keyword
 another-value})

 Any ideas? I have played around in repl for the last 2 hrs but I
 haven't found the proper way to do this.

 Thank you for your time :)

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group**/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**grou**ps/opt_outhttps://groups.google.com/groups/opt_out
 .




  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+u...@**googlegroups.com.
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --
 --
 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

Re: Analog to Scheme's partition in Clojure?

2013-04-04 Thread Jonathan Fischer Friberg
I think group-by can do what you want (and more);

http://clojuredocs.org/clojure_core/clojure.core/group-by

Jonathan


On Thu, Apr 4, 2013 at 2:16 PM, Christian Romney xmlb...@gmail.com wrote:

 Hi all,

 I was wondering if something in core (or new contrib) like this exists
 already...

 (defn segregate
   Takes a predicate, p, and a collection, coll, and separates the items in 
 coll
into matching and non-matching subsets. Like Scheme or Ruby's partition.
   [p coll]
   (loop [s coll y [] n []]
 (if (empty? s) [y n]
   (if (p (first s))
 (recur (rest s) (conj y (first s)) n)
 (recur (rest s) y (conj n (first s)))


 (let [[odds evens] (segregate odd? (range 1 11))]
   (println evens))

 In Scheme (and Ruby) this function is partition, which is quite different 
 from /partition(-all|-by)?/ in Clojure:

 #lang racket

 (let-values [[(odds evens) (partition odd? (range 1 11))]]
   (display evens))

 If not, I have two follow-up questions.

 1) Is there a better way to write segregate
 2) Is this useful enough to consider adding to core?

 TIA, and my apologies for the newbie question. :)

 (Gist version if you prefer: https://gist.github.com/xmlblog/5309853)

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Memoization in clojure

2013-04-14 Thread Jonathan Fischer Friberg

 (letfn [(fib [x]
   (memoize
 #(if (or (zero? %) (= % 1))
1
(+ (fib (- % 1)) (fib (- % 2))]
   (time (fib 30))
   (time (fib 30))
   (time (fib 40))
   (time (fib 40)))


Calling fib just creates a new function, no values
are calculated. So you're measuring the time
it takes to create a function, and not the calculation
of fibonacci numbers.

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Memoization in clojure

2013-04-14 Thread Jonathan Fischer Friberg

 Oops ;)
 Of course you are right. The amazing thing is that the times I observed
 fitted somehow the situation (the first (fib 30) call taking much more time
 than the others, the third call more than the second and fourth) that I was
 tricked into believing the calculations were being done and wasn't careful
 enough ...


Hmm, my guess would be that the jvm is optimising the
code. Most things run slower the first time. That doesn't
explain the third run though, although it could have been
a coincidence. It was indeed very tricky. :)

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Jonathan Fischer Friberg
If that's a problem, you could try https://github.com/hugoduncan/criterium


On Thu, Apr 25, 2013 at 5:38 PM, Phil Hagelberg p...@hagelb.org wrote:

 Three repetitions is not nearly enough to get a feel for how hotspot
 optimizes functions when it detects they're in a tight loop. I don't know
 how javac works, but Clojure doesn't optimize much for cases where hotspot
 can do a much better job over time.

 -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
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: cannot read foo.xml from the top level of a jar!

2013-04-26 Thread Jonathan Fischer Friberg
Did you put / at the beginning of the string to resource? Because you
shouldn't.

You should call it like this: (resource foo.xml).

Jonathan


On Fri, Apr 26, 2013 at 8:47 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

 Hello everyone,

 I hope you're all doing well...

 Can anyone enlighten my as to why I cannot read anything from the top
 directory of a jar? The jar in question is on the classpath and the foo.xml
 file is located  at the top directory...tries clojure.java.io/resourcetried 
 .getResourceAsStream from the classloader + the Class object...

 any ideas?

 thanks,
 Jim

 --
 --
 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 --- You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to 
 clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Now *there*'s a machine made for Clojure.

2013-04-29 Thread Jonathan Fischer Friberg
You could always give https://github.com/halgari/clojure-py a spin, might
not be so easy to get everything working though. :)

Jonathan




On Mon, Apr 29, 2013 at 2:48 PM, Lee Spector lspec...@hampshire.edu wrote:


 On Apr 29, 2013, at 8:15 AM, Michiel Overtoom wrote:
  On Apr 28, 2013, at 05:36, Lee Spector wrote:
 
  our experience running Clojure on 48-core machines was pretty
 depressing, with our speedups often being near zero or even negative
 
  Did you also do a test on that hardware with Python w/ multiprocessing?

 No, we didn't try Python or any other language. Our interest is in getting
 multicore speedups in Clojure or possibly in some other Lisp (although with
 our current code base it'd be best if we could do this in Clojure).

  -Lee

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: testing for nil may not be enough

2013-04-29 Thread Jonathan Fischer Friberg
If you don't want to set the initial value to nil, set it to ::unbound or
similar. Should be very
hard to accidentally bind the same value.

Jonathan


On Mon, Apr 29, 2013 at 8:04 PM, AtKaaZ atk...@gmail.com wrote:

 the pain with that is that it wouldn't work inside a function where a
 would be the function parameter, ok it would work in a macro but inside a
 function... that would be interesting to see


 On Mon, Apr 29, 2013 at 9:01 PM, Sean Corfield seancorfi...@gmail.comwrote:

 Try this:

 user= (def a)
 #'user/a
 user= (bound? (var a))
 false
 user= (def a nil)
 #'user/a
 user= (bound? (var a))
 true

 Sean

 On Mon, Apr 29, 2013 at 8:32 AM, AtKaaZ atk...@gmail.com wrote:
  How do you guys handle the cases when the var is unbound? I mean
  specifically in the cases where you just test if the var is nil.
 
  = (def a)
  #'clojurewerkz.titanium.graph-test/a
 
  = a
  #Unbound Unbound: #'clojurewerkz.titanium.graph-test/a
 
  = (nil? a)
  false
 
  = (bound? a)
  ClassCastException clojure.lang.Var$Unbound cannot be cast to
  clojure.lang.Var  clojure.core/bound?/fn--4837 (core.clj:4954)
 
  = (bound? #'a)
  false
 
  ok imagine the following sample :))
 
  = (defn decorate [input]
   (when (not (nil? input)) (str prefix: input :suffix)))
  #'clojurewerkz.titanium.graph-test/decorate
 
  = (decorate 1)
  prefix:1:suffix
 
  = (decorate a)
  prefix:Unbound: #'clojurewerkz.titanium.graph-test/a:suffix
 
  so... fix?
   but more importantly does anyone need to add checks for
 is-the-var-bound in
  their code where they checked for nil ?
 
  --
  --
  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 unsubscribe from this group and stop receiving emails from it, send
 an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 



 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Using a Java game engine in my project

2013-04-29 Thread Jonathan Fischer Friberg
I'm currently making a library for jmonkeyengine. It's not
ready yet, however, a while back I decided to put jme in a repository.

Url: http://jmonkeyengine.s3-website-eu-west-1.amazonaws.com/;
Add to deps: [jme 2013-04-01]

The biggest problem with it right now is that it contains all test models
and textures, which I didn't realise at the time (this accounts for more
than half of the size). But it's quick  easy if you want to give it a go.

Jonathan



On Mon, Apr 29, 2013 at 9:56 PM, AtKaaZ atk...@gmail.com wrote:

 That's awesome!  Thanks James!


 On Mon, Apr 29, 2013 at 10:46 PM, James Reeves ja...@booleanknot.comwrote:

 I've been messing around with jME3 as well, and at some point I might
 release a library for it.

 One of the problems with jME3 is that its deployment mechanism hasn't
 quite caught up with the current century. I'm planning on packaging it up
 eventually, but in the meantime here's the ugly, dirty, terrible hack I've
 been using:

 1. Download the binaries:
 http://www.jmonkeyengine.com/nightly/jME3_2013-04-29.zip
 2. Create a new directory and extract the zip file into it
 3. Create a new Leiningen project
 4. Add the following to your project.clj file: :resource-paths [lib/*]
 5. Copy the lib directory from the jME3 binaries into your project
 directory

 Here's an example application to get you going:

 https://gist.github.com/weavejester/5484183

 - James


 On 29 April 2013 20:02, Alex Fowler alex.murat...@gmail.com wrote:

 Hello! I have a problem, I will try to explain.. I want to write a game
 with Clojure and JMonkeyEngine (http://jmonkeyengine.com/). So I take
 their latest nightie set of jars (http://jmonkeyengine.com/nightly/)
 and what? I can't make use of them in my CCW/Leiningen project no
 matter how hard I try. So ok, I have found some examples where people get
 them in the lib folder and it works, or where they recommend pushing them
 to the local maven repo... but they do not tell how they do it, or they
 show it for some very simple cases. Sure, there is a lot of instructions
 like use mvn install:install-file a-lot-of-stuff-goes-here or lein
 localrepo install less-stuff-but-hey... so do I have to do it for all
 the 30 (thirty) jar files? Considering too, that I have to invent an
 artifactId for every one of them, invent a version number, type all
 that in manually. And that is not my library, I do not want to invent that.
 And even, if I do that, then, how do I specify that all them are
 interdependant (are parts of one thing) and have to be always drawn in
 together? I will have to specify the 30 dependencies in my project.clj each
 time? Well, and even if I do, then I will still have that pain with
 manually copying all that stuff on each new machine where I work, picking
 it from the local maven repo and putting it to another maven repo. And
 if I want to push it to Clojars, I have do that for each one manually too,
 typing in commands in the Windows cmd and taking care for inventing version
 numbers?... oh, and maybe I could go about specifying dependency clauses
 in a pom? pinch me am I dreaming a nightmare? :)

 I have tried to do something along these lines... spent about 15 hours
 in general and got almost nothing but headache and eyesore... and a feeling
 of being extremily stupid for not being able to plug a few jars into a jvm
 program (isn't java all just about putting jars together? :) ). I am a
 Clojure newb and maybe I am missing somewhat essential.. but in Scala, with
 or without SBT, using Scala IDE for Eclipse, I got everything up and
 running in about 15 minutes.

 Please, could anyone give me a clear explanation or better, a full
 example of plugging in the JME3 into a Clojure project? Shouldn't it be
 simple? Thank you in advance, the situation is really disappointing for me
 :(

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 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 

Re: Now *there*'s a machine made for Clojure.

2013-04-29 Thread Jonathan Fischer Friberg
On Mon, Apr 29, 2013 at 5:25 PM, Konrad Hinsen 
googlegro...@khinsen.fastmail.net wrote:

 --On 29 avril 2013 09:09:27 -0400 Lee Spector lspec...@hampshire.edu
 wrote:

  On Apr 29, 2013, at 9:01 AM, Jonathan Fischer Friberg wrote:

  You could always give 
 https://github.com/halgari/**clojure-pyhttps://github.com/halgari/clojure-pya
  spin,
 might not be so easy to get everything working though. :)


 It might be worth it, if we could still write in Clojure and get good
 multicore utilization and good performance overall for our application.

 Is there evidence that code written/run this way will perform
 particularly well?


 No. The Python VM has a global interpreter lock that prevents parallel
 execution of Python bytecode. If you want to parallel processing in Python
 (more precisely, the CPython implementation), you must either port
 CPU-intensive stuff to C or Cython, or run multiple communicating CPython
 instances.

 Konrad.


clojure-py code should run on pypy, which is much more promising;
http://pypy.org/
The support for http://www.stackless.com/ is especially interesting.

Jonathan

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Now *there*'s a machine made for Clojure.

2013-04-29 Thread Jonathan Fischer Friberg
Reading about this, yes, but there is hope:

http://morepypy.blogspot.se/2012/08/multicore-programming-in-pypy-and.html

Jonathan


On Mon, Apr 29, 2013 at 10:45 PM, Timothy Baldridge tbaldri...@gmail.comwrote:

 But as Konrad pointed out, the python VM (and the pypy vm) offers nothing
 that JVMs don't support better. Everything from concurrency to the GC is
 implemented better in the JVM.

 Timothy


 On Mon, Apr 29, 2013 at 2:41 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 On Mon, Apr 29, 2013 at 5:25 PM, Konrad Hinsen 
 googlegro...@khinsen.fastmail.net wrote:

 --On 29 avril 2013 09:09:27 -0400 Lee Spector lspec...@hampshire.edu
 wrote:

  On Apr 29, 2013, at 9:01 AM, Jonathan Fischer Friberg wrote:

  You could always give 
 https://github.com/halgari/**clojure-pyhttps://github.com/halgari/clojure-pya
  spin,
 might not be so easy to get everything working though. :)


 It might be worth it, if we could still write in Clojure and get good
 multicore utilization and good performance overall for our application.

 Is there evidence that code written/run this way will perform
 particularly well?


 No. The Python VM has a global interpreter lock that prevents parallel
 execution of Python bytecode. If you want to parallel processing in Python
 (more precisely, the CPython implementation), you must either port
 CPU-intensive stuff to C or Cython, or run multiple communicating CPython
 instances.

 Konrad.


 clojure-py code should run on pypy, which is much more promising;
 http://pypy.org/
 The support for http://www.stackless.com/ is especially interesting.

 Jonathan

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 “One of the main causes of the fall of the Roman Empire was that–lacking
 zero–they had no way to indicate successful termination of their C
 programs.”
 (Robert Firth)

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Using a Java game engine in my project

2013-04-30 Thread Jonathan Fischer Friberg

 I think that for today I will stick with the lib folder solution,
 proposed by James, but I encourage the knowledgefull people Jonathan and
 James to work together to deliver a Clojars or Amazonaws online repository
 with more-or-less daily update, since the engine is really well-maintained.
 And a Clojure wrapper? I also think that there is no need to strip away the
 testdata since it contains many materials and shaders good for prototyping
 or prodution.


I think the best solution would be to separate it, that's
my plan. That is, to have jme with only the core, and
jme-extra or similar, with the extra goodies.

Jonathan

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: A JMonkeyEngine3 wrapper?

2013-05-01 Thread Jonathan Fischer Friberg
My effort can be found here:
https://github.com/odyssomay/orbit

It's kind of all over the place in that I have started on a lot of
things, but not really
finished any parts. In any case, should be some useful stuff in there.

I haven't really been active on the project lately - there's a bunch of
other things I'd
like to finish first. But I intend to finish the library in the near
future.

I renamed the library today which might cause some trouble - just a heads
up.

Jonathan


On Wed, May 1, 2013 at 10:08 PM, Alex Fowler alex.murat...@gmail.comwrote:

 So, inspired by the latest talks with locals, I propose starting a
 collective initiative on creating a full-scale wrapper for JME3.

 Actually, I am starting to write my Clojure project with JME3 and I feel
 like in a desperate need for a clojuric wrapper. So I started implementing
 wrappers for Material, Texture, Geometry and so on.. but I think that that
 code would be rather universal and there is no point for it to belong to a
 personal project. So I think that we might start a community library
 project on this with those who is interested. Besides that, I think that I
 am a rather newb in Clojure and if I do that on my own, I will not do it as
 good as possible :D Is somebody interested in that?

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: A JMonkeyEngine3 wrapper?

2013-05-01 Thread Jonathan Fischer Friberg
Some info about the current status:

* Input handling - missing joystick (not that important I guess).
* Networking - completely done (might be improved, but works for most
purposes).
* Physics - not started.
* Materials - usable, but needs work.
* Geometry - same as material.
* Application + settings - mostly done.
* UI - mostly done. Most notably missing click handlers.

I have also tried to make an enlive-style system for creating user
interfaces and 3d geometry. The ui part is
done, but the geometry part is missing.

I might have missed something. Just ask if you'd like to know more.

Jonathan


On Wed, May 1, 2013 at 11:20 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 My effort can be found here:
 https://github.com/odyssomay/orbit

 It's kind of all over the place in that I have started on a lot of
 things, but not really
 finished any parts. In any case, should be some useful stuff in there.

 I haven't really been active on the project lately - there's a bunch of
 other things I'd
 like to finish first. But I intend to finish the library in the near
 future.

 I renamed the library today which might cause some trouble - just a heads
 up.

 Jonathan


 On Wed, May 1, 2013 at 10:08 PM, Alex Fowler alex.murat...@gmail.comwrote:

 So, inspired by the latest talks with locals, I propose starting a
 collective initiative on creating a full-scale wrapper for JME3.

 Actually, I am starting to write my Clojure project with JME3 and I feel
 like in a desperate need for a clojuric wrapper. So I started implementing
 wrappers for Material, Texture, Geometry and so on.. but I think that that
 code would be rather universal and there is no point for it to belong to a
 personal project. So I think that we might start a community library
 project on this with those who is interested. Besides that, I think that I
 am a rather newb in Clojure and if I do that on my own, I will not do it as
 good as possible :D Is somebody interested in that?

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: A JMonkeyEngine3 wrapper?

2013-05-01 Thread Jonathan Fischer Friberg
UI example:
https://github.com/odyssomay/orbit/blob/master/test/orbit/test/ui.clj#L45

Sorry for the spam. :)

Jonathan


On Wed, May 1, 2013 at 11:28 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 Some info about the current status:

 * Input handling - missing joystick (not that important I guess).
 * Networking - completely done (might be improved, but works for most
 purposes).
 * Physics - not started.
 * Materials - usable, but needs work.
 * Geometry - same as material.
 * Application + settings - mostly done.
 * UI - mostly done. Most notably missing click handlers.

 I have also tried to make an enlive-style system for creating user
 interfaces and 3d geometry. The ui part is
 done, but the geometry part is missing.

 I might have missed something. Just ask if you'd like to know more.

 Jonathan


 On Wed, May 1, 2013 at 11:20 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 My effort can be found here:
 https://github.com/odyssomay/orbit

 It's kind of all over the place in that I have started on a lot of
 things, but not really
 finished any parts. In any case, should be some useful stuff in there.

 I haven't really been active on the project lately - there's a bunch of
 other things I'd
 like to finish first. But I intend to finish the library in the near
 future.

 I renamed the library today which might cause some trouble - just a heads
 up.

 Jonathan


 On Wed, May 1, 2013 at 10:08 PM, Alex Fowler alex.murat...@gmail.comwrote:

 So, inspired by the latest talks with locals, I propose starting a
 collective initiative on creating a full-scale wrapper for JME3.

 Actually, I am starting to write my Clojure project with JME3 and I feel
 like in a desperate need for a clojuric wrapper. So I started implementing
 wrappers for Material, Texture, Geometry and so on.. but I think that that
 code would be rather universal and there is no point for it to belong to a
 personal project. So I think that we might start a community library
 project on this with those who is interested. Besides that, I think that I
 am a rather newb in Clojure and if I do that on my own, I will not do it as
 good as possible :D Is somebody interested in that?

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.







-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: idiomatic way to force evaluation of a lazy operation

2013-05-04 Thread Jonathan Fischer Friberg
If you don't need the result, you should use dorun instead of doall.
http://clojuredocs.org/clojure_core/clojure.core/dorun

Jonathan


On Sat, May 4, 2013 at 8:07 PM, Gary Verhaegen gary.verhae...@gmail.comwrote:

 Just want to point out that doall seeming more idiomatic in this case
 might just be an accident of history - mapv is a relatively new
 addition to Clojure (1.4). At least to me, it is immediately obvious
 that a mapv is intentionally non lazy.

 On 4 May 2013 12:07, Timo Mihaljov t...@mihaljov.info wrote:
  On 04.05.2013 13:01, Korny Sietsma wrote:
  Thanks - I thought doall was probably better than mapv.
 
  Incidentally, doseq won't work - if the 5th result throws an exception
  during parsing, results 1-4 will still be saved, whereas I want the
  whole operation to abort without saving anything.
 
  Ah right, I didn't think of that. I'd still go with `doseq` for the
  saving (otherwise you'll build up a result collection just to throw it
  away), just wrap the first `map parse-record` in a `doall`.
 
  --
  Timo
 
  --
  --
  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 unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [ANN] bleach 0.0.11

2013-05-04 Thread Jonathan Fischer Friberg
You could try reading about it here:
http://search.cpan.org/~dconway/Acme-Bleach-1.150/lib/Acme/Bleach.pm

I still can't figure out exactly what it does though...
Reading the description, it seems like it removes, for example
whitespace at the end of lines. But from the example it seems
like it removes print statements. :S

Jonathan


On Sat, May 4, 2013 at 8:26 PM, Gary Verhaegen gary.verhae...@gmail.comwrote:

 Without looking at more than the Readme on github, I guess it's kind
 of like a compiler to whitespace. You know, the whitespace programming
 language :
 http://en.wikipedia.org/wiki/Whitespace_(programming_language)

 like implemented as a user defined type with the #bleach/ed type.

 On 4 May 2013 19:51, AtKaaZ atk...@gmail.com wrote:
  could you post a sample code how it looks before and after?
 
 
  On Thu, May 2, 2013 at 7:36 AM, David Lowe j.david.l...@gmail.com
 wrote:
 
  bleach: whitens unsightly code!
 
  When you bleach your code, it continues to work as before, only now it
  looks like:
 
  (use 'bleach.core) #bleach/ed 
 
 
 
 
  
 
  Find it here: https://github.com/dlowe/bleach
 
  Enjoy :)
  David Lowe
 
  --
  --
  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 unsubscribe from this group and stop receiving emails from it, send
 an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 
  --
  --
  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 unsubscribe from this group and stop receiving emails from it, send an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Using a Java game engine in my project

2013-05-05 Thread Jonathan Fischer Friberg
That sounds scary. :)

I haven't experienced any of the sort. Tested in both linux 64-bit and
windoze 32-bit.

The problem likely stems from the way jme loads the native libraries. As
far as I know
they do it manually by extracting the libraries and then setting some
sort of path. It
should be automatic for the users of the library however.

Jonathan



On Sun, May 5, 2013 at 6:24 PM, James Ashley james.ash...@gmail.com wrote:

 I don't have much to contribute here, just some vague observations pulled
 out of distant memories. So this is fuzzy, and I apologize for that.

 I started working on this same sort of thing, sometime late last year.
 Setting up a basic project using jME in clojure worked fine under 64-bit
 Windows. Trying the same in 64-bit linux failed, because it kept trying to
 use the 32-bit native shared library. I've been meaning to go back to try
 renaming the 64-bit library, but I haven't found the time to find the
 project since I got distracted.

 The one suggestion I got about the problem on stackoverflow was from a
 Java guy with no experience in clojure. IIRC, he suggested that I needed to
 specify something in the :native-dependencies in project.clj. That sounded
 wrong at the time, since I specifically mentioned that I was using lein2.
 But I barely qualify as a clojure programmer, and I'm definitely out of
 my league (for now) when it comes to things like java and maven.

 I got distracted back then, and I haven't had any time since to try to
 figure out what's going on.

 FWIW, using the jME version of netbeans worked fine on my linux box.

 I've asked a couple of Java gurus about it, and they didn't have any
 suggestions.

 This may be totally obsolete information that isn't relevant anymore. But
 I think this is an extremely interesting project, and it seems worth
 mentioning. As vague and useless as it probably is.

 I didn't want to clutter the main mailing list with the details back then,
 because I wanted to try to track down whether the problem was something in
 my lein setup, some weird configuration in the way jME packages their jars,
 or simply my lack of knowledge about the way java resolves native library
 dependencies. I still don't, so it seems worth at least tentatively
 suggesting a mailing list for this sort of conversation (maybe something
 about clojure 3d graphics?). I won't have much time for it in the near
 future, but I'd be more than happy to contribute what I'm able.

 Then again, I probably should have started asking here in the first place.

 However it works, I definitely wish good luck!

 Regards,
 James


 On Monday, April 29, 2013 2:02:16 PM UTC-5, Alex Fowler wrote:

 Hello! I have a problem, I will try to explain.. I want to write a game
 with Clojure and JMonkeyEngine (http://jmonkeyengine.com/). So I take
 their latest nightie set of jars 
 (http://jmonkeyengine.com/**nightly/http://jmonkeyengine.com/nightly/)
 and what? I can't make use of them in my CCW/Leiningen project no
 matter how hard I try. So ok, I have found some examples where people get
 them in the lib folder and it works, or where they recommend pushing them
 to the local maven repo... but they do not tell how they do it, or they
 show it for some very simple cases. Sure, there is a lot of instructions
 like use mvn install:install-file a-lot-of-stuff-goes-here or lein
 localrepo install less-stuff-but-hey... so do I have to do it for all
 the 30 (thirty) jar files? Considering too, that I have to invent an
 artifactId for every one of them, invent a version number, type all
 that in manually. And that is not my library, I do not want to invent that.
 And even, if I do that, then, how do I specify that all them are
 interdependant (are parts of one thing) and have to be always drawn in
 together? I will have to specify the 30 dependencies in my project.clj each
 time? Well, and even if I do, then I will still have that pain with
 manually copying all that stuff on each new machine where I work, picking
 it from the local maven repo and putting it to another maven repo. And
 if I want to push it to Clojars, I have do that for each one manually too,
 typing in commands in the Windows cmd and taking care for inventing version
 numbers?... oh, and maybe I could go about specifying dependency clauses
 in a pom? pinch me am I dreaming a nightmare? :)

 I have tried to do something along these lines... spent about 15 hours in
 general and got almost nothing but headache and eyesore... and a feeling of
 being extremily stupid for not being able to plug a few jars into a jvm
 program (isn't java all just about putting jars together? :) ). I am a
 Clojure newb and maybe I am missing somewhat essential.. but in Scala, with
 or without SBT, using Scala IDE for Eclipse, I got everything up and
 running in about 15 minutes.

 Please, could anyone give me a clear explanation or better, a full
 example of plugging in the JME3 into a Clojure project? Shouldn't it be
 simple? Thank you in 

Re: Import java classes in clojure

2013-05-05 Thread Jonathan Fischer Friberg
(:import ...) only works in (ns ...). Outside ns, you have to use (import
...) instead (note: no :).

See:
http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html

Jonathan


On Mon, May 6, 2013 at 12:04 AM, Caocoa p.de.bois...@gmail.com wrote:

 Hi all! I'm  a new Clojure user. I'm trying to import some java classes in
 order to use them with overtone, but I fail :/ Would you help me?
 Thanks a lot in advance for your answer.

 Here is the bug:

 user= (:import [javax.constraints
   #_= Problem
   #_= ProblemFactory
   #_= Var
   #_= Solver
   #_= Objective
   #_= VarSet])
 CompilerException java.lang.RuntimeException:
 java.lang.ClassNotFoundException: javax.constraints,
 compiling:(NO_SOURCE_PATH:1)

 user= (:import [jm.music.data
   #_= Score
   #_= Part
   #_= Phrase
   #_= Note])
 CompilerException java.lang.RuntimeException:
 java.lang.ClassNotFoundException: jm.music.data,
 compiling:(NO_SOURCE_PATH:1)


 As a newbie, I have several questions:

- I've found jMusic here:
http://sourceforge.net/projects/jmusic/?source=dlp. I hope it's the
latest version. I've copied it in

/usr/lib/jvm/java-7-openjdk/jre/lib/ext

but I still can't invoke any jm.music.data classes. How could I
include it int the classpath. I thought that folder was already included.
- How can I download and properly install javax.constraints? I don't
even know where I can find that package.

 Some data about my system:

- uname -a gives me back:

Linux C40C04 3.8.11-1-ARCH #1 SMP PREEMPT Wed May 1 20:18:57 CEST
2013 x86_64 GNU/Linux

- When I look for jMusic or javax in package database with my package
manager (I use yaourt), I don't find anything.
- Here is what java packages I've already installed:

$ yaourt -Qs java
extra/apache-ant 1.9.0-1
A java-based build tool
extra/ca-certificates-java 20121112+nmu2-1
Common CA certificates (JKS keystore)
extra/eclipse 4.2.2-1
An IDE for Java and other languages
extra/gjs 1.36.1-1
Javascript Bindings for GNOME
local/hsqldb-java 1:1.8.0.10-2
HSQLDB Java libraries
extra/java-activation-gnu 1.1.1-1
JavaBeans Activation Framework (JAF), framework for declaring
what beans operate on what MIME type data
local/java-commons-email 1.2-1
Library for sending e-mail from Java.
extra/java-gnumail 1.1.2-1
GNU implementation of the JavaMail API specification, version 1.3
extra/jdk7-openjdk 7.u21_2.3.9-1
Free Java environment based on OpenJDK 7.0 with IcedTea7
replacing binary plugs - SDK
extra/jre7-openjdk 7.u21_2.3.9-1
Free Java environment based on OpenJDK 7.0 with IcedTea7
replacing binary plugs - Full Java runtime environment - needed for
executing Java GUI and Webstart programs
extra/jre7-openjdk-headless 7.u21_2.3.9-1
Free Java environment based on OpenJDK 7.0 with IcedTea7
replacing binary plugs - Minimal Java runtime - needed for executing non
GUI Java programs
community/netbeans 7.3-1
IDE for Java, HTML5, PHP, Groovy, C and C++$ yaourt -Qs java
extra/apache-ant 1.9.0-1
A java-based build tool
extra/ca-certificates-java 20121112+nmu2-1
Common CA certificates (JKS keystore)
extra/eclipse 4.2.2-1
An IDE for Java and other languages
extra/gjs 1.36.1-1
Javascript Bindings for GNOME
local/hsqldb-java 1:1.8.0.10-2
HSQLDB Java libraries
extra/java-activation-gnu 1.1.1-1
JavaBeans Activation Framework (JAF), framework for declaring
what beans operate on what MIME type data
local/java-commons-email 1.2-1
Library for sending e-mail from Java.
extra/java-gnumail 1.1.2-1
GNU implementation of the JavaMail API specification, version 1.3
extra/jdk7-openjdk 7.u21_2.3.9-1
Free Java environment based on OpenJDK 7.0 with IcedTea7
replacing binary plugs - SDK
extra/jre7-openjdk 7.u21_2.3.9-1
Free Java environment based on OpenJDK 7.0 with IcedTea7
replacing binary plugs - Full Java runtime environment - needed for
executing Java GUI and Webstart programs
extra/jre7-openjdk-headless 7.u21_2.3.9-1
Free Java environment based on OpenJDK 7.0 with IcedTea7
replacing binary plugs - Minimal Java runtime - needed for executing non
GUI Java programs
extra/js 17.0.0-1
JavaScript interpreter and libraries
extra/js185 1.0.0-2
JavaScript interpreter and libraries (legacy)
extra/libreoffice-common 4.0.2-3 (libreoffice)
common files for LibreOffice - a productivity suite that is
compatible with other major office suites
community/netbeans 7.3-1
IDE for Java, HTML5, PHP, Groovy, C and C++
local/saxon-he 9.4.0.7-2
XSLT 2.0 / XPath 2.0 / XQuery 1.0 processor for Java - Home
Edition

Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
I haven't used clojurescript in a while, but if I recall correctly, the
only way
to not compile everything into a single file is to leave out the
:optimization flag
completely. If this is the case this should probably be considered a bug. I
might
be wrong though.

Jonathan


On Tue, May 7, 2013 at 5:49 PM, David Nolen dnolen.li...@gmail.com wrote:

 I believe the ClojureScript compiler simply looks for all .cljs files on
 the specified compile path. I think maybe you could put your files in
 different directories so they don't all get concatenated together. You can
 one build specify one path, and another build specify both paths.

 Perhaps other people have better solutions?


 On Tue, May 7, 2013 at 11:26 AM, Timothy Washington twash...@gmail.comwrote:

 This is on a Clojurescript compilation note. I've noticed that if I have
 a *main.cljs* and *my-other.cljs*, parts of *my-other.cljs* will appear
 in *main.cljs*. Is there a way to avoid this? Using *lein-cljsbuild*,
 any of the :optimization flags, gives the same result (in terms of adding
 all to *main.cljs*). I'd like main.cljs to just be a bootstrap file, and
 separately include my other files. Then at production time, I can choose
 flip a switch to have all the files compiled down to one
  compressed main.cljs.

 Can I do this?


 Thanks
 Tim

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
From the sample.project.clj:

; Determines whether the temporary JavaScript files will be left in place
between
; automatic builds. Leaving them in place speeds up compilation because
things can
; be built incrementally. This probably shouldn't be disabled except for
troubleshooting.
; Defaults to true.
:incremental true


So it seems like you don't have to worry about it. :)
cljsbuild does it automatically.

Jonathan





On Tue, May 7, 2013 at 6:32 PM, David Nolen dnolen.li...@gmail.com wrote:

 This is why I suggested organizing the project around directories and
 specifying different groups of them with different lein-cljsbuild groups.


 On Tue, May 7, 2013 at 12:24 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I haven't used clojurescript in a while, but if I recall correctly, the
 only way
 to not compile everything into a single file is to leave out the
 :optimization flag
 completely. If this is the case this should probably be considered a bug.
 I might
 be wrong though.

 Jonathan


 On Tue, May 7, 2013 at 5:49 PM, David Nolen dnolen.li...@gmail.comwrote:

 I believe the ClojureScript compiler simply looks for all .cljs files on
 the specified compile path. I think maybe you could put your files in
 different directories so they don't all get concatenated together. You can
 one build specify one path, and another build specify both paths.

 Perhaps other people have better solutions?


 On Tue, May 7, 2013 at 11:26 AM, Timothy Washington 
 twash...@gmail.comwrote:

 This is on a Clojurescript compilation note. I've noticed that if I
 have a *main.cljs* and *my-other.cljs*, parts of *my-other.cljs* will
 appear in *main.cljs*. Is there a way to avoid this? Using *
 lein-cljsbuild*, any of the :optimization flags, gives the same result
 (in terms of adding all to *main.cljs*). I'd like main.cljs to just be
 a bootstrap file, and separately include my other files. Then at production
 time, I can choose flip a switch to have all the files compiled down to one
  compressed main.cljs.

 Can I do this?


 Thanks
 Tim

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed

Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
I tried it, and I think removing the :optimizations flag will do
what you want. The problem is that cljsbuild sets it to :whitespace
by default, so even if you remove it from your build it's still there.

To circumvent this, I opened lein-cljsbuild-0.3.0.jar in
~/.m2/repository/lein-cljsbuild/lein-cljsbuild/0.3.0/
In the jar, in the file leiningen/cljsbuild/config.clj I changed the
function

(defn- default-compiler-options [target-path]
  {:output-to (in-target-path target-path main.js)
   :optimizations :whitespace
   :warnings true
   :externs []
   :libs []
   :pretty-print true})

to

(defn- default-compiler-options [target-path]
  {:output-to (in-target-path target-path main.js)
   :warnings true
   :externs []
   :libs []
   :pretty-print true})

(just removing the :optimizations)

and put it back in the jar. Which had the effect which I think you
want, If I understand you correctly.

I hope these instructions are clear enough. :)

Jonathan



On Tue, May 7, 2013 at 10:06 PM, Timothy Washington twash...@gmail.comwrote:

 Hey Jonathan,

 Saw that flag, and it's useful. But what I want to do is separate my
 main.js from all my other.js files. I've a more detailed description
 abouve. Maybe I just can't do this, but I thought I'd ask around.


 Tim


 On Tue, May 7, 2013 at 4:03 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 From the sample.project.clj:

 ; Determines whether the temporary JavaScript files will be left in place
 between
 ; automatic builds. Leaving them in place speeds up compilation because
 things can
 ; be built incrementally. This probably shouldn't be disabled except for
 troubleshooting.
 ; Defaults to true.
 :incremental true


 So it seems like you don't have to worry about it. :)
 cljsbuild does it automatically.

 Jonathan


  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
*DON'T DO IT*

I just realised, if the :optimizations missing triggers this
behaviour, it should be possible to set it to nil, and it was!

So try ':optimizations nil' in your build.

Jonathan


On Tue, May 7, 2013 at 10:20 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 I tried it, and I think removing the :optimizations flag will do
 what you want. The problem is that cljsbuild sets it to :whitespace
 by default, so even if you remove it from your build it's still there.

 To circumvent this, I opened lein-cljsbuild-0.3.0.jar in
 ~/.m2/repository/lein-cljsbuild/lein-cljsbuild/0.3.0/
 In the jar, in the file leiningen/cljsbuild/config.clj I changed the
 function

 (defn- default-compiler-options [target-path]
   {:output-to (in-target-path target-path main.js)
:optimizations :whitespace
:warnings true
:externs []
:libs []
:pretty-print true})

 to

 (defn- default-compiler-options [target-path]
   {:output-to (in-target-path target-path main.js)
:warnings true
:externs []
:libs []
:pretty-print true})

 (just removing the :optimizations)

 and put it back in the jar. Which had the effect which I think you
 want, If I understand you correctly.

 I hope these instructions are clear enough. :)

 Jonathan



 On Tue, May 7, 2013 at 10:06 PM, Timothy Washington twash...@gmail.comwrote:

 Hey Jonathan,

 Saw that flag, and it's useful. But what I want to do is separate my
 main.js from all my other.js files. I've a more detailed description
 abouve. Maybe I just can't do this, but I thought I'd ask around.


 Tim


 On Tue, May 7, 2013 at 4:03 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 From the sample.project.clj:

 ; Determines whether the temporary JavaScript files will be left in
 place between
 ; automatic builds. Leaving them in place speeds up compilation because
 things can
 ; be built incrementally. This probably shouldn't be disabled except for
 troubleshooting.
 ; Defaults to true.
 :incremental true


 So it seems like you don't have to worry about it. :)
 cljsbuild does it automatically.

 Jonathan


  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Separating Out .cljs Content

2013-05-07 Thread Jonathan Fischer Friberg
You have to import the google closure library when compiling without
optimisation.

Given your build, probably something like this:

script type=text/javascript
src=public/javascript/goog/base.js/script

Just make sure the base.js file is actually there.

Jonathan



On Tue, May 7, 2013 at 10:54 PM, Timothy Washington twash...@gmail.comwrote:

 That's an interesting tweak. Indeed, I no longer have any of my contents
 in main.js. But I also get a JS error in my browser.


 goog.provide('edgar');
  Uncaught ReferenceError: goog is not defined
 goog.require('cljs.core');
 goog.require('shoreleave.remotes.http_rpc');
 goog.require('clojure.browser.repl');
 shoreleave.remotes.http_rpc.remote_callback.call(null,\uFDD0'heartbeat,
 cljs.core.PersistentVector.fromArray([heartbeat], true),(function (
 p1__2853_SHARP_){
 return alert(p1__2853_SHARP_);
 }));


 *my-file.js*

 Same thing happens in main.js

 goog.addDependency(base.js, ['goog'], []);
  Uncaught ReferenceError: goog is not defined
 goog.addDependency(../cljs/core.js, ['cljs.core'], ['goog.string',
 'goog.array', 'goog.object', 'goog.string.format',
 'goog.string.StringBuffer']);
 goog.addDependency(../clojure/browser/event.js, ['clojure.browser.event'
 ], ['cljs.core', 'goog.events.EventType', 'goog.events.EventTarget',
 'goog.events']);
 ...
 goog.addDependency(../shoreleave/remotes/http_rpc.js, [
 'shoreleave.remotes.http_rpc'], ['cljs.core', 'shoreleave.remotes.xhr',
 'cljs.reader']);
 goog.addDependency(../edgar.js, ['edgar'], ['cljs.core',
 'clojure.browser.repl', 'shoreleave.remotes.http_rpc']);


 *main.js *


 Hmm
 Tim


 On Tue, May 7, 2013 at 4:37 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 *DON'T DO IT*

 I just realised, if the :optimizations missing triggers this
 behaviour, it should be possible to set it to nil, and it was!

 So try ':optimizations nil' in your build.

 Jonathan


 On Tue, May 7, 2013 at 10:20 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I tried it, and I think removing the :optimizations flag will do
 what you want. The problem is that cljsbuild sets it to :whitespace
 by default, so even if you remove it from your build it's still there.

 To circumvent this, I opened lein-cljsbuild-0.3.0.jar in
 ~/.m2/repository/lein-cljsbuild/lein-cljsbuild/0.3.0/
 In the jar, in the file leiningen/cljsbuild/config.clj I changed the
 function

 (defn- default-compiler-options [target-path]
   {:output-to (in-target-path target-path main.js)
:optimizations :whitespace
:warnings true
:externs []
:libs []
:pretty-print true})

 to

 (defn- default-compiler-options [target-path]
   {:output-to (in-target-path target-path main.js)
:warnings true
:externs []
:libs []
:pretty-print true})

 (just removing the :optimizations)

 and put it back in the jar. Which had the effect which I think you
 want, If I understand you correctly.

 I hope these instructions are clear enough. :)

 Jonathan



 On Tue, May 7, 2013 at 10:06 PM, Timothy Washington 
 twash...@gmail.comwrote:

 Hey Jonathan,

 Saw that flag, and it's useful. But what I want to do is separate my
 main.js from all my other.js files. I've a more detailed description
 abouve. Maybe I just can't do this, but I thought I'd ask around.


 Tim


 On Tue, May 7, 2013 at 4:03 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 From the sample.project.clj:

 ; Determines whether the temporary JavaScript files will be left in
 place between
 ; automatic builds. Leaving them in place speeds up compilation
 because things can
 ; be built incrementally. This probably shouldn't be disabled except
 for troubleshooting.
 ; Defaults to true.
 :incremental true


 So it seems like you don't have to worry about it. :)
 cljsbuild does it automatically.

 Jonathan

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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

Re: Separating Out .cljs Content

2013-05-08 Thread Jonathan Fischer Friberg
That's odd, it should definitely be possible to do - I've done it before.

Did you include the scripts something like this (from the dom example):

script type=text/javascript src=out/goog/base.js/script
script type=text/javascript src=dom.js/script
script type=text/javascript
   goog.require('dom.test');
/script

Jonathan



On Wed, May 8, 2013 at 2:30 AM, Timothy Washington twash...@gmail.comwrote:

 That fixed one of the dependency problems. But now there are a bunch of
 other dependency errors. AndI'm not sure if I have to independently include
 all the library generated .js files. It looks like you have no choice but
 to glom your .js code into main.js. Hmmm.


1. Uncaught ReferenceError: goog is not defined 
 http_rpc.js:1http://localhost:8080/javascript/shoreleave/remotes/http_rpc.js


1. Uncaught ReferenceError: shoreleave is not defined 
 edgar.js:1http://localhost:8080/javascript/edgar.js

 Tim


 On Tue, May 7, 2013 at 5:26 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 You have to import the google closure library when compiling without
 optimisation.

 Given your build, probably something like this:

 script type=text/javascript
 src=public/javascript/goog/base.js/script

 Just make sure the base.js file is actually there.

 Jonathan

  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Struggling with encapsulation

2013-05-09 Thread Jonathan Fischer Friberg
I agree with Gary, there's normally not really any need to obfuscate the
implementation,
and using the underlying structure can sometimes be useful.

That said, if you really want to, you can create a woobly protocol and
implement it using reify, this will make the underlying implementation
completely hidden.

(defprotocol Woobly
  (add-job [woobly job]))

(defn create-woobly
 ([] (create-woobly 100)
 ([queue-size]
  (let [queue (java.util.concurrent.LinkedBlockingQueue. queue-size)]
(reify Woobly
  (add-job [woobly job]
...use queue...)

Jonathan



On Thu, May 9, 2013 at 6:15 PM, Gary Trakhman gary.trakh...@gmail.comwrote:

 If the interface provides everything that's needed, then there will be no
 need to dive in?

 I find attempts to hide that stuff frustrating when I'm a consumer of the
 code, if I need it, and I acknowledge that implementation details are
 subject-to-change when I take that risk, so only having something clearly
 marked off by documentation of intent would be what I would do as a
 producer of the code.


 On Thu, May 9, 2013 at 12:07 PM, Colin Yates colin.ya...@gmail.comwrote:

 (newbie, but trying hard!)

 I am designing a Woobly.  A Woobly is non-trivial and has a number of
 internal data structures (queues, worker threads etc.).  You can 'add' and
 'remove' jobs from a Woobly.

 In OO land I might have a Woobly interface with the various methods which
 provides a public API.  I might also have a factory or more likely builder
 somewhere which creates Wooblies.

 The part I am struggling with is how to create a Woobly without exposing
 its internals.  Let's imagine that Woobly uses an internal
 LinkedBlockingQueue of a certain size.

 Option 1 - a big bag of data.
 I could create a map of config/state/data that comprises the
 implementation and have the creator function return that.  Consumers can
 then call other methods passing back that bag of config/state, but what
 stops them simply diving into that bag themselves?  For example:

 [code]
 (defn create-woobly
  ([] (create-woobly 100)
  ([queue-size] {:queue (java.util.concurrent.LinkedBlockingQueue
 queue-size)}))

 (defn add-job [woobly job] )

 ;; nothing stopping me diving into that state...
 (.clear (:queue (create-wobbly)))
 [/code]

 Option 2 - protocol and deftype
 Alternatively I could implement an IWoobly protocol and create a single
 deftype which is instantiated and returned from the 'create-woobly'
 function?  I am not sure I like this as it is really back to OO isn't it?

 I want to retain the notion of create returning a handle which is the
 first argument in the other public functions, but the first way just feels
 far too dangerous.

 Am I overthinking this - what do you all do to address this?

 Thanks a bunch.

 Col

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-11 Thread Jonathan Fischer Friberg
On Sat, May 11, 2013 at 9:25 PM, Alex Baranosky 
alexander.barano...@gmail.com wrote:

 Most of the code I see and write at work at Runa uses (not (empty? foo)).
  I'll continue to defend the position that it is more obvious code, and
 therefore better (imo :) )

 Alex


Completely agree. (seq foo) says nothing, but (empty? foo) says exactly
what's going on.

Jonathan

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Screencast: Clojure development with Sublime Text 2

2013-05-18 Thread Jonathan Fischer Friberg
Nice introduction!

Problems/suggestions for lispindent can be reported here:
https://github.com/odyssomay/sublime-lispindent/issues
don't be shy!

In any case, I went ahead and implemented checking for the
syntax of the file. So non-saved files with clojure syntax is now
indented correctly.

This update is not live yet. It will be soon, but I have recently
done some rather large changes on the plugin (not huge, but
largest since its inception), so I want to do some more testing
before pushing it to everyone. :)

Jonathan (author of lispindent)


On Sat, May 18, 2013 at 10:36 PM, James MacAulay jmacau...@gmail.comwrote:

 This is a little show-and-tell I recorded today:

 http://www.youtube.com/watch?v=wBl0rYXQdGg

 Hopefully it's useful for some of you. Feedback welcome!

 Cheers,
 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
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: find first match in a sequence

2013-05-19 Thread Jonathan Fischer Friberg
On Sun, May 19, 2013 at 4:54 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

  ha! you cheated with iterate...

 try this which is closer to the example...

 (first (filter odd? (map #(do (println realized  %) %)  [2 4 6 7 8 9])))
 realized  2
 realized  4
 realized  6
 realized  7
 realized  8
 realized  9
 7

 Jim


= (some #(when (odd? %) %)
 (map #(do (println realized %) %)
  [2 4 6 7 8 9]))
realized 2
realized 4
realized 6
realized 7
realized 8
realized 9
7

;)

In fact, just calling 'first' on a mapped sequence gives the same behaviour:

= (first (map #(do (println realized %) %)
   [2 4 6 7 8 9]))
realized 2
realized 4
realized 6
realized 7
realized 8
realized 9
2

That said, 'some' does avoid realizing the first 32 elements if it's a vec.
I still don't
think you should care about that though - that's kind of the point of
laziness, to be
able to use map/filter etc without caring about how much is realized.

Jonathan

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: user math expression evaluation

2013-05-28 Thread Jonathan Fischer Friberg
Found this: http://www.objecthunter.net/exp4j/
Might be useful.

Jonathan


On Wed, May 29, 2013 at 12:45 AM, SpiderPig spiderpi...@googlemail.comwrote:

 You could just write this yourself.
 It's easier than it looks.
 First start with an evaluator for rpn (reverse polish notation)
 expressions.
 x + sin(y) in rpn would be y sin x +.
 First you split that string and make it into a list.
 Then you can evaluate that with a few lines of code using a stack. Go
 through the list and if an element is a number or a variable push it on the
 stack. If it's an operator pop the appropriate number of elements from the
 stack, apply the operator and push the result back on the stack. At the end
 the stack should contain only one element, which is the result.
 Evaluating an infix expression is more complicated. One way to do it is by
 first converting the infix expression to rpn. Notice that the order of the
 operands is the same in infix and rpn. Only the operators change. To do
 this conversion you need one list to hold the result and a stack. Go
 through all the elements of the infix expression. If it's an operand just
 add it to the result list. If it's an operator pop operators from the stack
 and add them to the result for as long as the top element on the stack is
 an operator with a higher precedence then the current one. Then push the
 current operator on the stack. Opening parenthesis are also pushed and when
 there is a closing parenthesis you pop operators and add them to the result
 until you find an opening one.
 There also is another method of evaluating infix expressions using
 recursion. This works by first searching for the operator with the lowest
 precedence and then recursively evaluating the expressions left and right
 from that operator.

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: using partial with -

2013-06-07 Thread Jonathan Fischer Friberg
On Fri, Jun 7, 2013 at 11:13 PM, Matt Smith matt.smith...@gmail.com wrote:

 (- '([1 2] [3 4] [5])
  (partial map first)
  flatten
  )


Because this becomes

(flatten (partial '([1 2] [3 4] [5]) map first))

I think I understand how you thought; (partial map first) becomes a
function, then I call this function with '([1 2] [3 4] [5]) which gives me
what I want!. That is not how it works, - simple rearranges the forms,
see the documentation: http://clojuredocs.org/clojure_core/clojure.core/-

What you want is -
http://clojuredocs.org/clojure_core/clojure.core/-

Hope that's understandable.

Jonathan


On Fri, Jun 7, 2013 at 11:13 PM, Matt Smith matt.smith...@gmail.com wrote:

 Newbie question here. This code:

 (println (flatten(map first '([1 2] [3 4] [5]




 (def mapfirst  (partial map first))
 (println
  (- '([1 2] [3 4] [5])
  mapfirst
  flatten
  ))




 (println
  (- '([1 2] [3 4] [5])
  (partial map first)
  flatten
  ))

 prints out:

 (1 3 5)
 (1 3 5)
 ()


 Could someone help me understand why the last println does not print (1 3
 5)

 thx.

 --
 --
 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 unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Re: eval and load-string behavior

2011-06-22 Thread Jonathan Fischer Friberg
Yes, unless you wrap it in another macro.

(defmacro a [] (vec (map (fn [x] `(load-string-here ~x)) [1 2 3
4])))

= (a)
[1 2 3 4]

But it's still pretty useless, unless macros are to replace functions...

Jonathan

On Wed, Jun 22, 2011 at 8:20 AM, Meikel Brandmeyer m...@kotka.de wrote:

 Hi,

 note that this breaks down as soon as you don't provide a literal string.
 And if you provide a literal string, you can provide the form directly
 anyway...

 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


-- 
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: ANN: Hafni

2011-06-24 Thread Jonathan Fischer Friberg
Thanks for the interest! :)

When it comes to arrows, from what I have read, functions can be seen as a
subset to arrows. Although, I don't have sufficient understanding to what
this really means.

It's true that standard functions could be used, and would be clearer. I'm a
little scared of doing that because people might use the mindset they have
of functions and apply it on these arrows. I don't know if that's really a
bad thing though (probably not).

I'm currently investigating how extend-type could be used to extend
component-p which would mean that java objects could be used directly.
This would play better with both java and seesaw.

__

Actually, while I'm writing this, I have changed the arrow implementation.
Datatypes implementing the arrow protocol only have to implement _int
(for internal) and fst_int.
I added implementation for functions.
 and  supports any number ( 0) of arrows.

https://github.com/odyssomay/Hafni/blob/master/src/Hafni/arrow.clj

Jonathan

On Thu, Jun 23, 2011 at 5:44 PM, Dave Ray dave...@gmail.com wrote:

 Hi,

 This looks pretty cool. I'd love to see a larger example of how you'd
 apply arrows to managing UI state. From my limited understanding,
 functions are arrows, but arrows are not functions. The examples you
 give fall pretty much in the functions are arrows camp, meaning that
 the code could be written just as easily, and maybe more clearly, by
 chainging pure functions (please correct me if I'm wrong). I'd like to
 see an example where FRP clearly makes handling change easier and more
 functional.

 When I started working on Seesaw, I did some reading on FRP, but
 decided I was already up to my neck with learning Clojure. As a
 result, Seesaw's nice to use, but isn't particularly functional and,
 as you say, the most annoying parts are those that manipulate the UI.
 So, I'd also like to explore how Hafni could be used in conjunction
 with Seesaw. If you have further ideas on this or need help, feel free
 to contact me.

 ... and don't feel too bad about writing another Swing wrapper. A
 month after starting Seesaw, I stumbled upon another, abandoned
 Clojure+Swing project called ... wait for it... Seesaw. Go figure :)

 Best regards,

 Dave

 On Mon, Jun 20, 2011 at 7:57 AM, Jonathan Fischer Friberg
 odysso...@gmail.com wrote:
  Hi,
 
  I figured that I would announce a library that I have been working on for
 a
  while now.
 
  It's called Hafni, and it's a swing wrapper. Why another swing wrapper?
  I wanted to solve the following problems:
 
  1. There are a lot of boilerplate code needed.
 
  2. Changes made to content is not very functional.
 
  3. Changing content is (sometimes) annoyingly hard.
 
  To solve these problems, I looked into the very functional world of
 Haskell
  and found something called Functional reactive programming (FRP)[1][2]
 which
  has been used to solve problem 2 in gui programming for Haskell. To be
 able
  to program FRP, the datatype arrow was created (or maybe the other way
  around), and this is what Hafni uses. I wont go into detail here since it
 is
  not very easy to explain in a short mail, and there are a lot of
 resources
  out there on the subject (see the links).
 
  To be honest, when I first started programming on Hafni, I didn't know
 that
  there existed other swing wrappers for java (I guess I also wanted to try
  this myself, which meant that I didn't really search it out), but since
 they
  do exist, lets compare Hafni to the two I have seen on this mailing list:
  seesaw [3] and GUIFTW [4].
 
  1. Hafni is strictly a swing wrapper and does not claim to be anything
 else.
 Seesaw - aims to provide a ui library, It happens to be built on
 Swing.
 GUIFTW - It's not tied to any GUI toolkit but instead front-ends for
  each can be written easily.
 
  2. Hafni has facilities, but is not really interested in exactly how
  components look.
 Seesaw - Doesn't really express an opinion about this, but seems to
 have
  a lot of facilities for making components look a certain way.
 GUIFTW - Style it in a CSS fashion
 
  3. When events happen, Hafni uses the Event and arrow datatypes to
 make
  things happen while both
 seesaw and GUIFTW uses something that looks like
 the standard java event function(s). It should be noted that Hafni
  event/arrows
 behaves exactly like corresponding for seesaw and GUIFTW if no changes
 is
  made to content.
 
  The reason of 2 (which, in a way, leads to 3) is that when I wrote swing
  code manually, the parts
  that I were most annoyed with weren't to make things look as I wanted
 them,
  it was changing them.
 
  I haven't really looked into it exactly (or tried it), but it looks like
  seesaw and Hafni can be combined
  since seesaw deals directly with java objects (the config! function is
  especially interesting) [5].
 
  I would like to end this mail with an example of Hafni. This example is
 the
  same as in the Hafni readme.
 
  (frame :content (comp

Re: ANN: Hafni

2011-07-06 Thread Jonathan Fischer Friberg
Sorry to not get back at you earlier. I was on vacation.

iarr stands for internal arrow, it was created because the arr function
cannot be used inside the Arrow record. As of the rearrangement of the arrow
protocol, it is deprecated.

The ||| function is definitely the most confusing, but I added a docstring
that might help:
https://github.com/odyssomay/Hafni/blob/master/src/Hafni/arrow.clj

I also added your examples.

I should also say that the flow macro is deprecated in favor of the new 
function in version 1.0.6 (which I just uploaded).

Jonathan

On Thu, Jun 30, 2011 at 8:48 PM, Scott Jaderholm jaderh...@gmail.comwrote:

 In arrow.clj:

 What is iarr an abbreviation for?

 Perhaps a docstring on ||| would help, I'm having trouble understanding it.

 Maybe add these examples, I found them helpful

 ((arr inc) 1)
 ;; 2

 (( (arr inc) (arr dec)) 1)
 ;; 1

 ((flow (arr inc)  (arr inc)  (arr inc)) 1)
 ;; 4

 ((*** (arr inc)
  (arr dec))
  [1 1])
 ;; [2 0]

 (( (arr inc)
  (arr dec))
  1)
 ;; [2 0]

 ((fst (arr inc)) [1 1])
 ;; [2 1]

 Scott



 On Mon, Jun 20, 2011 at 7:57 AM, Jonathan Fischer Friberg
 odysso...@gmail.com wrote:
  Hi,
 
  I figured that I would announce a library that I have been working on for
 a
  while now.
 
  It's called Hafni, and it's a swing wrapper. Why another swing wrapper?
  I wanted to solve the following problems:
 
  1. There are a lot of boilerplate code needed.
 
  2. Changes made to content is not very functional.
 
  3. Changing content is (sometimes) annoyingly hard.
 
  To solve these problems, I looked into the very functional world of
 Haskell
  and found something called Functional reactive programming (FRP)[1][2]
 which
  has been used to solve problem 2 in gui programming for Haskell. To be
 able
  to program FRP, the datatype arrow was created (or maybe the other way
  around), and this is what Hafni uses. I wont go into detail here since it
 is
  not very easy to explain in a short mail, and there are a lot of
 resources
  out there on the subject (see the links).
 
  To be honest, when I first started programming on Hafni, I didn't know
 that
  there existed other swing wrappers for java (I guess I also wanted to try
  this myself, which meant that I didn't really search it out), but since
 they
  do exist, lets compare Hafni to the two I have seen on this mailing list:
  seesaw [3] and GUIFTW [4].
 
  1. Hafni is strictly a swing wrapper and does not claim to be anything
 else.
 Seesaw - aims to provide a ui library, It happens to be built on
 Swing.
 GUIFTW - It's not tied to any GUI toolkit but instead front-ends for
  each can be written easily.
 
  2. Hafni has facilities, but is not really interested in exactly how
  components look.
 Seesaw - Doesn't really express an opinion about this, but seems to
 have
  a lot of facilities for making components look a certain way.
 GUIFTW - Style it in a CSS fashion
 
  3. When events happen, Hafni uses the Event and arrow datatypes to
 make
  things happen while both
 seesaw and GUIFTW uses something that looks like
 the standard java event function(s). It should be noted that Hafni
  event/arrows
 behaves exactly like corresponding for seesaw and GUIFTW if no changes
 is
  made to content.
 
  The reason of 2 (which, in a way, leads to 3) is that when I wrote swing
  code manually, the parts
  that I were most annoyed with weren't to make things look as I wanted
 them,
  it was changing them.
 
  I haven't really looked into it exactly (or tried it), but it looks like
  seesaw and Hafni can be combined
  since seesaw deals directly with java objects (the config! function is
  especially interesting) [5].
 
  I would like to end this mail with an example of Hafni. This example is
 the
  same as in the Hafni readme.
 
  (frame :content (comp-and-events (button :text *)
:act (flow (output-arr this :text) 
   (arr #(str % *)) 
  (input-arr this :text)))
  :size 200 200 :dont_exit_on_close)
 
  As it's already explained in the readme, let's look at the most
 interesting
  part:
 
  (flow (output-arr this :text)  (arr #(str % *))  (input-arr this
  :text))
 
  This code snippet says that the current text of the button created with
  (button :text *) should flow to
  the function #(str % *) which adds a * to the text, which should flow
 to
  the text of that same button.
  The result of this is that when the button is pressed, the text of that
  button is changed as follows:
  *
  **
  ***
  
  etc ...
 
  And finally, the link to Hafni: https://github.com/odyssomay/Hafni
 
  ___
 
  I really hope that someone finds this project interesting, and at best
 even
  useful. ;)
 
  Questions, comments, ideas, critique?
 
  Jonathan
 
  1. http://en.wikipedia.org/wiki/Functional_reactive_programming
  2. http://www.haskell.org/haskellwiki/Functional_Reactive_Programming
  3. https

Re: Please stand firm against Steve Yegge's yes language push

2011-07-07 Thread Jonathan Fischer Friberg
On Thu, Jul 7, 2011 at 7:42 AM, nchubrich nchubr...@gmail.com wrote:

 * Since Lisp is highly extensible, in the long run being
 'prescriptive' is a losing battle.  It is better to eventually add
 standard 'bad' features to the language than to tempt third parties to
 do it in even worse and incompatible ways.


Maybe, but I don't think that the core should change much or at all.
Besides, most of those features are probably already in java.


 * Clojure is already enough of a new way of thinking, and it may be
 simply too much at once for many people.  If a gentle path gets more
 people into the ecosystem, it's worth itonce they are in Clojure
 they can be steered towards better, more functional ways of doing
 things.  In any case, experienced users are always free to ignore
 extra features.


I don't agree, It's like postponing your homework. You have to learn
sometime, and I don't think it's going to be easier later on.


 * It's meant to be a pragmatic language.  This means that a prime goal
 should be to get people writing useful (web, GUI, shell) code in it
 right away.  Having choices is good, but being forced to make all
 these choices your first day of writing Clojure, when you don't have a
 sixth sense about the community and What Really Works, is needlessly
 discouraging.


This is dangerous. One of the main points of clojure (in my opinion), is
that it's written for the actual users, and not the potential users.


 * Final (added) point: while it might have made sense to be
 'prescriptive' initially in order to establish the identity, core, and
 soul of the language, this has been done sufficiently.  Newcomers are
 not going to be confused about what the main points of Clojure are
 now.  There is therefore less risk in making it broadly useful to
 different paradigms.


Run for the hills!
I don't quite know what to say about this point, but an earlier mail comes
to mind. In that mail someone pointed out that it doesn't really matter how
many features a language supports, it will still be specifically good at
doing one thing.

___

Otherwise, I agree with the documentation issue. clojure.org seldom gives me
useful information.

Jonathan

-- 
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: Please stand firm against Steve Yegge's yes language push

2011-07-08 Thread Jonathan Fischer Friberg
On Fri, Jul 8, 2011 at 4:29 PM, James Keats james.w.ke...@gmail.com wrote:

 May I also add the following caveat emptors:
 - If you're new to programming, clojure will overwhelm you. Start with
 something like python.


I think most programming languages overwhelm you if you don't have any prior
experience. I started with C++ and when pointers  references where
introduced to me, my head almost blew out.


 - If you come from python/ruby and have no java background, do not
 expect to start hacking clojure in the morning and be productive
 and accomplishing work in the afternoon of that same day; go learn
 java for a while first (a few months at least). Also, continue using
 whatever it is you use now till you're confident you know enough to
 jump ship.


I'm learning java through clojure. Since clojure and java is so tight, it
works fine.

- if all you need is a hello world program, there are simpler
 languages for this purpose (python etc). Consider clojure if you have
 need for java apis or concurrency needs (concurrency is an advanced,
 low level topic and not something most programmers should concern
 themselves with).


You probably don't mean an actual hello world program, but let's compare
them anyway.

python:
print hello world

clojure:
(print hello world)

Not that much harder, is it?

Jonathan

-- 
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: Vagrant setup [was Re: Please stand firm against Steve Yegge's yes language push]

2011-07-08 Thread Jonathan Fischer Friberg
It looks like you haven't got enough privileges, try sudo gem install
vagrant

Jonathan

On Fri, Jul 8, 2011 at 6:58 PM, Lee Spector lspec...@hampshire.edu wrote:


 On Jul 8, 2011, at 12:38 PM, Vivek Khurana wrote:

  That is still not as easy as python. Running VM is a bigger overhead...

 There are different kinds of overhead. If the installation and setup of the
 VM is simple and bullet proof then this is acceptable overhead for me.

 On the other hand I just tried it and while the first two steps were fine
 (installing virtualbox and the extension pack) I then got:

 lee-spectors-macbook-pro:Seajure-emacs-clojure-vagrant-9a47c23 leespector$
 gem install vagrant
 WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
  /usr/bin aren't both writable.
 WARNING:  You don't have /Users/leespector/.gem/ruby/1.8/bin in your PATH,
  gem executables will not run.
 Building native extensions.  This could take a while...
 ERROR:  Error installing vagrant:
thor requires RubyGems version = 1.3.6

 This is on a macbook pro running os x 10.8.7.

  -Lee

 --
 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: Please stand firm against Steve Yegge's yes language push

2011-07-08 Thread Jonathan Fischer Friberg
I don't agree that clojure is, or should be seen as something entirely
different than java. If it weren't for java, clojure wouldn't have much use
at all.

When it comes to IDEs, I agree. I write all code in vim (for editing only),
and do the rest from the command line (meaning mostly leiningen). It felt a
bit clunky at first, but I have grown to become very confident in that
environment.

Jonathan

On Fri, Jul 8, 2011 at 7:38 PM, Colin Yates colin.ya...@gmail.com wrote:

 I think we need to be careful here about the association between Java
 and Clojure.  Sure, they run on the JVM, but that is their *only*
 relationship (from a consumer's point of view) as far as I can see.

 For me, after a decade+ of developing Enterprise Java (primarily web)
 applications I am sick and tired of all the hoops and ceremony
 involved in building Java applications.  More and more I am coming
 (from reading other people's work - not my own discovery!) to realise
 that most established best-practice is only required to answer an
 insufficiency in the language itself.

 The thing that most sold me on Clojure (rather than Scala, the main
 other contender) was the simplicity of the language itself and the low
 ceremony build-process.  To this end, I am absolutely *not* interested
 in having to live inside a huge complex bit of machinery in order to
 productively write programs.  Eclipse and IntelliJ (and ilk) are
 necessary for serious Java development mainly because they take the
 implicit weight of Java applications.  I would see it as a failing
 (maybe too strong) if Clojure required either that much machinery.

 So, for me, and I appreciate this is maybe unique, I want to go back
 and basics and learn Clojure properly.  Getting Clojure installed in
 my nice familiar Java IDE _might_ send the wrong, and very dangerous
 message that Clojure is on a migration path from Java, when, to my
 mind, it isn't.  It is a completely different language, right down to
 the fundamental build-deploy cycle.

 I guess I am saying how much of IDE _whatever_'s functionality is
 actually helpful in building Clojure applications?  As I understand
 it, large, deep nested packages (a sign of a nicely decomposed Java
 system) probably isn't the right thing in Clojure.  Refactoring
 support probably isn't required as much because Clojure *seems* easier
 to write the right thing first time  I am being naive and
 simplistic, but hopefully you get my point.

 I absolutely get that saying forget IDE _whatever_ and use Emacs
 isn't the right thing either, but I do think there is something good
 about a message of Clojure is a LISP, which have certain behaviours
 of development, Emacs is designed for that very purpose and whilst you
 can use IDE X, maybe you are trying to fit a square peg into a
 ridiculously heavy and complex hole.

 I too was pretty disillusioned when, after reading about the purity
 of development with the REPL and the bliss that is LISP development in
 emacs it turned out that after hours trying to get it all configured,
 I still couldn't get it working  A downloaded VM, or a vagrant/
 puppet/chef/one line batch/sh script file orr windows (or statically
 compiled tar.gz) executable would have made life much much simpler.

 P.S  To be transparent, although I have written millions of LOC of
 Java on trivial and large enterprise systems, I have written 3 lines
 of Clojure code, along the lines of (+ 1 2 3).  I have spent many
 hours thinking about what solutions look like in a functional language
 and have read 4 books on Clojure, so I am viewing this from afar.

 --
 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: Recommendation for Clojure Enterprise Development toolkit

2011-07-09 Thread Jonathan Fischer Friberg
That's not very constructive at all.

I think clojure would work fine (or better) for enterprise applications. The
one thing that could pull it down is maintainability, as the maintainers
must know clojure.

There was recently a thread about working on large programs in clojure. It
might contain some useful info;
http://groups.google.com/group/clojure/browse_thread/thread/edd07e750511e461#

Jonathan

On Sat, Jul 9, 2011 at 10:29 AM, MarkH markhanif...@gmail.com wrote:

 As a tech lead or architect you should be fired for even suggesting to
 use Clojure as an enterprise greenfield.   Industry and academia is
 moving towards advanced type systems.  Nobody in industry seriously
 considers Clojure for enterprise systems.

 On Jul 8, 12:43 pm, Colin Yates colin.ya...@gmail.com wrote:
  *This isn't meant to start a flame-war!*
 
  I am pretty convinced that I want to use Clojure as my primary tool
  (in place of Java/Groovy Spring and Hibernate) in writing Enterprise
  applications on the JVM.  By Enterprise I mean that my solution has to
  be very stable, maintainable by others, subject to a number of stake-
  holders and so on.
 
  Part of the attraction of Java is the set of well-established tools
  for certain things:
 
   - maven/gradle/ant for building
   - Spring for glue and a gazillion other things (disclaimer: I used to
  work for them as a Consultant)
   - Hibernate for ORM
   - JUnit/TestNG
   - and so on
 
  I am convinced that Clojure offers a different playing field in terms
  of building blocks; due to its power it seems that there isn't the
  need for such heavyweight players, rather rolling your own, or using
  light-weigh libraries seems to possible.
 
  That is excellent news, but I need to start somewhere.
 
  So, what do other enterprise developers use?  There are a gazillion
  libraries out there but where do you start?  For example (religious
  war starts now):
 
   - cake seems to be a superset of lein but lein seems to be the
  preferred choice - which should a newbie go with
   - what behaviour driven testing (i.e. BDD) library would you use (for
  integration tests)
   - which unit testing framework do you use (lazy-test's watch method
  is very appealing)
   - which CI servers have you integrated Clojure with, and how?
   - which other high quality libraries can you recommend (akin to
  JodaTime)
 
  Basically, what supporting infrastructure do you guys use to build
  large Clojure apps.
 
  I hope the gist of this request comes through - I, of course, should
  try them all, but if recommendations are always welcome.

 --
 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: Looking for examples of using Java iterators from Clojure...

2011-07-09 Thread Jonathan Fischer Friberg
Maybe this would do:
https://gist.github.com/1073506

I should add that I have never used iterators, and that the code is untested
;)

Jonathan

On Sat, Jul 9, 2011 at 11:10 AM, stu stuart.hungerf...@gmail.com wrote:

 Hi,

 I'd like to make use of Java classes implementing the Java2D
 PathIterator interface:


 http://download.oracle.com/javase/6/docs/api/java/awt/geom/PathIterator.html

 Which leads to a serious impedance mismatch between immutable Clojure
 data structures and the iterator's approach of calling next() until
 isDone() and using currentSegment() to retrieve the point
 coordinates.

 I'd guess this kind of iterator is widely used in the Java world, so
 can some kind person point to an example of Clojure code using a Java
 iterator in this way?

 Thanks in advance,

 Stu

 --
 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: Looking for examples of using Java iterators from Clojure...

2011-07-09 Thread Jonathan Fischer Friberg
I don't think I like the notion of a lazy-seq and an iterator, since reading
the iterator also changes it. Consider the case where you create a lazy-seq
from an iterator, and the iterator somehow escapes. Somewhere else the
iterator is read from, and now the data that where supposed to be in the
lazy-seq no longer exists.

I guess you could clone the iterator, but that would sort of remove the
purpose of using a lazy-seq in the first place.

Jonathan

On Sat, Jul 9, 2011 at 3:17 PM, David Powell djpow...@djpowell.net wrote:


 On Sat, Jul 9, 2011 at 10:10 AM, stu stuart.hungerf...@gmail.com wrote:

 Hi,

 I'd like to make use of Java classes implementing the Java2D
 PathIterator interface:


 http://download.oracle.com/javase/6/docs/api/java/awt/geom/PathIterator.html

 Which leads to a serious impedance mismatch between immutable Clojure
 data structures and the iterator's approach of calling next() until
 isDone() and using currentSegment() to retrieve the point
 coordinates.

 I'd guess this kind of iterator is widely used in the Java world, so
 can some kind person point to an example of Clojure code using a Java
 iterator in this way?

 Thanks in advance,

 Stu


 Clojure has a built in function, iterator-seq, which converts a
 java.util.Iterator to a lazy-seq.  Lazy-seq's keep a copy of each data item
 that they have grabbed from the iterator, so they hide the mutability of
 Iterators.

 http://clojuredocs.org/clojure_core/clojure.core/iterator-seq

 Your interface doesn't subclass java.util.Iterator though, so you would
 need to make something similar.

 I haven't tested this, but maybe something like this:


 (defn pathiterator-seq
   [i]
   (when-not (.isDone i)
 (lazy-seq
  (.next i)
  (let [arr (make-array Double/TYPE 6)
type (.currentSegment i arr)]
(cons {:type type :coords (into [] arr)}
  (pathiterator-seq i))


 --
 Dave


  --
 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: Looking for examples of using Java iterators from Clojure...

2011-07-09 Thread Jonathan Fischer Friberg
Well, I guess.
But I get the feeling that the iterator are probably coming from some java
object somewhere, and might get passed around in that environment, that's
why I'm worried.

In the examples you mentioned, line-seq for example. The reader has already
'escaped' since it is passed as an argument. Of course, it is perfectly fine
to have a function where the object is completely confined, read-lines[1] in
contrib comes to mind.

Functions like line-seq and resultseq-seq are obviously needed somewhere.
However, If they are used in conjunction with some java somewhere
else...well, I don't like it.

Jonathan

[1]
http://clojuredocs.org/clojure_contrib/clojure.contrib.duck-streams/read-lines

On Sat, Jul 9, 2011 at 4:27 PM, Stuart Halloway
stuart.hallo...@gmail.comwrote:

 I don't think I like the notion of a lazy-seq and an iterator, since
 reading the iterator also changes it. Consider the case where you create a
 lazy-seq from an iterator, and the iterator somehow escapes. Somewhere else
 the iterator is read from, and now the data that where supposed to be in the
 lazy-seq no longer exists.

 I guess you could clone the iterator, but that would sort of remove the
 purpose of using a lazy-seq in the first place.

 Jonathan


 The same argument could apply to every other kind of lazy seq:

 * resultset-seq better not let the ResultSet escape
 * seqs over arrays better not let the array escape
 * line-seq better not let the BufferedReader escape

 and so on.

 Implementers of seqs are responsible for encapsulating implementation
 details and not letting them escape. It's a fact of life.

 Stu


 Stuart Halloway
 Clojure/core
 http://clojure.com

  --
 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: Extending a type to an Interface

2011-07-10 Thread Jonathan Fischer Friberg
I think the reason is that an interface means that the function must be
'inside' the class.
I.e you can call (.method object). Since it isn't possible to extend a java
class in that way, it isn't possible to use extend. In a defrecord body
however, a new class is defined, which means that it's possible to define
functions 'inside' that class.

Protocols on the other hand doesn't define functions 'inside' the object,
they are simply standard functions.

Jonathan

On Sun, Jul 10, 2011 at 1:15 PM, David Jagoe davidja...@gmail.com wrote:

 Thanks for your response Devin.

 I guess I had come to the same conclusion by the end of my email. But
 I wonder if there is a more direct way of achieving the same thing
 without using a macro that spits out a defrecord with in-line method
 declarations? I had a quick look at the defrecord code and didn't
 follow well enough to see what machinery is being used internally to
 extend the record to the java interface.

 In short: why can I implement java interfaces within a defrecord body
 but not when using extend?


 Cheers,
 David

 On 9 July 2011 02:35, Devin Walters dev...@gmail.com wrote:
  What I think Kevin meant to say was that you might consider using a
 macro.
 
  If you have questions about specifics, please do reply. This group is
 here to Help, and it would be a shame if a response like the previous one
 steered you away from asking a follow-up.
 
  Sent via mobile
 
  On Jul 8, 2011, at 5:14 PM, Kevin Downey redc...@gmail.com wrote:
 
  if only lisp had macros
 
  On Fri, Jul 8, 2011 at 12:16 PM, David Jagoe davidja...@gmail.com
 wrote:
  Hi All,
 
  I am battling with how to deal with the difference between Protocols
  and Interfaces in a particular case.
 
  Consider the following code:
 
  (defrecord DomainTypeA []
   SomeInternalProtocol
   (foo [this] foo result)
 
   clojure.lang.IFn
   (invoke [this] invoke result))
 
  This code works fine.
 
  However, I have a number of domain types all of which must use the
  same implementation of foo and invoke.
 
  In the case off foo its easy:
 
  (defrecord DomainTypeA [])
  (extend DomainTypeA SomeInternalProtocol
 internal-protocol-implementation-map)
 
  However I cannot do:
 
  (extend DomainTypeA clojure.lang.IFn some-implementation)
 
  because IFn is a java Interface. How would I get arount this?
 
  My use case is as follows:
 
  Every one of my domain objects needs to implement invoke in the same
  way, so I don't want to code it in-line on the record definition each
  time. The implementation is defined in one place and I eventually want
  a macro (e.g. defdomainobj but with a better name!) that would
  automatically hook up the IFn def.
 
  Hmm maybe I just answered my own question:
 
  Should I just write the macro that spits out the code in my first
 listing?
 
  Thanks!
 
  Cheers,
  David
 
  --
  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
 
 
 
  --
  And what is good, Phaedrus,
  And what is not good—
  Need we ask anyone to tell us these things?
 
  --
  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

 --
 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

Re: Local bindings w/o let

2011-07-10 Thread Jonathan Fischer Friberg
There's no interfaces, that's the function definition.

define function max
(defn max

attach docstring
Returns the greatest of the nums.

attach metadata
{:added 1.0}

if max is called with one argument, use this function definition
([x] x)

if max is called with two arguments, use this function definition
([x y] (if ( x y) x y))

if max is called with more than two arguments, use this function definition
([x y  more]
  (reduce max (max x y) more)))
___

As you can see, y is introduced in one of the functions definitions.
Also see:
http://clojure.org/special_forms#Special%20Forms--(fn%20name?%20[params*%20]%20exprs*)http://clojure.org/special_forms#Special%20Forms--%28fn%20name?%20[params*%20]%20exprs*%29
and
http://clojure.org/metadata

Jonathan

On Sun, Jul 10, 2011 at 11:44 PM, octopusgrabbus
octopusgrab...@gmail.comwrote:

 For Question 1 this is an example of multiple interfaces. Got it.

 On Jul 10, 5:42 pm, octopusgrabbus octopusgrab...@gmail.com wrote:
  From Clojure api for max
 
  (defn max
Returns the greatest of the nums.
{:added 1.0}
([x] x)
([x y] (if ( x y) x y))
([x y  more]
 (reduce max (max x y) more)))
 
  Question 1: Why can y be introduced as a local binding without a let?
 
  Question 2: What is the map   {:added 1.0} doing?
 
  Thanks.
  cmn

 --
 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: Results from 2011 State of Clojure survey

2011-07-13 Thread Jonathan Fischer Friberg
All those are available in 1.2, or am I missing something?

From my own experience:
metadata, when I started to learn clojure, I thought this is awesome. When
I realized that metadata only applies to clojure types, it felt unreliable
and I never got to using it.

protocols  records/types - they're straightforward, I use them.

multimethods - since close to every mention of multimethods also involves
telling how slow they are, these are most often shunned.

Jonathan

On Wed, Jul 13, 2011 at 12:52 PM, Albert Cardona sapri...@gmail.com wrote:

 Chas,

 It seems that relatively few people are taking advantage of some of
 Clojure’s most sophisticated and unique features: metadata; protocols,
 records, and types; and multimethods.  These facilities are absolutely
 game-changers, at least IMO.  Either most domains have no use for them
 (I can’t believe that), or most people don’t know how to use them
 effectively, thus they are left unused.  Those of us that write about
 and teach Clojure, take note.


 What prevents me from using it is that clojure 1.3.* is still alpha or
 early beta, and it's been for a long time.
 If clojure 1.3 was released and development continued into 1.4, I
 predict that protocols and records would suddenly start being used a
 lot more.

 Albert

 --
 http://albert.rierol.net
 http://www.ini.uzh.ch/~acardona/

 --
 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: Noobie needs help

2011-07-14 Thread Jonathan Fischer Friberg
def defines a global binding (i.e. you can reach the symbol from
everywhere).
defn does the same thing, but always binds the symbol to a function.

Therefore, you only need either def OR defn.

(defn string-maker [the-string]
  (str the-string))

OR

(def string-maker (fn [the-string] (str the-string)))

Jonathan

On Thu, Jul 14, 2011 at 8:41 AM, Tuba Lambanog tuba.lamba...@gmail.comwrote:

 Hello,
 Total noobie here. I'm trying to create a sort of a string maker
 function. Something like:

 (defn string-maker [string-name the-string]
  (def string-name (str the-string)))

 so that I can call the function like so:

 (string-maker friend Peter)

 which I expect to give me the variable:   friend
 with the value: Peter

 But alas, no luck. Can anybody point me in the right direction?
 Thanks!
 tuba

 --
 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: Noobie needs help

2011-07-14 Thread Jonathan Fischer Friberg
I see I misunderstood the question, sorry about that.

What you want is a macro:

(defmacro string-maker [string-name the-string]
  `(def ~(symbol string-name) ~the-string))

Jonathan

On Thu, Jul 14, 2011 at 1:13 PM, Giancarlo Angulo igan.l...@gmail.comwrote:

 Please look at this:
 http://clojure.org/data_structures
 see maps.
 
Giancarlo Angulo
 
 -|-^_^X@^_^,=|+^_^X~_~@-
 




 On Thu, Jul 14, 2011 at 2:41 PM, Tuba Lambanog tuba.lamba...@gmail.comwrote:

 Hello,
 Total noobie here. I'm trying to create a sort of a string maker
 function. Something like:

 (defn string-maker [string-name the-string]
  (def string-name (str the-string)))

 so that I can call the function like so:

 (string-maker friend Peter)

 which I expect to give me the variable:   friend
 with the value: Peter

 But alas, no luck. Can anybody point me in the right direction?
 Thanks!
 tuba

 --
 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


-- 
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: Modelling relationships between objects

2011-08-04 Thread Jonathan Fischer Friberg
I like to have the datastructure as one big mutable structure. It's not
optimal in many cases, but it is simple.
In this case you could have something like:

(def NoteDb
 (atom
  [{:text a note :category :misc}
   {:text note 2 :category :misc}
   {:text blabla :category :important}]))

(defn get-category-notes [category]
  (filter #(= (:category %) category) @NoteDb))

(defn update-category [category]
  (let [notes (get-category-notes category)]
.. do stuff .. ))

(defn update-note-text [index text]
  (swap! NoteDb assoc [index :text] text)
  (update-category (:category (nth @NoteDb index

I'm guessing when you say And when I change the name of a
category, all notes belonging to that category know that the category name
has
changed., you mean that each note is some sort of object, which does some
sort of operation when that category changed. Instead you could have a
update function that operates on notes from a specific category.

I also think that you should think over whether it is really necessary with
mutable notes. Depending on the case you're modeling, it could suffice with
some sort of function that updates the data and recurs.

---

The bottom line is that instead of having multiple nodes that are objects
that take care of themselves, you can have functions operating on the full
data structure.

Jonathan

On Wed, Aug 3, 2011 at 11:26 AM, Rickard Lindberg ricl...@gmail.com wrote:

 Hi,

 I am interested in Clojures approach to managing state and its use of
 immutable
 values. I believe immutable values will make the life of programmers easier
 and
 I'm trying to figure out how I can simplify my OO code by using more
 immutable
 values.

 In particular, I am wondering how I can model notes that can belong to a
 category.

 So a note is a piece of text and a reference to a category. A category is
 just
 a name. However, both notes and categories are entities (the identity is
 *not*
 defined by their value). So it is perfectly ok to have two notes with the
 same
 text and same category, yet they are different notes.

 The data structure holding these things together (lets call it NoteDb) has
 a
 list of categories and a list of notes. And I want to be able to say things
 like change the text of a note to this. And when I change the name of a
 category, all notes belonging to that category know that the category name
 has
 changed. I also want to be able to get all notes belonging to a category.

 Should I model this as a list of refs? Is there another way to think about
 this
 problem that I don't see because I have mainly done work in OO languages.

 --
 Rickard Lindberg

 --
 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: [ANN] CongoMongo 0.1.6

2011-08-05 Thread Jonathan Fischer Friberg
Might be appropriate:
https://github.com/aboekhoff/congomongo

Jonathan

On Fri, Aug 5, 2011 at 1:29 AM, Sean Corfield seancorfi...@gmail.comwrote:

 Available on Clojars.

 Compatible with Clojure 1.2 and Clojure 1.3. Fixes (almost) all reflection
 warnings. Handles multi-server connections (bug in previous snapshot build).
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/
 Railo Technologies, Inc. -- http://www.getrailo.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

 --
 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: What's wrong with my *print-dup* persistence?

2011-09-11 Thread Jonathan Fischer Friberg
Or
(load-string (+ 1 (+ 2 4)))

Jonathan

On Fri, Sep 9, 2011 at 5:14 PM, Chouser chou...@gmail.com wrote:

 On Thu, Sep 8, 2011 at 5:16 PM, Tassilo Horn tass...@member.fsf.org
 wrote:
  Hi all,
 
  I've just read Alan Malloy's excellent clojure persistence article at
 
 
 http://amalloy.hubpages.com/hub/Dont-use-XML-JSON-for-Clojure-only-persistence-messaging
 
  Then I wanted to add a feature for persisting and reloading clojure data
  that also contains vertices and edges of some java graph datastructure.
  In contrast to his java.util.Date example, those cannot be simply
  created but have to be retrieved in the context of the graph that holds
  the vertex or edge in question.
 
  All vertices and all edges have a numeric and unique id in their graph,
  and a graph itself has a unique graph id (some string).  A vertex can be
  retrieved by id using (vertex mygraph id), and it's likewise for edges
  (edge mygraph id).
 
  So my plan was to serialize vertices and edges as calls to those
  functions where the graph is looked up in a hash-map that has to be
  bound dynamically when reading the data back.  That's what I came up
  with:
 
  --8---cut here---start-8---
  (def ^:dynamic
   *serialization-bindings* nil)
 
  (defmethod print-dup Vertex [v out]
   (.write out
   (str #=
`(vertex (*serialization-bindings* ~(id (graph v))) ~(id
 v)
 
  (defmethod print-dup Edge [e out]
   (.write out
   (str #=
`(edge (*serialization-bindings* ~(id (graph e))) ~(id
 e)
 
  (defn tg-pr [x]
   (binding [*print-dup* true]
 (pr-str x)))
  --8---cut here---end---8---
 
  Testing that (rg is a memoized fn that returns just some sample graph),
  I get
 
  == (tg-pr [1 2 3 (vertex (rg) 1) 4])
  [1 2 3 #=(de.uni-koblenz.funtg.core/vertex
(de.uni-koblenz.funtg.core/*serialization-bindings*
  \c06de1c7-f4ec0906-21cfbc86-28c31aa1\) 1)
 4]
 
  Looks good, I'd say.  So my reloading function only needs to bind
  *serialization-bindings* to a map from graph id to graph, and it should
  work.
 
  --8---cut here---start-8---
  (defn tg-read [str  gs]
   (binding [*serialization-bindings* (into {} (map (fn [g] [(id g) g])
gs))
 *print-dup* true]
 (binding [*print-dup* false];; For debugging...
   (println *serialization-bindings*))
 (read-string str)))
  --8---cut here---end---8---
 
  However, using that, I get an exception.
 
  de.uni-koblenz.funtg.test.core (tg-read (tg-pr [1 2 3 (vertex (rg) 1)
 4]) (rg))
  {c06de1c7-f4ec0906-21cfbc86-28c31aa1 #RouteMapImpl
 de.uni_koblenz.jgralabtest.schemas.greqltestschema.impl.std.RouteMapImpl@5203e0c6
 }
  ; Evaluation aborted.
  No implementation of method: :vertex of protocol:
 #'de.uni-koblenz.funtg.core/IDOps found for class:
 clojure.lang.PersistentList

 I haven't tried all the above, but I had a couple thoughts that might help:

 First, inside #=(), arguments aren't evaluated.  They act as if quoted:

#=(+ 1 (+ 2 4))
; ClassCastException clojure.lang.PersistentList cannot be cast to
 java.lang.Number clojure.lang.Numbers.add (Numbers.java:126)

 The list (+ 2 4) is passed as a list to the outer +, which fails
 because it's expecting a number not a list.  So one alternative would
 be:

#=(+ 1 #=(+ 2 4))
;= 7

 But please consider another alternative:

(+ 1 (+ 2 4))
;= 7

 That is, if you're going to be evaluating a large amount of code while
 reading your data back into memory, why not just go ahead and eval it
 instead of just reading it?

(read-string #=(+ 1 #=(+ 2 4)))
 vs.
(eval (read-string (+ 1 (+ 2 4

 --Chouser

 --
 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: debugging

2011-09-11 Thread Jonathan Fischer Friberg
Sort of.

http://georgejahad.com/clojure/cdt.html

Jonathan

On Sat, Sep 10, 2011 at 5:36 PM, Dennis Haupt d.haup...@googlemail.comwrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1


 hi there,

 what's the currently best way to debug a clojure program?
 ideally, i want to see all vars, symbols, functions etc. that are in
 the current scope and be able evaluate expressions on the fly

 a start repl here and stop program until repl is closed would be
 near perfect. does such a thing exist?



 - --

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v2.0.14 (MingW32)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iQIcBAEBAgAGBQJOa4QBAAoJENRtux+h35aG1Z4P/07rnp52lJFb6HqrKCNoPkFE
 EZ4a1TxR1YYI8cBh6olcbdSxe/urFbT3JuQeR0v0/f1u/LjGzve00L+qbw3++f1v
 +yC35BAomMh5aFDJk1v5hjP63hP+/BLt+eHA2MW+wgrHtHIArS1JuE9keJwhZsVT
 W6F0AiVbbyedYieqVOhi7S8cn/0vrbVR9vaiDFytaW3ijihAMqt37pSRV8ptIGFo
 bGJuGBt6uQFpuyM+6/3c4gUcf5wtLX7/515PVhxPqO5aLQrjHfk+fRj+++XQPxkX
 WjCvd/Fl0Lkd0HbBX0TQyZwDKqYqJ7XXEfHIto7nMHwf9FVA0PWODfoYxkGlQnjX
 wrXMouddA6S0MrdhtD4TwqBiYbWAINJP9uUCIMRtDYWkmmOEDK43VoZk9qk37H+W
 ZKaCbrruaG0PYHlLxbPa5wapFb94KzgvZ2UFYN0XbKiFl4Tha2a86QS5ZI0jHpw2
 dmhBScFloWRbtZ3Rocwq8gBGyCJxE5u5qYHCELnC3a9e/LXPPyyO5d099QEUG4uM
 H2u4FGbOSdn8Le+YWc0slcYueDQkZqdlFkrXFQ+vcNUzQZLZLNcVAgkZ62NhGnX8
 Vdq1F9zKxp91JjCrhq3VHyNYg0yte3Ygzx00U/tbepkCbhoLV+yp0KGEF5Mrxad7
 /4IpYf7B0AO7QvgRcQnU
 =tERq
 -END PGP SIGNATURE-

 --
 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: Misleading Exception due to function name containing -

2011-09-11 Thread Jonathan Fischer Friberg
I've had no problems with functions containing -

Jonathan

On Fri, Sep 9, 2011 at 10:47 AM, Christina Conway
ccon...@annadaletech.comwrote:

 A function name contains the characters -
   e.g.  foo-fn
 The function causes an exception.
 However the exception is not reported on the function but on another
 function called before it.
   java.lang.IllegalArgumentException: Wrong number of args (1) passed
 to: datetime$other-fn

 If the  character is removed from the function name
   e.g. foo-fn
 then the same exception is thrown but on the function itself:
   java.lang.IllegalArgumentException: Wrong number of args (1) passed
 to: datetime$foo-fn

 If the - character is removed from the function name
   e.g. foofn
 then the exception is thrown on the function as follows:
   java.lang.IllegalArgumentException: Wrong number of args (1) passed
 to: datetime$foo-GT-fn

 The foo-fn function is compiled to a .class file as:
 foo__GT_fn.class
 The foofn function is compiled to a .class file as:
 foo_GT_fn.class
 The foo-fn function is compiled to a .class file as:
 foo_fn.class

 Has anybody else encountered this with function names containing -.
 Is this a bug?

 Thanks,
 cc

 --
 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: Exceptions in Haskell and in Clojure

2011-09-12 Thread Jonathan Fischer Friberg
Incidentally, I was just working on such a thing.
I'll send it in a new thread.

Jonathan

On Sun, Sep 11, 2011 at 7:03 PM, Michael Jaaka michael.ja...@googlemail.com
 wrote:

 Couldn't match expected type `(t, t1)'
 against inferred type `(t2, t3, t4)'
 In the expression: (8, 11, 5)
 In the expression: [(1, 2), (8, 11, 5), (4, 5)]
 In the definition of `it': it = [(1, 2), (8, 11, 5), (4, 5)]


 This was excerpt from Haskell exception, will Clojure have ever
 something like this?

 --
 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

trace-forms macro

2011-09-12 Thread Jonathan Fischer Friberg
Hello,

I made a small macro, if anyone is interested.
https://gist.github.com/1209498

It wraps one or more forms and if an exception is thrown,
prints the form that caused it, and throws the exception itself.

Examples:

user= (trace-forms 3)
3

user= (trace-forms (+ 6 (/ 9 0)))
java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:9)
Form failed: (/ 9 0)
Form failed: (+ 6 (/ 9 0))

user= (trace-forms (let [a 0 b (/ 9 a)] b))
java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:75)
Form failed: (/ 9 a)
Form failed: (let* [a 0 b (/ 9 a)] b)
Form failed: (let [a 0 b (/ 9 a)] b)

Issues:

user= (trace-forms (let [b (/ 9 a)] b))
java.lang.Exception: Unable to resolve symbol: a in this context
(NO_SOURCE_FILE:94)

user= (trace-forms (let [a (java.lang.DoesNotExist.)] a))
java.lang.ClassNotFoundException: java.lang.DoesNotExist (NO_SOURCE_FILE:93)



Thoughts?

Jonathan

-- 
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: heaps in clojure

2011-09-13 Thread Jonathan Fischer Friberg
There is the inbuilt sort function, also sort-by is useful.

In The joy of clojure, there were an example of a lazy sort.
It can be found here:
http://www.manning.com/fogus/
In the file q.clj in the source code.

Jonathan

On Tue, Sep 13, 2011 at 1:44 PM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hi Everybody,
  I have a very large, but with finite size, collection. I would like to get
 like first 10 elements in the sorted list . I would use a heap if I were in
 c++ .. is there a inbuilt implementation of this in clojure? .. Is there
 some other way to achieve this? some sort of lazy sort would be perfect. I
 know I need the full collection to start with .. but that is fine.
 Thanks,
 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

-- 
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: trace-forms macro

2011-09-14 Thread Jonathan Fischer Friberg
It was tested with 1.2.1

Jonathan

On Wed, Sep 14, 2011 at 9:09 AM, Sergey Didenko sergey.dide...@gmail.comwrote:

 Looks interesting. Did you use it with Clojure 1.3 or earlier?

 --
 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: Mocking out namespaces

2011-09-14 Thread Jonathan Fischer Friberg
You could call the mock file B_mock.clj
then

(require '[B-mock :as B])

Jonathan

On Wed, Sep 14, 2011 at 5:19 PM, Brian Hurt bhur...@gmail.com wrote:

 Say I have two name spaces, A and B, with A depending on B.  I want to test
 namespace A, replacing module B with a mock B for testing purposes-
 preferably without having to load B at all (B sucks in a bunch of stuff,
 like dependencies on databases and external web sites and etc. that I don't
 want to deal with in testing).  What is the easy, clojure-approved,
 mechanism for doing this?  I tried:

 (ns B)

 ; mock defns

 (ns user)

 (require 'A)

 but this still load the real B, and A still calls the real B, and not
 the mock B.

 Thanks.

 Brian

  --
 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: trace-forms macro

2011-09-24 Thread Jonathan Fischer Friberg

 I am moving the trace contrib stuff to 1.3. I would like to include your
 trace-forms
 macro in it. Feeling ok with this ? Comments ?


Sounds good to me.
After all, I sent it to this list so that others could make use of it!

When it comes to issues, in 1.3 it's not allowed to recur across (try ...),
which means that the macro wont work with (loop (recur ...)) or (fn ...
(recur ...)).

Also, the big missing thing is that (trace-special-form) doesn't cover fn*,
i.e. the body of functions wont be traced.

Jonathan

On Sat, Sep 24, 2011 at 7:03 AM, Luc Prefontaine 
lprefonta...@softaddicts.ca wrote:

 Hi Jonathan,

 I am moving the trace contrib stuff to 1.3. I would like to include your
 trace-forms
 macro in it. Feeling ok with this ? Comments ?

 The issues you underlined are not runtime errors, they are compilation
 errors.
 There's not much you can do to trap these.
 The macro is still valuable for runtime tracing.

 Luc P.

 On Mon, 12 Sep 2011 11:31:39 +0200
 Jonathan Fischer Friberg odysso...@gmail.com wrote:

  Hello,
 
  I made a small macro, if anyone is interested.
  https://gist.github.com/1209498
 
  It wraps one or more forms and if an exception is thrown,
  prints the form that caused it, and throws the exception itself.
 
  Examples:
 
  user= (trace-forms 3)
  3
 
  user= (trace-forms (+ 6 (/ 9 0)))
  java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:9)
  Form failed: (/ 9 0)
  Form failed: (+ 6 (/ 9 0))
 
  user= (trace-forms (let [a 0 b (/ 9 a)] b))
  java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:75)
  Form failed: (/ 9 a)
  Form failed: (let* [a 0 b (/ 9 a)] b)
  Form failed: (let [a 0 b (/ 9 a)] b)
 
  Issues:
 
  user= (trace-forms (let [b (/ 9 a)] b))
  java.lang.Exception: Unable to resolve symbol: a in this context
  (NO_SOURCE_FILE:94)
 
  user= (trace-forms (let [a (java.lang.DoesNotExist.)] a))
  java.lang.ClassNotFoundException: java.lang.DoesNotExist
  (NO_SOURCE_FILE:93)
 
  
 
  Thoughts?
 
  Jonathan
 



 --
 Luc P.

 
 The rabid Muppet

 --
 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: trace-forms macro

2011-09-26 Thread Jonathan Fischer Friberg
I looked at it today and have updated the macro.
(same gist: https://gist.github.com/1209498)

Additions:
It detects if a form contains (recur ...), and if it does,
the form isn't wrapped in (try ...).

trace vectors, maps, and sets.

trace (fn* ...)  (new ...)

---

The code feels a bit thrown together right now, if anyone would like to
take a look,
that would be great.

---

To Marczyk:
Sure, where to?

Jonathan

On Sat, Sep 24, 2011 at 10:27 PM, Michał Marczyk
michal.marc...@gmail.comwrote:

 Oh, that's a nice idea! Definitely looks like a worthy addition to the
 trace lib.

 I believe the process around contributions to contrib involves a CA,
 though; Jonathan: do you have one in place? Any chance you might be
 convinced to submit one if not? :-)

 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: iterate with side-effect function?

2011-09-28 Thread Jonathan Fischer Friberg
How about while?

(while not-finished
  (do stuff ...))

On Wed, Sep 28, 2011 at 4:23 AM, Nathan Sorenson n...@sfu.ca wrote:

 Quite often I convince myself I need state or some effectful trigger, but
 further thought reveals a simpler stateless approach.

 That being said--if you absolutely need to be doing something based on
 effects, something that absolutely can't be tracked via values in a purely
 functional way--like polling a queue once per second (functional-reactive
 programming notwithstanding), I personally prefer straight loop/recur to the
 list processing functions. In my mind, usings seq/filter/map suggests you
 are doing something lazy, referentially transparent, and composable. If you
 are not doing that, a loop recur signals to me you are manipulating the
 execution flow in a precise way.

 But again, I always try to find a way to avoid dealing with the messy
 stateful world until the last possible moment. Lots of application logic can
 be completely pure with one small write to file-type operation at the end.

  --
 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: Learning clojure - comments on my function?

2011-09-29 Thread Jonathan Fischer Friberg
First of all, you should switch from

((fn [ls wip ans] ...) ls [] nil)

to

(loop [ls ls wip [] ans nil] ...)

Read about it here:
http://clojure.org/special_forms

Using higher-order functions, you could do:

(defn split-zero [coll]
  (if (seq coll)
(let [divided (partition-by zero? coll)]
  (take-nth 2 (if (zero? (ffirst divided)) (rest divided) divided)

Step by step:
(partition-by zero? coll)
'(1 2 3 0 4 5 6 0 7 8 9) - '((1 2 3) (0) (4 5 6) (0) (7 8 9))

(if (zero? (ffirst divided)) (rest divided) divided)
If the first partition consists of zeroes, skip it.

(take-nth 2 ...)
'(3 1 7 3 0) - '(3 7 0)

On Thu, Sep 29, 2011 at 1:35 PM, Peter Hull peterhul...@gmail.com wrote:

 Hi All,
 I am just learning clojure and I've written a function to split a list (see
 docstring for details). I was wondering if any of you experienced hands
 could take a look at it and comment. I've never used lisp or a functional
 language before so I was wondering if I was doing it right or if there is a
 better way. Anyway here is the function:

 (defn split-zero
   Split a collection at its zero values into a list of lists.
Multiple zeros are treated as one.
The order of elements in each inner list is maintained but
the order of inner lists in the result may be changed.
e.g. (split-zero '(1 2 3 0 4 5 6 0 7 8 9))
- ((7 8 9) (4 5 6) (1 2 3))
   [ls] ((fn [ls wip ans]
 (if (empty? ls)
   (if (empty? wip) ans (conj ans (list* wip)))
   (if (zero? (first ls))
 (if (empty? wip)
   (recur (next ls) [] ans)
   (recur (next ls) [] (conj ans (list* wip
 (recur (next ls) (conj wip (first ls)) ans ls [] nil))

 Thanks,
 Peter

  --
 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: goog.net.cookies with clojurescript?

2011-10-06 Thread Jonathan Fischer Friberg
I managed to do it.
The problem is that we need to use the function set in a goog.net.Cookies
object.
There is already such an object, which is called goog.net.cookies, see the
bottom of the source file:

/**
 * A static default instance.
 * @type {goog.net.Cookies}
 */
goog.net.cookies = new goog.net.Cookies(document);

Therefore we need to do

(ns cookies
  (:require [goog.net.cookies :as cks]))

(defn ^:export setcookie []
  (.set goog.net.cookies name content -1))

Which will properly set the cookie (see attachment)


On Wed, Oct 5, 2011 at 11:24 PM, Eric Harris-Braun
zippy.314@gmail.comwrote:

 Has anybody successfully used cookies in clojurescript with
 goog.net.cookies?

 I keep getting this error: 'this.isValidName' [undefined] is not a
 function (Safari) or Uncaught TypeError: Object [object DOMWindow]
 has no method 'isValidName' (Chrome) when I try to set a cookie via
 goog.net.cookies.set.

 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 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=enattachment: cookie_small.png

Re: clojure.contrib.base64

2011-10-06 Thread Jonathan Fischer Friberg

 thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding?


This is already possible, if you're using leiningen:
put the file in src/util/ and compile, you can now call it as usual.

On Thu, Oct 6, 2011 at 11:16 AM, Rok Lenarcic rok.lenar...@gmail.comwrote:

 I use Base64 encoding a lot and the slow implementation is hurting a
 lot. It's slower than Sun misc encoder/decoder
 and that one is very very slow. I was using Sun's implementation a bit
 and it took 80 seconds to encode a 56 MB file.
 Then I found this: http://migbase64.sourceforge.net/
 It loaded from a disk drive and encoded the same file in 0.3 seconds!
 Would it be possible to have Clojure contrib use an implementation
 like this and thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding? I know having everything implemented in
 clojure is a big thing around here but in case of Base64 encoding and
 regular expressions I think the language would benefit greatly by
 having implementations which are orders of magnitude faster than
 default implementations in java. Did I say regular expressions?
 http://www.tusker.org/regex/regex_benchmark.html
 Like Rich Hickey said: why should we reinvent file streams and sockets
 in each language?
 I think the same principle applies to Base64 and regular expressions,
 especially when in Clojure we have an opportunity to replace standard
 java implementations with ones that are orders of magnitude faster.
 What are your views on this?

 --
 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: The Website / Wikispaces

2011-10-06 Thread Jonathan Fischer Friberg
I do

On Thu, Oct 6, 2011 at 2:32 PM, Simon Morgan s...@spamcop.net wrote:

 When using clojure.org does anybody else quite frequently get the
 Wikispaces homepage instead? This seems to happen most often when I
 start Firefox because I always have a clojure.org tab open. Any idea
 what's causing this?

 --
 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: tools.logging vs clojure.contrib.logging

2011-10-12 Thread Jonathan Fischer Friberg
As I understand it, tools.logging was created from clojure.contrib.logging
(but has been updated since).

In any case; if there exists a library in clojure/, which can perform the
same things as some part of contrib, use the clojure/ one.

On Wed, Oct 12, 2011 at 5:06 PM, jingguo yaojing...@gmail.com wrote:

 Is tools.logging is a replacement of clojure.contrib.logging?
 Which one should I use?

 --
 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

Get the name of keyword/symbol in clojurescript

2011-10-17 Thread Jonathan Fischer Friberg
Hi,

As I understand it, clojurescript uses some unicode characters to identify
keywords/symbols.
I guess that's why (str 'a) gives me ï·‘'a
I thought that this was intentional, and that (name 'a) would give me a,
but I got the same result as with (str).

So how do I extract the name from a symbol or keyword in clojurescript?
Also, is this behavior intentional, and if so, why?

-- 
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: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
I'm on the master branch.

I compiled the file using 'cljsc file  file.js', and run it in the browser.

On Tue, Oct 18, 2011 at 1:16 AM, David Nolen dnolen.li...@gmail.com wrote:

 Are you using ClojureScript HEAD? If you are and you are still seeing this
 under what conditions (advanced mode, browser REPL, etc.) ?

 David

 On Mon, Oct 17, 2011 at 6:41 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 Hi,

 As I understand it, clojurescript uses some unicode characters to identify
 keywords/symbols.
 I guess that's why (str 'a) gives me ï·‘'a
 I thought that this was intentional, and that (name 'a) would give me a,
 but I got the same result as with (str).

 So how do I extract the name from a symbol or keyword in clojurescript?
 Also, is this behavior intentional, and if so, why?

 --
 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

-- 
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: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
I can't run that repl, I get

Exception in thread main java.lang.RuntimeException:
java.lang.ClassNotFoundException: org.mozilla.javascript.Context
at clojure.lang.Util.runtimeException(Util.java:165)
at clojure.lang.Compiler.eval(Compiler.java:6435)
at clojure.lang.Compiler.eval(Compiler.java:6414)
at clojure.lang.Compiler.load(Compiler.java:6861)
at clojure.lang.RT.loadResourceScript(RT.java:357)
at clojure.lang.RT.loadResourceScript(RT.java:348)
at clojure.lang.RT.load(RT.java:427)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$require.doInvoke(core.clj:5352)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at user$eval1715.invoke(NO_SOURCE_FILE:2)
at clojure.lang.Compiler.eval(Compiler.java:6424)
at clojure.lang.Compiler.eval(Compiler.java:6390)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$null_opt.invoke(main.clj:348)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:405)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.lang.ClassNotFoundException: org.mozilla.javascript.Context
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at
cljs.repl.rhino$eval1719$loading__4505__auto1720.invoke(rhino.clj:9)
at cljs.repl.rhino$eval1719.invoke(rhino.clj:9)
at clojure.lang.Compiler.eval(Compiler.java:6424)
... 31 more


On Tue, Oct 18, 2011 at 4:25 PM, David Nolen dnolen.li...@gmail.com wrote:

 Does the same problem occur when trying this at the REPL (say via
 script/repljs) ?

 David


 On Tue, Oct 18, 2011 at 7:22 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I'm on the master branch.

 I compiled the file using 'cljsc file  file.js', and run it in the
 browser.


 On Tue, Oct 18, 2011 at 1:16 AM, David Nolen dnolen.li...@gmail.comwrote:

 Are you using ClojureScript HEAD? If you are and you are still seeing
 this under what conditions (advanced mode, browser REPL, etc.) ?

 David

 On Mon, Oct 17, 2011 at 6:41 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 Hi,

 As I understand it, clojurescript uses some unicode characters to
 identify keywords/symbols.
 I guess that's why (str 'a) gives me ï·‘'a
 I thought that this was intentional, and that (name 'a) would give me
 a, but I got the same result as with (str).

 So how do I extract the name from a symbol or keyword in clojurescript?
 Also, is this behavior intentional, and if so, why?

 --
 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


  --
 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

Re: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
It works now, and the result is as expected.

In the browser I still get the extra characters however.

On Tue, Oct 18, 2011 at 5:04 PM, David Nolen dnolen.li...@gmail.com wrote:

 Have you rerun the bootstrap script since the Rhino upgrade?


 On Tue, Oct 18, 2011 at 10:33 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I can't run that repl, I get

 Exception in thread main java.lang.RuntimeException:
 java.lang.ClassNotFoundException: org.mozilla.javascript.Context
 at clojure.lang.Util.runtimeException(Util.java:165)
 at clojure.lang.Compiler.eval(Compiler.java:6435)
 at clojure.lang.Compiler.eval(Compiler.java:6414)
 at clojure.lang.Compiler.load(Compiler.java:6861)
 at clojure.lang.RT.loadResourceScript(RT.java:357)
 at clojure.lang.RT.loadResourceScript(RT.java:348)
 at clojure.lang.RT.load(RT.java:427)
 at clojure.lang.RT.load(RT.java:398)
 at clojure.core$load$fn__4610.invoke(core.clj:5386)
 at clojure.core$load.doInvoke(core.clj:5385)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.core$load_one.invoke(core.clj:5200)
 at clojure.core$load_lib.doInvoke(core.clj:5237)
 at clojure.lang.RestFn.applyTo(RestFn.java:142)
 at clojure.core$apply.invoke(core.clj:602)
 at clojure.core$load_libs.doInvoke(core.clj:5271)
 at clojure.lang.RestFn.applyTo(RestFn.java:137)
 at clojure.core$apply.invoke(core.clj:602)
 at clojure.core$require.doInvoke(core.clj:5352)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at user$eval1715.invoke(NO_SOURCE_FILE:2)
 at clojure.lang.Compiler.eval(Compiler.java:6424)
 at clojure.lang.Compiler.eval(Compiler.java:6390)
 at clojure.core$eval.invoke(core.clj:2795)
 at clojure.main$eval_opt.invoke(main.clj:296)
 at clojure.main$initialize.invoke(main.clj:315)
 at clojure.main$null_opt.invoke(main.clj:348)
 at clojure.main$main.doInvoke(main.clj:426)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.main.main(main.java:37)
 Caused by: java.lang.ClassNotFoundException:
 org.mozilla.javascript.Context
 at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
 at
 clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:186)
 at
 cljs.repl.rhino$eval1719$loading__4505__auto1720.invoke(rhino.clj:9)
 at cljs.repl.rhino$eval1719.invoke(rhino.clj:9)
 at clojure.lang.Compiler.eval(Compiler.java:6424)
 ... 31 more



 On Tue, Oct 18, 2011 at 4:25 PM, David Nolen dnolen.li...@gmail.comwrote:

 Does the same problem occur when trying this at the REPL (say via
 script/repljs) ?

 David


 On Tue, Oct 18, 2011 at 7:22 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I'm on the master branch.

 I compiled the file using 'cljsc file  file.js', and run it in the
 browser.


 On Tue, Oct 18, 2011 at 1:16 AM, David Nolen dnolen.li...@gmail.comwrote:

 Are you using ClojureScript HEAD? If you are and you are still seeing
 this under what conditions (advanced mode, browser REPL, etc.) ?

 David

 On Mon, Oct 17, 2011 at 6:41 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 Hi,

 As I understand it, clojurescript uses some unicode characters to
 identify keywords/symbols.
 I guess that's why (str 'a) gives me ï·‘'a
 I thought that this was intentional, and that (name 'a) would give me
 a, but I got the same result as with (str).

 So how do I extract the name from a symbol or keyword in
 clojurescript?
 Also, is this behavior intentional, and if so, why?

 --
 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


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send

Re: Get the name of keyword/symbol in clojurescript

2011-10-18 Thread Jonathan Fischer Friberg
It works!

Thanks for all the help.

On Tue, Oct 18, 2011 at 5:52 PM, David Nolen dnolen.li...@gmail.com wrote:

 I see you're not setting the encoding. Try adding the following to the top
 of head

 meta charset=UTF-8

 David


 On Tue, Oct 18, 2011 at 11:43 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I did a minimal example
 https://gist.github.com/1295749

 Result is in the attachment.


 On Tue, Oct 18, 2011 at 5:22 PM, David Nolen dnolen.li...@gmail.comwrote:

 Try removing the following:

 file.js
 out

 and recompiling. I also recommend compiling one of the ClojureScript
 samples that you haven't checked out yet to see if the issue is
 reproducible.

 David

 On Tue, Oct 18, 2011 at 11:17 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 It works now, and the result is as expected.

 In the browser I still get the extra characters however.


 On Tue, Oct 18, 2011 at 5:04 PM, David Nolen dnolen.li...@gmail.comwrote:

 Have you rerun the bootstrap script since the Rhino upgrade?


 On Tue, Oct 18, 2011 at 10:33 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I can't run that repl, I get

 Exception in thread main java.lang.RuntimeException:
 java.lang.ClassNotFoundException: org.mozilla.javascript.Context
 at clojure.lang.Util.runtimeException(Util.java:165)
 at clojure.lang.Compiler.eval(Compiler.java:6435)
 at clojure.lang.Compiler.eval(Compiler.java:6414)
 at clojure.lang.Compiler.load(Compiler.java:6861)
 at clojure.lang.RT.loadResourceScript(RT.java:357)
 at clojure.lang.RT.loadResourceScript(RT.java:348)
 at clojure.lang.RT.load(RT.java:427)
 at clojure.lang.RT.load(RT.java:398)
 at clojure.core$load$fn__4610.invoke(core.clj:5386)
 at clojure.core$load.doInvoke(core.clj:5385)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.core$load_one.invoke(core.clj:5200)
 at clojure.core$load_lib.doInvoke(core.clj:5237)
 at clojure.lang.RestFn.applyTo(RestFn.java:142)
 at clojure.core$apply.invoke(core.clj:602)
 at clojure.core$load_libs.doInvoke(core.clj:5271)
 at clojure.lang.RestFn.applyTo(RestFn.java:137)
 at clojure.core$apply.invoke(core.clj:602)
 at clojure.core$require.doInvoke(core.clj:5352)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at user$eval1715.invoke(NO_SOURCE_FILE:2)
 at clojure.lang.Compiler.eval(Compiler.java:6424)
 at clojure.lang.Compiler.eval(Compiler.java:6390)
 at clojure.core$eval.invoke(core.clj:2795)
 at clojure.main$eval_opt.invoke(main.clj:296)
 at clojure.main$initialize.invoke(main.clj:315)
 at clojure.main$null_opt.invoke(main.clj:348)
 at clojure.main$main.doInvoke(main.clj:426)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.main.main(main.java:37)
 Caused by: java.lang.ClassNotFoundException:
 org.mozilla.javascript.Context
 at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
 at
 clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:186)
 at
 cljs.repl.rhino$eval1719$loading__4505__auto1720.invoke(rhino.clj:9)
 at cljs.repl.rhino$eval1719.invoke(rhino.clj:9)
 at clojure.lang.Compiler.eval(Compiler.java:6424)
 ... 31 more



 On Tue, Oct 18, 2011 at 4:25 PM, David Nolen 
 dnolen.li...@gmail.comwrote:

 Does the same problem occur when trying this at the REPL (say via
 script/repljs) ?

 David


 On Tue, Oct 18, 2011 at 7:22 AM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I'm on the master branch.

 I compiled the file using 'cljsc file  file.js', and run it in the
 browser.


 On Tue, Oct 18, 2011 at 1:16 AM, David Nolen 
 dnolen.li...@gmail.com wrote:

 Are you using ClojureScript HEAD? If you are and you are still
 seeing this under what conditions (advanced mode, browser REPL, etc.) 
 ?

 David

 On Mon, Oct 17, 2011 at 6:41 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 Hi,

 As I understand it, clojurescript uses some unicode characters to
 identify keywords/symbols.
 I guess that's why (str 'a) gives me ï·‘'a
 I thought that this was intentional, and that (name 'a) would give
 me a, but I got the same result as with (str).

 So how do I extract the name from a symbol or keyword in
 clojurescript?
 Also, is this behavior intentional, and if so, why?

 --
 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

Re: Merging two maps based on ids

2011-04-26 Thread Jonathan Fischer Friberg
(defn merge-data [data1 data2]
  (map first (partition-by :id (sort-by :id (concat data1 data2)

Since the sorting is stable (relative order is kept), we know that the first
occurrence of each id is either the existing map from data1, or the new map
from data2.

On Tue, Apr 26, 2011 at 5:34 PM, pepijn (aka fliebel) pepijnde...@gmail.com
 wrote:

 Another option is using clojure.set, as is shown here:
 https://github.com/pepijndevos/Begame/blob/master/src/begame/util.clj#L99

 On Apr 26, 10:10 am, Meikel Brandmeyer m...@kotka.de wrote:
  Hi,
 
  you can construct the output sequence from your input sequences.
 
  (defn merge-data
[data-orig data-override]
(let [override-ids (set (map :id data-override))]
  (concat data-override (remove (comp override-ids :id) data-orig
 
  If you need your output sorted you can also add a (sord-by :id ...)
 around
  the concat.
 
  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


-- 
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: Merging two maps based on ids

2011-04-26 Thread Jonathan Fischer Friberg
Correction:
(concat data1 data2) should be (concat data2 data1)

On Tue, Apr 26, 2011 at 6:37 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 (defn merge-data [data1 data2]
   (map first (partition-by :id (sort-by :id (concat data1 data2)

 Since the sorting is stable (relative order is kept), we know that the
 first occurrence of each id is either the existing map from data1, or the
 new map from data2.


 On Tue, Apr 26, 2011 at 5:34 PM, pepijn (aka fliebel) 
 pepijnde...@gmail.com wrote:

 Another option is using clojure.set, as is shown here:
 https://github.com/pepijndevos/Begame/blob/master/src/begame/util.clj#L99

 On Apr 26, 10:10 am, Meikel Brandmeyer m...@kotka.de wrote:
  Hi,
 
  you can construct the output sequence from your input sequences.
 
  (defn merge-data
[data-orig data-override]
(let [override-ids (set (map :id data-override))]
  (concat data-override (remove (comp override-ids :id) data-orig
 
  If you need your output sorted you can also add a (sord-by :id ...)
 around
  the concat.
 
  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




-- 
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: Odd Java interop behavior

2011-04-26 Thread Jonathan Fischer Friberg
Since you are essentially using java, I think that a clojure bug can be
ruled out.
Have you checked the drive for errors?

On Tue, Apr 26, 2011 at 8:12 PM, Ken Wesson kwess...@gmail.com wrote:

 Anyone know what is going on here? I'm trying to use my Clojure REPL
 to rename a file that's gotten stuck on my Windows box (somehow,
 both Explorer and the command prompt claim the file isn't found if I
 try to move, delete, or rename it) but I get this:

 com.example.isii= (FileInputStream. (nth (.listFiles (java.io.File.
 C:\\Users\\Owner\\Documents\\Downloads)) 44))
 #CompilerException java.io.FileNotFoundException:
 C:\Users\Owner\Documents\Downloads\blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah blah blah blah blah blah
 blah blah blah blah blah blah blah blah blah.mpeg  (The system cannot
 find the file specified) (NO_SOURCE_FILE:97)

 Either Java has the same bug as Windows Explorer and Windows cmd.exe,
 which seems very unlikely (why would Sun/Oracle and Microsoft make
 identical mistakes?), the NTFS volume itself is corrupt in some way
 (practically unheard-of), or something's going wrong with interop.

 I first tried pasting the file name into (.renameTo (File.
 C:\\Users\\blah blah blah)) and it didn't work so I had the idea
 that maybe the file had a funny character in its name that was causing
 problems. But the above uses .listFiles on the directory to pull the
 File object right out of the system (it happens to be the 45th file in
 the order produced by .listFiles). So it *should* work. But it
 doesn't! The .listFiles method is listing a file that .renameTo cannot
 rename and the FileInputStream constructor cannot open; both claim the
 file doesn't exist.

 Crazily, .isFile says false for this File object, so does
 .isDirectory, and so does .exists. I'm pretty sure that File objects
 returned by .listFiles are supposed to .exists, at the very least.
 Unless the Java API has a bug here, and this is an old but
 non-deprecated part of a heavily-used stock JavaSE API so that seems
 highly unlikely, then I have to suspect some wires are getting crossed
 during Clojure's Java interop. Clojure is newer and much less
 well-tested than the JavaSE API in question.

 Perhaps one object is being replaced with another, or the wrong
 methods are being called?

 At this point, the only other alternatives are increasingly outlandish
 and unlikely:

 1. A bug in an old, heavily-used, non-deprecated, standard JavaSE API
 that's gone undetected for ages.

 2. A bug in a low-level kernel file-handling routine that causes a
 file to exist for listing purposes but not for opening/rename/delete,
 in an NT kernel operating system on its second service pack rather
 than a Windows 7 beta or Windows 3.1 or some such crap. (Microsoft is
 of course notorious for bugs, but generally of the
 dodgy-C-pointer-arithmetic variety and the security-hole variety;
 getting basic file handling wrong is not really their style, and
 besides, something like that would be an utter showstopper in high
 performance server environments, a market Microsoft has been trying to
 gain significant share in for eons. Servers needing to be rebooted
 every few days? Annoying. Servers that get hacked every few months and
 need to be reloaded from the last backup? Annoying. Servers that can't
 find, read, or handle files correctly, resulting in spurious 404
 errors and the like consistently afflicting particular web pages?
 Unusable.)

 3. Some kind of damage to the underlying NTFS volume.

 Case 3, if true, would be especially worrying since that's my C drive.
 If it goes, the computer goes. Oh, most of my data is backed up and
 recoverable but having to replace the drive, the operating system, and
 reinstall all applications is likely to be very time consuming and
 expensive. So I hope you'll pardon me if I hope it's a bug in Clojure
 instead. :)

 --
 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: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
I don't know.
However, given the situation I think

(cond
  (empty? @unique-offers) (dosync ... alter ...)
  :else (logger/log error))

is better, since the change is more isolated.

On Tue, Apr 26, 2011 at 9:45 PM, Zlatko Josic zlatko.jo...@gmail.comwrote:

 Hi,

 I use cond in dosync but it doesn't work. Here is a function code:


 (defn process-request
   [offer args]
   (logger/log process called)
   (let [offer-value (Double/parseDouble (:offer offer))
   out-queue (:out-queue args)
   unique-offers (:unique-offers args)
   all-offers (:all-offers args)
   streams (:streams offer)]
   (dosync
 (cond
   (empty? @unique-offers)
   ((logger/log map @unique-offers)
 (alter unique-offers assoc offer-value streams))
   :else (logger/log  error)

 unique-offer is ref for map which is empty so condition (empty?
 @unique-offers) is true.
 Statement (alter unique-offers assoc offer-value streams) never changes
 unique-offers map.
 If I remove cond from function it works fine (The function has only dosyn
 and alter).

 What am I doing wrong?

 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 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: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
On a closer look:

((logger/log map @unique-offers)
(alter unique-offers assoc offer-value streams))

should probably be

(do (logger/log map @unique-offers)
(alter unique-offers assoc offer-value streams))

On Tue, Apr 26, 2011 at 9:55 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 I don't know.
 However, given the situation I think

 (cond
   (empty? @unique-offers) (dosync ... alter ...)
   :else (logger/log error))

 is better, since the change is more isolated.


 On Tue, Apr 26, 2011 at 9:45 PM, Zlatko Josic zlatko.jo...@gmail.comwrote:

 Hi,

 I use cond in dosync but it doesn't work. Here is a function code:


 (defn process-request
   [offer args]
   (logger/log process called)
   (let [offer-value (Double/parseDouble (:offer offer))
   out-queue (:out-queue args)
   unique-offers (:unique-offers args)
   all-offers (:all-offers args)
streams (:streams offer)]
   (dosync
 (cond
   (empty? @unique-offers)
   ((logger/log map @unique-offers)
 (alter unique-offers assoc offer-value streams))
   :else (logger/log  error)

 unique-offer is ref for map which is empty so condition (empty?
 @unique-offers) is true.
 Statement (alter unique-offers assoc offer-value streams) never changes
 unique-offers map.
 If I remove cond from function it works fine (The function has only dosyn
 and alter).

 What am I doing wrong?

 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 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: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
The important part were that the dosync call is isolated. The condition
doesn't really matter.

By the way: wouldn't it be simpler to create a new map instead of altering
unique-offers/all-offers?
(this is also more idiomatic)

On Tue, Apr 26, 2011 at 10:02 PM, Zlatko Josic zlatko.jo...@gmail.comwrote:

 I have given only part of function. I have condition like this :

 (cond
   (and (empty? @unique-offers) (empty? @all-offers))

 I change in dosync both unique-offers and all-offers. If I use your
 suggestion
   (empty? @unique-offers) (dosync ... alter ...)

 Can I get in situation where unique-offers is old value but all-offers is
 new value?

 Thanks



 On Tue, Apr 26, 2011 at 9:55 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I don't know.
 However, given the situation I think

 (cond
   (empty? @unique-offers) (dosync ... alter ...)
   :else (logger/log error))

 is better, since the change is more isolated.

 On Tue, Apr 26, 2011 at 9:45 PM, Zlatko Josic zlatko.jo...@gmail.comwrote:

 Hi,

 I use cond in dosync but it doesn't work. Here is a function code:


 (defn process-request
   [offer args]
   (logger/log process called)
   (let [offer-value (Double/parseDouble (:offer offer))
   out-queue (:out-queue args)
   unique-offers (:unique-offers args)
   all-offers (:all-offers args)
streams (:streams offer)]
   (dosync
 (cond
   (empty? @unique-offers)
   ((logger/log map @unique-offers)
 (alter unique-offers assoc offer-value streams))
   :else (logger/log  error)

 unique-offer is ref for map which is empty so condition (empty?
 @unique-offers) is true.
 Statement (alter unique-offers assoc offer-value streams) never changes
 unique-offers map.
 If I remove cond from function it works fine (The function has only dosyn
 and alter).

 What am I doing wrong?

 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 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


  --
 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: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
No, that isn't possible.
http://clojure.org/refs

Inside a transaction (a dosync call), values updated in another transaction
wont be seen. This means that the first transaction wont see the change
until it commits, at that moment it realizes that the ref that were altered
was changed outside of that particular transaction, and retries. All of this
happens automatically, so you wont have to worry.

On Tue, Apr 26, 2011 at 10:33 PM, Zlatko Josic zlatko.jo...@gmail.comwrote:

 Is this scenario posible :

 (def test-map (ref {}))

 (def test-map2 (ref {}))

 (defn process
 [map1 map2]
 (cond
   (and (empty? @map1) (empty? @map2))
   (dosync
((alter map1 assoc key1 value1)
 (alter map2 assoc key2 value2)
 .


 Suppose the process method is called from many threads. Is it posible that
 one thread tests first condition (empty? @map1) and gets true
 than another thread comits its transaction wich puts values in both maps.
 Now first thread check second
 condition (empty? @map2) which is false.



 On Tue, Apr 26, 2011 at 10:17 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 The important part were that the dosync call is isolated. The condition
 doesn't really matter.

 By the way: wouldn't it be simpler to create a new map instead of altering
 unique-offers/all-offers?
 (this is also more idiomatic)


 On Tue, Apr 26, 2011 at 10:02 PM, Zlatko Josic zlatko.jo...@gmail.comwrote:

 I have given only part of function. I have condition like this :

 (cond
   (and (empty? @unique-offers) (empty? @all-offers))

 I change in dosync both unique-offers and all-offers. If I use your
 suggestion
(empty? @unique-offers) (dosync ... alter ...)

 Can I get in situation where unique-offers is old value but all-offers is
 new value?

 Thanks



 On Tue, Apr 26, 2011 at 9:55 PM, Jonathan Fischer Friberg 
 odysso...@gmail.com wrote:

 I don't know.
 However, given the situation I think

 (cond
   (empty? @unique-offers) (dosync ... alter ...)
   :else (logger/log error))

 is better, since the change is more isolated.

 On Tue, Apr 26, 2011 at 9:45 PM, Zlatko Josic 
 zlatko.jo...@gmail.comwrote:

 Hi,

 I use cond in dosync but it doesn't work. Here is a function code:


 (defn process-request
   [offer args]
   (logger/log process called)
   (let [offer-value (Double/parseDouble (:offer offer))
   out-queue (:out-queue args)
   unique-offers (:unique-offers args)
   all-offers (:all-offers args)
streams (:streams offer)]
   (dosync
 (cond
   (empty? @unique-offers)
   ((logger/log map @unique-offers)
 (alter unique-offers assoc offer-value streams))
   :else (logger/log  error)

 unique-offer is ref for map which is empty so condition (empty?
 @unique-offers) is true.
 Statement (alter unique-offers assoc offer-value streams) never changes
 unique-offers map.
 If I remove cond from function it works fine (The function has only
 dosyn and alter).

 What am I doing wrong?

 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 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


  --
 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


  --
 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

Re: cond in dosync problem

2011-04-26 Thread Jonathan Fischer Friberg
Yes, you're right, I'm wrong. :)
The derefs must be in the dosync block. (which I somehow assumed, oh well)

On Tue, Apr 26, 2011 at 11:17 PM, Daniel Werner 
daniel.d.wer...@googlemail.com wrote:

 On Apr 26, 10:52 pm, Jonathan Fischer Friberg odysso...@gmail.com
 wrote:
  No, that isn't possible.http://clojure.org/refs

 I disagree: In the example given, dereferencing happens outside the
 dosync block, thus outside of any transaction, so a race where map1
 and map2 change midway through the #'and expression is theoretically
 possible. For this reason, #'deref/@ and #'alter are best kept in the
 same transaction in this situation.

  Inside a transaction (a dosync call), values updated in another
 transaction
  wont be seen. This means that the first transaction wont see the change
  until it commits, at that moment it realizes that the ref that were
 altered
  was changed outside of that particular transaction, and retries. All of
 this
  happens automatically, so you wont have to worry.

 --
 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: Executing Future

2011-04-28 Thread Jonathan Fischer Friberg
So I have this question. I have heard that Clojure's data structures
are immutable and it has support for promises, agents, atoms etc.

It's not that clojure's data structures support promises, agents ...
It's more like promises, agents ... support clojure's data structures.

Changing something in an agent doesn't actually change the data itself, it
only changes where the agent points, so to speak.
For example:
(def a 3)
(def b (agent a))
(send b inc)
a = 3 ; a is never changed!
@b = 4 ; instead, a new value is created, which b now points to.

Atom source:
https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Atom.java

About STM:
http://java.ociweb.com/mark/stm/article.html#PersistentDataStructures

On Thu, Apr 28, 2011 at 11:20 AM, MohanR radhakrishnan.mo...@gmail.comwrote:

 The problem was elsewhere but I realized that Clojure has support for
 futures at the level of the language even though it relies on
 java.util.concurrent.

 So I have this question. I have heard that Clojure's data structures
 are immutable and it has support for promises, agents, atoms etc.

 What exactly is meant by this ? Is it that all of these Clojure
 language featues are based on java.util.concurrent ?

 I am still learning FP and Clojure but I want to know if I am assuming
 something totally wrong here. All of these language featues seem to
 depend on java.util.concurrent.

 What about STM ? Is that a new idea based on the same Java library ?

 --
 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: Monadic implementation of the Shunting-yard algorithm

2011-05-03 Thread Jonathan Fischer Friberg
I wrote a simple implementation:
http://gist.github.com/953966https://gist.github.com/953966
(only supports operators)
It's not very elegant (I don't know how to use fnparse..), but it is
functional.
What it does is find out what the next element in the operator stack and the
out stack should be, and then recursively update the stacks and output the
finished out stack.

As I said I don't know how to use fnparse and therefore I couldn't really
understand your code.
Either way I hope that this code helps in some way.. ;)

Jonathan

On Tue, May 3, 2011 at 2:23 AM, Nicolas Buduroi nbudu...@gmail.com wrote:

 Hi, I'm working on my parsing skills using fnparse 2.2.7 and have written
 the following implementation of the Shunting-yard algorithm:

 https://gist.github.com/952607

 I plan to make a lightning talk about monadic parser at the next Bonjure
 meeting and I'd like to hear what people here think about that
 implementation first.

 It is more imperative that I would like, but that is the nature of this
 algorithm I think. Would a non-monadic implementation would be better in
 some ways? How would you make this code more flexible, faster and/or
 cleaner? Is there a more functional way of writing it?

 Thanks in advance for any comments!

 --
 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: Recreate a hierarchy

2011-05-05 Thread Jonathan Fischer Friberg
This is my take on this: http://gist.github.com/957028
The second file produces the correct result. The result isn't exactly like
you asked for. This is because it wouldn't support files that isn't in the
lowest level.

Ex:
(restore-hierarchy [[top level file1] [top level file2] [top
level2 file3]])
= {top {level {:files (file1 file2)}, level2 {:files (file3)}}}

(restore-hierarchy [[top file] [top level file1]])
= {top {level {:files (file1)}, :files (file)}}

Note the last :files in the top level.

Jonathan

On Thu, May 5, 2011 at 2:40 PM, Steffen steffen.die...@gmail.com wrote:

 Hello,

 I'm trying to come up with a way to recreate a directory hierarchy. Entries
 within zip archives are just flat strings like top/level/file1, but I
 would like to operate on them hierarchically. So my problem could be stated
 as:
 If

   (restore-hierarchy [[top level file1] [top level file2]
 [top level2 file3]])

 returns

   {top {level (file1 file2), level2 (file3)}}

  what does a nice definition of #'restore-hierarchy look like? Sadly my own
 attempts to hack it are too embarrassing to post them here...

 Thanks,

 Steffen

 --
 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: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
= uses the clojure.lang.Util/equiv to compare two things. The source of
this function is: [1]

static public boolean equiv(Object k1, Object k2){
if(k1 == k2)
return true;
if(k1 != null)
{
if(k1 instanceof Number  k2 instanceof Number)
return Numbers.equiv(k1, k2);
else if(k1 instanceof IPersistentCollection  k2 instanceof
IPersistentCollection)
return ((IPersistentCollection)k1).equiv(k2);
return k1.equals(k2);
}
return false;
}


Which says:
if k1 and k2 is the same instance (has the same id), return true
if k1 and k2 are numbers, compare them as numbers
if k1 and k2 are collections, compare them as collections
otherwise, use the function equals of the k1 object.

The equals function defines intelligent (proper) comparison of two
objects, and is defined by the programmer. If the equals function isn't
defined, it behaves like == [2]
The == function returns true if the things are of the same instance.

I think functions in clojure are defined in [3], but I'm not entirely sure.
As you can see, equals isn't implemented, and thus = will only compare
instance (id), as you have noticed.

Jonathan

[1] 
https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Util.java
https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Util.java%20
[2] http://leepoint.net/notes-java/data/expressions/22compareobjects.html
[3]
https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/AFn.java

On Thu, May 5, 2011 at 3:04 PM, Dominikus dominikus.herzb...@gmail.com
wrote:

 My observation is best distilled with the following definition of a
 function in Clojure 1.2:

 user= (defn id [x] (list id x))
 #'user/id

 Interstingly, (id 7) and (eval (id 7)) result in different instances
 of function id as the number after the '@' char unveils:

 user= (id 7)
 (#user$id user$id@53797795 7)
 user= (eval (id 7))
 (#user$id user$id@2de12f6d 7)

 Consequently, the following comparison leads to false:

 user= (= (id 7) (eval (id 7)))
 false

 Why is the instance relevant to '='? What is the precise semantics of
 two values being equal in Clojure?

 Dominikus

 (Remark: In Scheme, the use of 'eqv?' returns also #f, but the less
 restrictive 'equal?' does not and returns #t.)

 --
 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: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
I'm also interested in that.
I think it has to do with how clojure.lang.Compiler [1] works (since that is
what eval uses),
but since it is quite big, I don't know exactly what parts are important.

Jonathan

[1]
https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Compiler.java

On Thu, May 5, 2011 at 5:41 PM, Dominikus dominikus.herzb...@gmail.comwrote:

 Thanks for the pointers to the implementation, Jonathan!

 Unfortunately, I couldnt' find out yet, which part of the source code
 in Clojure 1.3 is responsible for fixing the misbehavior in 1.2. The
 parts you point to haven't changed in 1.3.

 Cheers,

 Dominikus

 On May 5, 4:27 pm, Jonathan Fischer Friberg odysso...@gmail.com
 wrote:
  = uses the clojure.lang.Util/equiv to compare two things. The source of
  this function is: [1]
 
  static public boolean equiv(Object k1, Object k2){
  if(k1 == k2)
  return true;
  if(k1 != null)
  {
  if(k1 instanceof Number  k2 instanceof Number)
  return Numbers.equiv(k1, k2);
  else if(k1 instanceof IPersistentCollection  k2
 instanceof
  IPersistentCollection)
  return ((IPersistentCollection)k1).equiv(k2);
  return k1.equals(k2);
  }
  return false;
 
  }
 
  Which says:
  if k1 and k2 is the same instance (has the same id), return true
  if k1 and k2 are numbers, compare them as numbers
  if k1 and k2 are collections, compare them as collections
  otherwise, use the function equals of the k1 object.
 
  The equals function defines intelligent (proper) comparison of two
  objects, and is defined by the programmer. If the equals function isn't
  defined, it behaves like == [2]
  The == function returns true if the things are of the same instance.
 
  I think functions in clojure are defined in [3], but I'm not entirely
 sure.
  As you can see, equals isn't implemented, and thus = will only compare
  instance (id), as you have noticed.
 
  Jonathan
 
  [1]
 https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lan...
  https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lan..
 .
  [2]http://leepoint.net/notes-java/data/expressions/22compareobjects.html
  [3]
 https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lan...
 
  On Thu, May 5, 2011 at 3:04 PM, Dominikus dominikus.herzb...@gmail.com
  wrote:
 
 
 
 
 
 
 
 
 
   My observation is best distilled with the following definition of a
   function in Clojure 1.2:
 
   user= (defn id [x] (list id x))
   #'user/id
 
   Interstingly, (id 7) and (eval (id 7)) result in different instances
   of function id as the number after the '@' char unveils:
 
   user= (id 7)
   (#user$id user$id@53797795 7)
   user= (eval (id 7))
   (#user$id user$id@2de12f6d 7)
 
   Consequently, the following comparison leads to false:
 
   user= (= (id 7) (eval (id 7)))
   false
 
   Why is the instance relevant to '='? What is the precise semantics of
   two values being equal in Clojure?
 
   Dominikus
 
   (Remark: In Scheme, the use of 'eqv?' returns also #f, but the less
   restrictive 'equal?' does not and returns #t.)
 
   --
   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


-- 
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: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
It also seems that I have been linking to the wrong repo... :S
https://github.com/clojure/clojure
Should be the correct one.

On Thu, May 5, 2011 at 6:09 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 I'm also interested in that.
 I think it has to do with how clojure.lang.Compiler [1] works (since that
 is what eval uses),
 but since it is quite big, I don't know exactly what parts are important.

 Jonathan

 [1]
 https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/Compiler.java

 On Thu, May 5, 2011 at 5:41 PM, Dominikus dominikus.herzb...@gmail.comwrote:

 Thanks for the pointers to the implementation, Jonathan!

 Unfortunately, I couldnt' find out yet, which part of the source code
 in Clojure 1.3 is responsible for fixing the misbehavior in 1.2. The
 parts you point to haven't changed in 1.3.

 Cheers,

 Dominikus

 On May 5, 4:27 pm, Jonathan Fischer Friberg odysso...@gmail.com
 wrote:
  = uses the clojure.lang.Util/equiv to compare two things. The source
 of
  this function is: [1]
 
  static public boolean equiv(Object k1, Object k2){
  if(k1 == k2)
  return true;
  if(k1 != null)
  {
  if(k1 instanceof Number  k2 instanceof Number)
  return Numbers.equiv(k1, k2);
  else if(k1 instanceof IPersistentCollection  k2
 instanceof
  IPersistentCollection)
  return ((IPersistentCollection)k1).equiv(k2);
  return k1.equals(k2);
  }
  return false;
 
  }
 
  Which says:
  if k1 and k2 is the same instance (has the same id), return true
  if k1 and k2 are numbers, compare them as numbers
  if k1 and k2 are collections, compare them as collections
  otherwise, use the function equals of the k1 object.
 
  The equals function defines intelligent (proper) comparison of two
  objects, and is defined by the programmer. If the equals function isn't
  defined, it behaves like == [2]
  The == function returns true if the things are of the same instance.
 
  I think functions in clojure are defined in [3], but I'm not entirely
 sure.
  As you can see, equals isn't implemented, and thus = will only compare
  instance (id), as you have noticed.
 
  Jonathan
 
  [1]
 https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lan...
  
 https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lan...
  [2]
 http://leepoint.net/notes-java/data/expressions/22compareobjects.html
  [3]
 https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lan...
 
  On Thu, May 5, 2011 at 3:04 PM, Dominikus dominikus.herzb...@gmail.com
 
  wrote:
 
 
 
 
 
 
 
 
 
   My observation is best distilled with the following definition of a
   function in Clojure 1.2:
 
   user= (defn id [x] (list id x))
   #'user/id
 
   Interstingly, (id 7) and (eval (id 7)) result in different instances
   of function id as the number after the '@' char unveils:
 
   user= (id 7)
   (#user$id user$id@53797795 7)
   user= (eval (id 7))
   (#user$id user$id@2de12f6d 7)
 
   Consequently, the following comparison leads to false:
 
   user= (= (id 7) (eval (id 7)))
   false
 
   Why is the instance relevant to '='? What is the precise semantics of
   two values being equal in Clojure?
 
   Dominikus
 
   (Remark: In Scheme, the use of 'eqv?' returns also #f, but the less
   restrictive 'equal?' does not and returns #t.)
 
   --
   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




-- 
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: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
I created a new datatype to solve this problem:
http://gist.github.com/958001
c-fn creates a comparable function;

(let [fnmaker4 (fn [coll] (c-fn [n] (nth coll n)))
  ints (range)]
 (= (fnmaker4 ints) (fnmaker4 ints)))
= true


On Thu, May 5, 2011 at 10:41 PM, Alan a...@malloys.org wrote:

 On May 5, 1:28 pm, Ken Wesson kwess...@gmail.com wrote:
  On Thu, May 5, 2011 at 4:16 PM, Alan a...@malloys.org wrote:
   (let [fnmaker4 (fn [coll] (fn [n] (nth coll n)))
ints (range)]
(= (fnmaker4 ints) (fnmaker4 ints)))
 
   You want to make it impossible to compare functions that close over
   infinite sequences? What is the point of being able to compare
   functions if there are cases in which using the functions will
   succeed, and the existing comparison strategy would not cause errors,
   but your new proposal does?
 
  Hm, that is a problem. You'd need to compare not the sequences, but
  their generator functions. :)
 
   Similarly, if you try to eval such a function, your proposed function-
   eval semantics would, as I understand it, store its closed-over values
   in a class constant somewhere. Then there's some secret place holding
   onto the head of my lazy sequences for me? No thanks.
 
  Your fnmaker4 already holds onto the head of ints, above, so that this:
 
  user= (def q (fnmaker4 (iterate inc 0)))
  #'user/q
  user= (q 119)
  119
  user= (q 0)
  0
 
  can work properly.

 Right. But if I drop all references to the returned function after I'm
 done with it, it gets GCed. If there's some class holding a reference
 to it forever, it will never get cleaned up. For example, ((fnmaker4
 (range)) 1e6) will (I think?) currently result in a million ints being
 held in memory at once, as things are now. Those things will get
 thrown away shortly thereafter, though. I'm not sure I fully
 understand your proposal, but it seems to me like you might be making
 these stick around permanently if I include the right mixture of eval,
 quoting, and unquoting in that expression.

 --
 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: Eval destroys equality

2011-05-05 Thread Jonathan Fischer Friberg
Although (as I just realized), it fails miserably with closures.

On Thu, May 5, 2011 at 11:38 PM, Jonathan Fischer Friberg 
odysso...@gmail.com wrote:

 I created a new datatype to solve this problem:
 http://gist.github.com/958001
 c-fn creates a comparable function;

 (let [fnmaker4 (fn [coll] (c-fn [n] (nth coll n)))
   ints (range)]
  (= (fnmaker4 ints) (fnmaker4 ints)))
 = true


 On Thu, May 5, 2011 at 10:41 PM, Alan a...@malloys.org wrote:

 On May 5, 1:28 pm, Ken Wesson kwess...@gmail.com wrote:
  On Thu, May 5, 2011 at 4:16 PM, Alan a...@malloys.org wrote:
   (let [fnmaker4 (fn [coll] (fn [n] (nth coll n)))
ints (range)]
(= (fnmaker4 ints) (fnmaker4 ints)))
 
   You want to make it impossible to compare functions that close over
   infinite sequences? What is the point of being able to compare
   functions if there are cases in which using the functions will
   succeed, and the existing comparison strategy would not cause errors,
   but your new proposal does?
 
  Hm, that is a problem. You'd need to compare not the sequences, but
  their generator functions. :)
 
   Similarly, if you try to eval such a function, your proposed function-
   eval semantics would, as I understand it, store its closed-over values
   in a class constant somewhere. Then there's some secret place holding
   onto the head of my lazy sequences for me? No thanks.
 
  Your fnmaker4 already holds onto the head of ints, above, so that this:
 
  user= (def q (fnmaker4 (iterate inc 0)))
  #'user/q
  user= (q 119)
  119
  user= (q 0)
  0
 
  can work properly.

 Right. But if I drop all references to the returned function after I'm
 done with it, it gets GCed. If there's some class holding a reference
 to it forever, it will never get cleaned up. For example, ((fnmaker4
 (range)) 1e6) will (I think?) currently result in a million ints being
 held in memory at once, as things are now. Those things will get
 thrown away shortly thereafter, though. I'm not sure I fully
 understand your proposal, but it seems to me like you might be making
 these stick around permanently if I include the right mixture of eval,
 quoting, and unquoting in that expression.

 --
 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

  1   2   >