Re: Best IDE

2012-01-20 Thread Norman Gray

Greetings.

On 2012 Jan 20, at 01:26, Mark Nutter wrote:

 On Thu, Jan 19, 2012 at 11:42 AM, David Brunell quantal...@gmail.com wrote:
 How long did it take you to get comfortable with paredit?  I keep getting
 frustrated and going back to manually matching parens.
 
 I had the same experience for a while, but then I realized I just had
 to remember 3 things:

Paredit (I've just looked at the cheat-sheet) looks clever, but from my point 
of view a bit too clever for my own good.  So, David, I don't think you're 
missing anything much if you stick with the standard movement keys.

Thus C-M-(, C-M-), C-M-f, -b, -u, -d and -k do most of what one wants, in terms 
of creating and moving around balanced brackets.

For example, hoisting a sexp, as Mark illustrated, is just C-M-k, C-M-u, C-y, 
C-M-k, which takes a lot less time to perform than to describe, and which gives 
you some sort of visual feedback while you're doing it.

Crucially, however, these same keys do mostly the same thing in other modes 
(though of course they're less useful there), and they don't get in the way.

There are things I can see paredit mode does that I do in a more roundabout 
way, but not that often, and it doesn't upset me that I spend a few more 
keystrokes on them.

Also, using the standard movement keys means less customisation, which means 
I'm less crippled without my own .emacs!

This is not meant as any criticism of paredit mode or its users, of course,.but 
one doesn't need _every_ gadget

Best wishes,

Norman
 

-- 
Norman Gray  :  http://nxg.me.uk



-- 
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: ClojureScript in IE 9 (does it work?)

2012-01-20 Thread gchristnsn
Thanks for the suggestions, I have created a wrapper function and it
works, but it seems, there are more problems.

I use reader/read-string function to parse clojure data structures
sent as POST messages, and it doesn't recognize keywords in IE.
For example, it treats {:status :ok} as {\uFFFD'status \uFFFD'ok}
(I just found the bug and don't tried to investigate yet).

-- 
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: ClojureScript in IE 9 (does it work?)

2012-01-20 Thread gchristnsn
I just have tried to replace all special characters in core.js to
their escaped equivalents (\uFDD0 for keywords) and it works fine.
But I still not certain where this bug comes from.

On Jan 20, 12:56 pm, gchristnsn gchrist...@gmail.com wrote:
 Thanks for the suggestions, I have created a wrapper function and it
 works, but it seems, there are more problems.

 I use reader/read-string function to parse clojure data structures
 sent as POST messages, and it doesn't recognize keywords in IE.
 For example, it treats {:status :ok} as {\uFFFD'status \uFFFD'ok}
 (I just found the bug and don't tried to investigate yet).

-- 
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: how to get font-lock to work in swank repl buffer

2012-01-20 Thread Daniel Janus
On Thursday, January 19, 2012 9:52:44 PM UTC, bsmith.occs wrote:
 

 Incidentally, what's with this strange form of let?

   (let (font-lock-mode) ;; - shouldn't this bind variables?
 (clojure-mode-font-lock-setup))

In Common Lisp (and presumably in Emacs Lisp as well), 'let' takes an 
additional pair of parens around each name/value pair. This allows for a 
shortcut: (let (a) body) is equivalent to (let ((a nil)) body).

Sorry for the offtopic,
- Daniel 

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

Pretty-print with metadata

2012-01-20 Thread Chris Perkins
Is there a way to pretty-print an object with its metadata?

If I (set! *print-meta* true) at the REPL, I can see the metadata.  If I 
use (pprint thing), I can see the structure much more easily.  How can I do 
both?

- Chris

-- 
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: Pretty-print with metadata

2012-01-20 Thread Meikel Brandmeyer (kotarak)
Hi,

how about something like this?

(defn pprint-with-meta
  [thing]
  (when (instanceof? IMeta thing)
(print ^)
(pprint (meta thing))
(print  ))
  (pprint thing))

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

Re: Pretty-print with metadata

2012-01-20 Thread Chris Perkins
Thanks Meikel.

So I guess from your reply that there is no built-in way to do this, right? 
 The objects I'm trying to inspect can be deeply nested maps and vectors, 
and I want to see all the metadata - not just on the root object.  I guess 
I would have to either re-implement some of the logic of pprint, or hack 
pprint itself to respect *print-meta*.

- Chris

-- 
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: ClojureScript in IE 9 (does it work?)

2012-01-20 Thread David Nolen
It would be helpful if you could investigate the precise problem if there
is one and submit a JIRA ticket.

On Friday, January 20, 2012, gchristnsn gchrist...@gmail.com wrote:
 Thanks for the suggestions, I have created a wrapper function and it
 works, but it seems, there are more problems.

 I use reader/read-string function to parse clojure data structures
 sent as POST messages, and it doesn't recognize keywords in IE.
 For example, it treats {:status :ok} as {\uFFFD'status \uFFFD'ok}
 (I just found the bug and don't tried to investigate yet).

 --
 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: Pretty-print with metadata

2012-01-20 Thread Meikel Brandmeyer (kotarak)
Hi,

I don't know a built-in way. But that doesn't mean, that there isn't one. 
You could ask Tom Faulhaber directly. He did the pretty print stuff.

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

Re: Pretty-print with metadata

2012-01-20 Thread Chris Perkins
By looking at pprint.clj, I have come up with something that seems to work. 
No hacking is necessary - the code in pprint is impressively clear and 
extensible.  It's obviously designed to allow exactly this sort of 
extension to the printing mechanism.

user (defn ppm [obj]
(let [orig-dispatch pprint/*print-pprint-dispatch*]
  (pprint/with-pprint-dispatch 
(fn [o]
  (when (meta o)
(print ^)
(orig-dispatch (meta o))
(pprint/pprint-newline :fill))
  (orig-dispatch o))
(pprint obj
#'user/ppm

user (ppm elt)
^{:xmlns {a http://aaa/}, :xmlns-decls {a http://aaa/}}
{:tag :foo,
 :attrs {},
 :content
 [^{:prefix a, :xmlns {a http://aaa/}}
  {:tag :bar, :attrs {}, :content [], :uri http://aaa/}
  ^{:xmlns {a http://aaa/}}
  {:tag :blah,
   :attrs {^{:prefix a}[:x http://aaa/;] y},
   :content [],
   :uri nil}],
 :uri nil}
nil
user 

Works great!  Tom F. is officially my clojure-hero-of-the-day.

thanks,

- Chris

-- 
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: Pretty-print with metadata

2012-01-20 Thread Meikel Brandmeyer (kotarak)
Cool. :) Good to hear, that things are working. Nice to have around.

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

Re: identical?

2012-01-20 Thread Gary Trakhman
Interning a string is caching it in a string pool that lives in the jvm's 
permgen space.  Calling .intern() on a string either adds it to the pool or 
return the string object that's already in the pool.  This is safe to do 
for strings that are defined statically, generally you don't want to 
programmatically call .intern() on user input strings because that could 
blow up the permgen and cause OOM errors.  Java also automatically interns 
its string literals.

-- 
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: Controlling the test environment

2012-01-20 Thread Daniel E. Renfer
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/15/2012 06:18 PM, Matt Stump wrote:
 
 
 Is there a way to set different values for global vars when running
 tests as opposed to the development or production environment?  I
 need to control which database my tests for a noir project connect
 to. Ideally I would like to do something like the following: for
 production and development, if an environment variable is set
 connect to the database server at the specified URL, if not then
 fall back to localhost.  For test start up an embedded server, and
 connect. After the test is done, rollback the global var to the
 previous value and resume connecting to the server on localhost or
 at the location specified by the environment variable.
 
 I could create some fixture with-test-database that modifies a
 global var, but that seems a little hackish.
 
 How are other people solving this problem?  Is there something
 similar pre-baked into noir, clojure.test or midje?
 

I wrote support for configuration with different environments into
Ciste.[1]

You create a config.clj file at the root of your application that
contains a map with each of the keys being a keyword naming the
environment and the value is a map for all the config options.

You can then use set-environment! or with-environment to set the
current environment.

You can then wrap some code in definitializer. That code will be run
whenever the environment changes. I set the environment when my
application runs and then wrap all my tests in (with-environment :test )


The config namespace should be isolated enough that you could use it
without involving any of the other features.



1: https://github.com/duck1123/ciste/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8ZoO0ACgkQWorbjR01Cx59cACffeQeffgR0zgtqt5FXGaQy9gx
zz8An2pMclSd+qA8dxc8XMPB+gMbhNjR
=XbSs
-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


ANN: ClojureScript revision 927 release

2012-01-20 Thread Stuart Sierra
We have released JARs for ClojureScript to the Sonatype OSS
repository.  They will be uploaded to the Maven Central repository
within 24 hours.

We do not yet have any automated build/release cycle for
ClojureScript. If you want to track the latest ClojureScript
development, please continue to use Git.


** Sample project.clj

Leiningen users can use a project.clj file similar to the following:

(defproject foo 1.0.0-SNAPSHOT
  :description FIXME: write description
  :dependencies [[org.clojure/clojure 1.3.0]
 [org.clojure/clojurescript 0.0-927]])

To start immediately without waiting for Maven Central, add Sonatype
OSS to your public repositories like this:

  :repositories {sonatype-oss
 http://oss.sonatype.org/content/groups/public/}


** About Version Numbers

ClojureScript has no release versions yet. Instead we have a
revision number, calculated as the number of commits on the master
branch since the beginning of the project. ClojureScript is currently
at revision 927. In Maven/Leiningen, this is represented as version
0.0-927.


** Dependencies

ClojureScript depends on four things:

*** 1. Clojure 1.3 or later

Published by us. Not declared as a dependency: add it to your project
build configuration.

*** 2. Mozilla Rhino JavaScript engine

Published by Mozilla.

*** 3. Google Closure Compiler

Published by Google. Pulls in a bunch of other dependencies including
Guava, Protocol Buffers, and Ant. You may choose to ignore these or
exclude them in your project build configuration.

*** 4. Google Closure Library

Published by us as org.clojure:google-closure-library, version
0.0-790, where 790 is the Subversion revision number we are using.
The most recent SVN revision does not currently work with
ClojureScript.

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


How to loop over several sequences in parallel for side-effects?

2012-01-20 Thread joachim
Hi All,

Here is a simple problem for which I nevertheless can't seem to find
the right solution: How to run over several sequences in parallel for
side-effects? Here is one way:

 (dorun (map some-fn-with-side-effects sequence-1 sequence-2))

However, I was told that the form (dorun (map ... )) indicates that
doseq should be used instead because it is faster, and I can use
speed. I think that this is not possible however because doseq only
allows to loop over a single sequence at a time? I was wondering what
is the idiomatic clojure way in this case?

Thanks! Jm.

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


Gist script

2012-01-20 Thread DAemon
Hey everyone,

I've been playing around with Clojure, and came up with this little
thing to allow you to easily pull scripts in from Gist and execute
them. Thought it might be useful to someone!

https://gist.github.com/1646223

- DAemon

-- 
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: Best IDE

2012-01-20 Thread Dennis Peterson
That third trick works in standard vim when you type da(...except you
don't have to be on the opening paren, you can be anyplace within the sexp
(as long as you're not within a smaller sexp, in which case you'll get that
one.)

A couple quick macros can handle the other two. If those three are the main
benefits of paredit, then vim might be a better fit for lisp than I'd
realized. (I'm a lispy newb so I don't have a whole lot of experience
trying to edit it yet.)

On Thu, Jan 19, 2012 at 8:26 PM, Mark Nutter manutte...@gmail.com wrote:

 On Thu, Jan 19, 2012 at 11:42 AM, David Brunell quantal...@gmail.com
 wrote:
  How long did it take you to get comfortable with paredit?  I keep getting
  frustrated and going back to manually matching parens.

 I had the same experience for a while, but then I realized I just had
 to remember 3 things:

 To enclose an existing sexp inside a new one---in other words, if I
 have (map...) and I want (doall (map...))---put the cursor on the
 opening paren of the existing sexp and type M-( and it automatically
 wraps the whole sexp in parens, correctly balanced.

 To pull an existing sexp out of its enclosing sexp---i.e. to turn
 (doall (map ...)) back into (map...)---put the cursor on the opening
 paren of the inner sexp and type M-uparrow. Use with caution, because
 it nukes anything else in the same enclosing sexp, but that's not too
 bad because:

 If you put the cursor on the opening paren and then hit C-k, it cuts
 out exactly that sexp (and its contents) but no more, keeping the
 parens perfectly balanced.

 That last trick is what made paredit a must-have for me, because I do
 a lot of cut and paste, and paredit makes it a piece of cake. You
 don't have to worry about selecting the beginning and ending parens,
 just put the cursor on the open paren and hit C-k, and it cuts exactly
 as much as it needs to grab a balanced sexp, even across multiple
 lines, leaving any other close-parens untouched. It's awesome.

 I think paredit does other stuff too, but those three things get me
 through the day.

 Mark

 --
 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: Best IDE

2012-01-20 Thread Bill Allen
Agreed. I find paredit mode essential for any serious coding. That said,
there are brief periods in which I find I like it off.
On Jan 19, 2012 1:57 PM, Sean Corfield seancorfi...@gmail.com wrote:

 On Thu, Jan 19, 2012 at 9:07 AM, Laurent PETIT laurent.pe...@gmail.com
 wrote:
  I've tried paredit in emacs, found it really cool, and ported it to
  Counterclockwise.
  I'm now totally sold to it, and I couldn't imagine a working session with
  Counterclockwise's Strict edition mode (aka paredit for emacsers)
 turned
  off.

 When I introduce anyone to Clojure who uses Eclipse, I set them up
 with CCW and strict structural mode and they take the auto-matching
 of ( { [ for granted and never question it. When I first started with
 CCW and Clojure, I quickly found the benefits of strict mode
 outweighed any minor annoyances.

 When I switched to Emacs, the first thing I did was add paredit and
 now I rely on it heavily when refactoring code (as well as for general
 editing).
 --
 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 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: Best IDE

2012-01-20 Thread Neale Swinnerton
On Thu, Jan 19, 2012 at 2:37 PM, Maris maris.orbid...@gmail.com wrote:


 Emacs + Paredit is probably the best IDE.
 Nothing improves productivity like paredit.


Hi,

Hopefully you won't consider it too much self promotion ;-), but I gave
brief  (7 mins) lightning talk at the london clojure user group earlier in
the week about paredit which might be of use to anyone not familiar or sure
of the benefits

You can watch it here:

http://skillsmatter.com/podcast/scala/paredit-mode

Neale
(@sw1nn)

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

Documenting Clojure Design without UML

2012-01-20 Thread Adam Markham
I have always used UML to document the design of software projects I
have worked on in object-oriented languages. I am now working on a
Clojure project and am required to document the design so anyone
reading these documents will understand the design of the software.

I was wondering if there is anything like UML that can be applied to
Clojure for these purposes?

It is quite important that I document the design of the software on
paper so any suggestions on doing this would be great.

Thanks,

Adam

-- 
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: strange problem

2012-01-20 Thread joachim
On Jan 18, 8:23 pm, Andy Fingerhut andy.finger...@gmail.com wrote:
 I don't have some code lying around to do that, but I might make one.  The
 name strings would require several megabytes of storage, but as long as you
 don't mind that...

I wouldn't mind, but the code your provided is already more than I was
hoping for, so thanks again!
Jm

-- 
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: Sorry Don't understand for macro, a bug or a newbie-question??

2012-01-20 Thread aschoerk
Ah,
thank you,  so a newbie question.
But helped me a lot.

Andreas

On Jan 18, 10:26 pm, Jack Moffitt j...@metajack.im wrote:
  doesn't show any effect of the for.
  The only difference is the additional statement at the end.
  I can not imagine how this statement sequentially behind can influence
  the for.

 for returns a lazy sequence. In the first case, in printing out the
 result to the REPL, the lazy sequence is realized, and in the second,
 the result is discarded so it is never realized.

 jack.

-- 
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: lein-cljsbuild 0.0.1 released

2012-01-20 Thread Evan Mezeske
I find the idea of using a special filename extension rather
appealing.  A couple of notes:

(1) I'm not sure there is a generic clojure.  ClojureScript has a
couple serious differences from Clojure, such as the way macros are
included in (ns ...).

(2) ClojureScript macro files, AFAICT, really are strictly Clojure
files.  So I think these would stay .clj. (Unless I'm missing
something?)

-Evan

On Jan 19, 12:55 am, Dave Sann daves...@gmail.com wrote:
 If you are referring to (2), I agree.

 But marking the type of a file by either path or extension is not a hack,
 in my opinion. (3)
 I was suggesting that ideally this would be better.

 To justify this statement I would claim that:
 jvm clj files         - using java platform specifics
 clr clj files           - using .net platform specifics
 generic clj files    - using only clojure
 cljs files             - using browser platform specifics
 (and even nodejs - using node platform specifics)

 (and a special case of cljs macros)

 are all different classes/types of clojure code. In the much the same way
 that .java and .clj are different.
 Different builds will use different files.

 The problem that these build tools (crossovers and so forth) are trying to
 address is how to classify these so as to know whether to use or ignore
 them - for a specific build.

 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


Re: Best IDE

2012-01-20 Thread Joseph Smith
emacs. :D

Seriously though, start with viper-mode.

---
Joseph Smith
j...@uwcreations.com
(402)601-5443






On Jan 18, 2012, at 1:35 PM, Jeb Beich wrote:

 Any suggestions for a vim man?
 
 On Wed, Jan 18, 2012 at 1:29 PM, Cedric Greevey cgree...@gmail.com wrote:
 On Wed, Jan 18, 2012 at 11:18 AM, Jay Fields j...@jayfields.com wrote:
  Use emacs, if you want the path of least resistance
 
 *boggles*
 
 Say WHAT?
 
 You've got to be kidding. That's like suggesting that the path of
 least resistance in taking a trip to L.A. involves climbing the north
 face of Everest instead of using an airplane. In particular, the
 learning curve of emacs and the north face of Everest, in a shocking
 coincidence, turn out to have exactly the same geometry. :)
 
 --
 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
 
 
 
 -- 
 Jeb Beich
 http://www.red-source.net/jeb
 
 -- 
 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

Seemingly simple shell commands taking forever

2012-01-20 Thread techwhizbang
I am using lein run -m to execute a simple database preparation task.
I issue 2 very simple commands that execute very fast on their on own
when executed in the shell. They also appear to execute very fast
based on the print output to stdout. However, the problem is that
after executing the 2 clojure.java.shell sh commands the process hangs
on way after it completes. So much so that it feels wrong.

Here is the gist. https://gist.github.com/1635837

PS I stripped down the database credentials so that it would be easily
runnable on anyone's machine so don't bother flaming me for using the
root user.

-- 
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: ClojureScript revision 927 release

2012-01-20 Thread David Nolen
Sweet!

On Fri, Jan 20, 2012 at 2:14 PM, Stuart Sierra
the.stuart.sie...@gmail.comwrote:

 We have released JARs for ClojureScript to the Sonatype OSS
 repository.  They will be uploaded to the Maven Central repository
 within 24 hours.

 We do not yet have any automated build/release cycle for
 ClojureScript. If you want to track the latest ClojureScript
 development, please continue to use Git.


 ** Sample project.clj

 Leiningen users can use a project.clj file similar to the following:

(defproject foo 1.0.0-SNAPSHOT
  :description FIXME: write description
  :dependencies [[org.clojure/clojure 1.3.0]
 [org.clojure/clojurescript 0.0-927]])

 To start immediately without waiting for Maven Central, add Sonatype
 OSS to your public repositories like this:

  :repositories {sonatype-oss
 http://oss.sonatype.org/content/groups/public/}


 ** About Version Numbers

 ClojureScript has no release versions yet. Instead we have a
 revision number, calculated as the number of commits on the master
 branch since the beginning of the project. ClojureScript is currently
 at revision 927. In Maven/Leiningen, this is represented as version
 0.0-927.


 ** Dependencies

 ClojureScript depends on four things:

 *** 1. Clojure 1.3 or later

 Published by us. Not declared as a dependency: add it to your project
 build configuration.

 *** 2. Mozilla Rhino JavaScript engine

 Published by Mozilla.

 *** 3. Google Closure Compiler

 Published by Google. Pulls in a bunch of other dependencies including
 Guava, Protocol Buffers, and Ant. You may choose to ignore these or
 exclude them in your project build configuration.

 *** 4. Google Closure Library

 Published by us as org.clojure:google-closure-library, version
 0.0-790, where 790 is the Subversion revision number we are using.
 The most recent SVN revision does not currently work with
 ClojureScript.

 --
 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: How to loop over several sequences in parallel for side-effects?

2012-01-20 Thread Lars Nilsson
On Fri, Jan 20, 2012 at 8:18 AM, joachim joachim.de.be...@gmail.com wrote:
 Hi All,

 Here is a simple problem for which I nevertheless can't seem to find
 the right solution: How to run over several sequences in parallel for
 side-effects? Here is one way:

     (dorun (map some-fn-with-side-effects sequence-1 sequence-2))

 However, I was told that the form (dorun (map ... )) indicates that
 doseq should be used instead because it is faster, and I can use
 speed. I think that this is not possible however because doseq only
 allows to loop over a single sequence at a time? I was wondering what
 is the idiomatic clojure way in this case?

You know that (map f seq1 seq2) means call f with one argument from
seq1 and one from seq2 in turn, until one of the sequences has been
exhausted?

Does

  = (map #(vector %1 %2) [1 2 3] ['a 'b 'c])
  ([1 a] [2 b] [3 c])

Seem like the result you would expect or not, when you talk about run
over several sequences in parallel?

Lars Nilsson

-- 
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: Documenting Clojure Design without UML

2012-01-20 Thread Paulo Pinto
Hi,

I think your problem is more general than just Clojure. Actually there
was a long
discussion on the Functional Programming group over at LinkedIn
about applying
UML to functional languages.

The general consensus is that you can somehow adapt UML concepts to
describe
data structures and execution flow, but there isn't an established way
how to do it.

--
Paulo

On 19 Jan., 14:12, Adam Markham adamjmark...@gmail.com wrote:
 I have always used UML to document the design of software projects I
 have worked on in object-oriented languages. I am now working on a
 Clojure project and am required to document the design so anyone
 reading these documents will understand the design of the software.

 I was wondering if there is anything like UML that can be applied to
 Clojure for these purposes?

 It is quite important that I document the design of the software on
 paper so any suggestions on doing this would be great.

 Thanks,

 Adam

-- 
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: ClojureScript revision 927 release

2012-01-20 Thread pmbauer
Weekend made.
Thank you!

-- 
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: Best IDE

2012-01-20 Thread Alex Baranosky
I say just to use whichever environment you like most.  I use Intellij. And
its all good.

Ctrl-w to grab matching parens.
Ctrl-shift up/down to move lines of code.
Etc... What I'm saying is that most modern tools can generally get you
where you want to go, so pick what you are comfortable with.
On Jan 20, 2012 2:15 PM, Dennis Peterson dennisbpeter...@gmail.com
wrote:

 That third trick works in standard vim when you type da(...except you
 don't have to be on the opening paren, you can be anyplace within the sexp
 (as long as you're not within a smaller sexp, in which case you'll get that
 one.)

 A couple quick macros can handle the other two. If those three are the
 main benefits of paredit, then vim might be a better fit for lisp than I'd
 realized. (I'm a lispy newb so I don't have a whole lot of experience
 trying to edit it yet.)

 On Thu, Jan 19, 2012 at 8:26 PM, Mark Nutter manutte...@gmail.com wrote:

 On Thu, Jan 19, 2012 at 11:42 AM, David Brunell quantal...@gmail.com
 wrote:
  How long did it take you to get comfortable with paredit?  I keep
 getting
  frustrated and going back to manually matching parens.

 I had the same experience for a while, but then I realized I just had
 to remember 3 things:

 To enclose an existing sexp inside a new one---in other words, if I
 have (map...) and I want (doall (map...))---put the cursor on the
 opening paren of the existing sexp and type M-( and it automatically
 wraps the whole sexp in parens, correctly balanced.

 To pull an existing sexp out of its enclosing sexp---i.e. to turn
 (doall (map ...)) back into (map...)---put the cursor on the opening
 paren of the inner sexp and type M-uparrow. Use with caution, because
 it nukes anything else in the same enclosing sexp, but that's not too
 bad because:

 If you put the cursor on the opening paren and then hit C-k, it cuts
 out exactly that sexp (and its contents) but no more, keeping the
 parens perfectly balanced.

 That last trick is what made paredit a must-have for me, because I do
 a lot of cut and paste, and paredit makes it a piece of cake. You
 don't have to worry about selecting the beginning and ending parens,
 just put the cursor on the open paren and hit C-k, and it cuts exactly
 as much as it needs to grab a balanced sexp, even across multiple
 lines, leaving any other close-parens untouched. It's awesome.

 I think paredit does other stuff too, but those three things get me
 through the day.

 Mark

 --
 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: how to get font-lock to work in swank repl buffer

2012-01-20 Thread Ben Smith-Mannschott
On Fri, Jan 20, 2012 at 00:45, Jack Moffitt j...@metajack.im wrote:
 (add-hook 'slime-repl-mode-hook
               (lambda ()
                 (clojure-mode-font-lock-setup)
                 (font-lock-mode)
                 (font-lock-mode)))

Excellent! This worked for me.

Many thanks for the tip.

// ben

-- 
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: How to loop over several sequences in parallel for side-effects?

2012-01-20 Thread Meikel Brandmeyer
Hi,

to add to Lars answer:

(doseq [[a b c] (map vector s1 s2 s3)]
  (side-effect-fn a b c))

This should do the trick.

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


Re: How to loop over several sequences in parallel for side-effects?

2012-01-20 Thread Steve Miner

On Jan 20, 2012, at 2:41 PM, Lars Nilsson wrote:

  = (map #(vector %1 %2) [1 2 3] ['a 'b 'c])
  ([1 a] [2 b] [3 c])

Sorry if I'm drifting a bit off topic, but I just wanted to point out that it's 
convenient to use just the function name if the arguments are already in the 
appropriate order.  Also, it is sometimes convenient to quote a vector rather 
than the individual elements.  For example, the following is an equivalent 
expression:

(map vector [1 2 3] '[a b c])

Of course, wrapping the expression in dorun is necessary if you care about 
forcing side-effects.

-- 
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: How to loop over several sequences in parallel for side-effects?

2012-01-20 Thread Alan Malloy
But I don't see any reason why this would be faster than (dorun (map
side-effect-fn s1 s2 s3)). You're creating and then dismantling a
three-element vector at every iteration to no purpose.

On Jan 20, 12:40 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 to add to Lars answer:

 (doseq [[a b c] (map vector s1 s2 s3)]
   (side-effect-fn a b c))

 This should do the trick.

 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


Re: Pretty-print with metadata

2012-01-20 Thread Cedric Greevey
Yeah, but it won't quite work if even the metadata has metadata.

user= (def x (with-meta {:b 1} (with-meta {:a 1} {:x 1})))
#'user/x
user=
x
{:b 1}

user=
(meta x)
{:a 1}

user=
(meta (meta x))
{:x 1}

The code above would leave out the metadata {:x 1} on {:a 1}, though
it should display the metadata for anything *inside* that map.

I think it could be adjusted with:

(fn [o] -(fn pm [o]

(orig-dispatch (meta o))-(pm (meta o))

Of course, this is probably a pretty rare corner case.

-- 
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: Seemingly simple shell commands taking forever

2012-01-20 Thread Phil Hagelberg
techwhizbang techwhizb...@gmail.com writes:

 I am using lein run -m to execute a simple database preparation task.
 I issue 2 very simple commands that execute very fast on their on own
 when executed in the shell. They also appear to execute very fast
 based on the print output to stdout. However, the problem is that
 after executing the 2 clojure.java.shell sh commands the process hangs
 on way after it completes. So much so that it feels wrong.

 Here is the gist. https://gist.github.com/1635837

The agent thread pool is probably keeping the process open. Try calling
(shutdown-agents) when you're done.

This is a long-standing known bug/shortcoming in Clojure:

  http://dev.clojure.org/jira/browse/CLJ-124

-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


Re: topoged-hibernate 1.0.0

2012-01-20 Thread Matthew O. Smith


On Jan 6, 8:20 am, Bill Robertson billrobertso...@gmail.com wrote:
 On Jan 3, 4:26 pm, Matthew O.  Smith m0sm...@gmail.com wrote:

  There is a mismatch between hibernate maps and clojure maps which
  means that there is some translating between them. Hopefully, this
  will be smoothed over in the future

 What is the mismatch?

The mismatch is that Hibernate and Clojure see Map object differently
so there is an (in my mind) unnecessary conversion that has to take
place at the boundary between the two systems both in sending data to
Hibernate and also retrieving it.  It is not a huge deal, but it is
annoying.

As an example consider this code.  Rather than treating a map as
Clojure map (immutable), the develop has to treat the map as a mutable
object.

 (with-session [session _]
  (let [person (.load session Person 1)
 email topo...@topoged.com]
   (doto (. person (get emailAddresses)) (.add email

Instead I would like somthing like:

 (with-session [session _]
  (let [person (.load session Person 1)
 email topo...@topoged.com]
(assoc-in person [:emailAddresses] email)))

But that leaves the question of how to propagate the change back to
the Hibernate session.I had thought about some hybrid between
java.util.Map and IMap but decided not as it would end up just
creating more problems than it solves.

It is a problem I am still working on.

-- 
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: Pretty-print with metadata

2012-01-20 Thread Chris Perkins
Good catch!  I was about to add this to my personal toolkit of generally 
useful random crap (every programmer has one of those, right?).  I'll make 
sure to cover that edge-case.  Thanks.

- Chris

-- 
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: Clojurescript One: distinguishing event sources / multiple widget instances

2012-01-20 Thread kovas boguta
Hi David,

Setting aside the data binding aspect of the problem for a minute..

jQuery, Dojo and other JS libs seem to be going all-in on the event
delegation paradigm.

The idea is: instead of binding event handlers to each individual
instance, you let the events bubble up to the top of the document, and
then have a single mechanism that matches the [event, eventsource]
tuple to the desired function.  In effect it allows elements to
inherit the dom handlers appropriate to them.

The advantages of this are: 1) Performance (no need to attach copies
of the same handler everywhere; more opportunities for JITing
optimizations) and 2) Code simplification (since adding new elements
does not require also attaching their event handlers) .

The core matching part seems up the logic/predicate dispatch alley.
Extending this kind of event-handling to data binding (for for example
having the matched tuple be [event, eventsource,
corresponding-model-data] ) might be a way to get at the problem.


On Wed, Jan 18, 2012 at 1:21 PM, David Nolen dnolen.li...@gmail.com wrote:
 On Tue, Jan 17, 2012 at 10:08 PM, kovas boguta kovas.bog...@gmail.com
 wrote:

 Pretty basic question here.

 Suppose I want to have 2 copies of the form in the same application.

 How will the event handlers know which form the events are coming
 from, and which form needs to be modified in response to those events?

 More generally, what if I have N copies of some widget that all have
 the same structure, but different instance data. For example, a list
 of tweets, where each tweet has favorite button.

 My current impression is that I'd have to architect the event routing
 myself, making sure some distinguishing ID is carried around
 throughout.

 Is this accurate?

 What is the recommended way to handle this situation?

 Thanks,
 Kovas


 I think it's an open question on how to best solve this problem. There have
 been many, many approaches to binding the UI to the data layer.
 ClojureScript One's dispatch approach is very interesting, but it might need
 something like efficient predicate dispatch to scale.

 It's worth looking at complex binding solutions like Cocoa Bindings and
 simple binding UI / data binding projects like Backbone.js or Ember.js to
 see how much progress there is to be made in this space.

 If people have other suggestion of things to look at, speak up.

 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

-- 
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: Clojurescript One: distinguishing event sources / multiple widget instances

2012-01-20 Thread David Nolen
On Fri, Jan 20, 2012 at 6:06 PM, kovas boguta kovas.bog...@gmail.comwrote:

 Hi David,

 Setting aside the data binding aspect of the problem for a minute..

 jQuery, Dojo and other JS libs seem to be going all-in on the event
 delegation paradigm.


Yup event delegation is definitely the way to go.

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

Re: active jQuery ticket for ADVANCED_OPTIMIZATIONS

2012-01-20 Thread Dave Sann
nice!

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

confusing macro issue: java.lang.InstantiationException

2012-01-20 Thread drewn
I've been trying to write a macro to generate predicates from maps,
for instance the map {1 :one 2 :two} would define two predicates, one?
and two?  Here's the first part of the macro:

(defmacro make-predicate [keyword-pair]
  `(defn ~(symbol (str (name (nth (eval keyword-pair) 1)) ?)) [~'x]
 (= ~'x ~(nth (eval keyword-pair) 0

So far, so good (I'm using symbol capture because x is a bound
variable here anyway).  For instance:

(def nums {1 :one 2 :two})

(make-predicate (first nums))
#'user/one?

Now I try to use this macro on an entire map:

(defn make-predicates-from-map [keyword-map]
  (loop [kmap keyword-map]
(if (empty? kmap) nil
  (do
(make-predicate (first kmap))
(recur (rest kmap))

But this won't even compile: it gives a
java.lang.InstantiationException.

I guess this has something to do with keyword-map not being an actual
map yet at macroexpansion time.  Whether or not that's the problem,
how do you get around it?  I did try making the whole thing into a
macro:

(defmacro make-predicates-from-map [keyword-map]
  `(loop [kmap# ~keyword-map]
(if (empty? kmap#) nil
  (do
(macroexpand-1 (make-predicate (first kmap#)))
(recur (rest kmap#))

But this time I just get the InstantiationException when I run it.

-- 
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: clojure-clr loadpath points to D: harddrive

2012-01-20 Thread dmiller
It shouldn't, obviously.  It appears to be holding on to a compile-
time value somewhere.  I'll track it down this weekend.

-David


On Jan 19, 10:25 pm, jayvandal s...@ida.net wrote:
 Why does the clr point to d: work?
 user= (use :reload 'ui)
 FileNotFoundException Could not locate db.mysql.clj.dll or db/
 mysql.clj on load
 path.  clojure.lang.RT.load (d:\work\clojure-clr\Clojure\Clojure\Lib
 \RT.cs:3065)
 user=

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


clooj ot seeing output

2012-01-20 Thread jayvandal
I aam trying hello-seesaw tutorial in clooj. I don't see output or
screens as in running Leiningen. I trie adding all the commands
and didn't see any output, so I went back line by line and can't
see any screens.
What commands should I be using to see progres? I am still trying to
write Clojure code but  simple errors

-- 
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: confusing macro issue: java.lang.InstantiationException

2012-01-20 Thread Cedric Greevey
On Fri, Jan 20, 2012 at 9:54 PM, drewn naylor...@gmail.com wrote:
 I've been trying to write a macro to generate predicates from maps,
 for instance the map {1 :one 2 :two} would define two predicates, one?
 and two?

What's the use case for this?

(def one? #{1})
(def two? #{2})

isn't much worse. I suppose a macro to emit those might be useful,
though I'd probably put the fn-names first in each pair; something
like

(defmacro specific-thing-preds [ kvs]
  `(do ~@(map (fn [[k v]] `(def ~k #{~v})) (partition 2 kvs

(specific-thing-preds one? 1 two? 2)

-- 
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: confusing macro issue: java.lang.InstantiationException

2012-01-20 Thread drewn
Thank you, that works great!  It's a nice use of destructuring too,
which I should of thought of.

I guess this is one case where solving the problem in pieces does not
help.  Actually, I seem to remember seeing idioms like that for other
macros over sequences.  I understand a little more now why.

 What's the use case for this?

A map can be used as a function translating a numeric code to a
keyword (e.g., an event code).  There may be very large maps of this
type, but you might also want predicates to test whether something is
of a given type.  Might as well generate them from the map you already
have.

I modified your solution so it fits my use case:

(defmacro make-predicates [kvs]
  `(do ~@(map (fn [[v k]] `(defn ~(symbol (str (name k) ?)) [~'x] (=
~'x ~v))) (eval kvs

The eval is needed so I can pass in a variable, and I used the defn
form so I could get a regular true-false predicate.

Thanks for a great lesson on macros!

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