Re: Help me improve and/or simplify this code

2012-02-22 Thread Meikel Brandmeyer (kotarak)
Salut Laurent,

yes. That's probably even better.

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: Help me improve and/or simplify this code

2012-02-22 Thread Meikel Brandmeyer (kotarak)
Salut Laurent,

that's a good remark. Collecting and exporting of constants were conflated 
in the previous version. So I added another API call: exported-constants. 
Usually this are just the ones collected from the child nodes. But for ::fn 
it's always empty.

; From your other mail
(defn processor
  [pre post]
  (fn this [form]
(let [form (pre form)
  form (maybe recursive? update-children form this)]
  (post form

(defmulti exported-constants :op)

(defmethod exported-constants :default
  [form]
  (:constants form))

(defmethod exported-constants ::fn
  [_]
  #{})

(defmulti collect-constants :op)

(defmethod collect-constants :default
  [form]
  form)

(defmethod collect-constants ::constant
  [form]
  (assoc form :constants #{(:form form)}))

(defmethod collect-constants ::recursive
  [{:as form :keys [children]}]
  (- children
(map exported-constants)
(reduce into #{})
(assoc form :constants)))

((processor set-unbox collect-constants) {:op ::fn :children [{:op ::let 
:children [{:op ::constant :form 1} {:op ::fn :children [{:op ::constant 
:form 2}]}]}]})
; = {:constants #{1}, :op :user/fn, :children ({:constants #{1}, :unbox 
false, :op :user/let, :children ({:constants #{1}, :unbox true, :op 
:user/constant, :form 1} {:constants #{2}, :unbox true, :op :user/fn, 
:children ({:constants #{2}, :unbox true, :op :user/constant, :form 2})})})}

Note how the nested ::fn collects constants from its children but doesn't 
export it to its parent without the need of a filter on parent level.

Never ask such things on the list; a discussion about simplified examples 
may arise. ;) But hopefully the discussion is helpful for Aaron in his 
endeavour.

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: Help me improve and/or simplify this code

2012-02-22 Thread Cedric Greevey
If I may venture an opinion here: aren't some people over-thinking and
maybe even gold-plating this? My own version is succinct, and moreover
when the requirements were changed/clarified it required only changing
a single constants to [] in a single spot in a single line of code
to adjust it.

YAGNI, folks. *If and when* you need multimethods and other
complications rather than condp etc. sufficing, due to evolving
requirements, then elaborate. Until then, do the simplest thing that
works. :)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Help me improve and/or simplify this code

2012-02-22 Thread Laurent PETIT
2012/2/22 Cedric Greevey cgree...@gmail.com

 If I may venture an opinion here: aren't some people over-thinking and
 maybe even gold-plating this? My own version is succinct, and moreover
 when the requirements were changed/clarified it required only changing
 a single constants to [] in a single spot in a single line of code
 to adjust it.

 YAGNI, folks. *If and when* you need multimethods and other
 complications rather than condp etc. sufficing, due to evolving
 requirements, then elaborate. Until then, do the simplest thing that
 works. :)


Peace :)



 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 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: clj-webdriver: Clojure API for Selenium-WebDriver

2012-02-22 Thread Tavis Rudd
Daniel,
Thanks again for the effort you've put into documentation and release
communication. It's first rate.
Tavis

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Lack in the documentation

2012-02-22 Thread John Gabriele
On Feb 20, 3:05 pm, Sean Corfield seancorfi...@gmail.com wrote:
 On Mon, Feb 20, 2012 at 1:48 AM, Sergey Didenko

 sergey.dide...@gmail.com wrote:

  It looks like our community already has a lot of articles, tutorials,
  gists, but they are just not very reachable to beginners.
 
  May be what we really need is a meta site or article on clojure.org or
  promotion of other meta site like
 http://stackoverflow.com/questions/tagged/clojure, with a lot of
  community rated links to existing resources?

 Folks could contribute tohttp://dev.clojure.org/display/doc/Home(I
 believe you need a CA on file and someone has to update your
 Confluence account permissions) but I believe this is the official hub
 for community-contributed documentation...

Looking at clojure.org, I'd just assumed that the central community-
driven documentation is the wiki ( 
http://en.wikibooks.org/wiki/Clojure_Programming
), which appears to include http://en.wikibooks.org/wiki/Learning_Clojure
(why is it a separate wikibook?).

A issue that all communities face though, is that some authors prefer
to write their own articles and blog posts, rather than update and
fine-tune the central community doc. It's understandable, since
everyone has their own style (and their own favorite markup format)
and it's also nice to get recognition for your very own linked-to and
possibly-popular article/blog-post vs. shared authorship of a wiki
book.

As an aside, my hunch is that it may be easier to get folks to
contribute to the wikibooks rather than contribute to
http://dev.clojure.org/display/doc/Home --- partly because the wiki
seems more familiar and easier to navigate compared to the Confluence
site. Also, if the Confluence site requires a signed contributor
agreement on-file, I'd bet that inhibits folks who just wanted to
clarify a sentence, fix some grammar, add a small example, etc.

Regarding a Clojure cookbook, I don't see any reason why it should be
separate from the main community-driven wiki.

So, my guess is that a good solution would be:

1. have one central wiki that the community is encouraged to monitor
and contribute to (the 2 wikibooks?),

2. expand the wiki's cookbook section (possibly split it out into
multiple sub-pages), and

3. have a page on that wiki that keeps a community-curated,
categorized, and (important!) dated list of useful external articles
(perhaps even roughly sorted by date --- newest at the top).

I've gone ahead and created an [External Articles](http://
en.wikibooks.org/wiki/Clojure_Programming/External_Articles) page on
the main wiki. If you've got any favorite articles and/or blog posts
that you think would be useful to others, please add them (creating
category sections for them as needed).

---John

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


clojure thesis opportunity

2012-02-22 Thread Paolo Negri
Dear list,

In the company where I work [1] we have an opening for a thesis
project involving clojure, I’m posting the abstract proposal on this
list since some reader might be interested.

Here’s some information about the thesis

Games configurations are structured collections of connected data
represented by documents that drive game logic execution.
Configurations need to be easily edited by non technical staff and
then rendered in a variety of machine readable formats like xml, json
or code.

The topic of this thesis is to research the suitability of S-
expression as primary representation format of game configurations and
a lisp dialect as a primary mean of modifying, analysing, validating
and converting configurations. The explicit intent is to take
advantage of homoiconicity. Focus of the thesis is to assess and
demonstrate advantages deriving by the adoption of S-expression and
clojure versus the XML + XSD + OO programming language tool chain
usually adopted to deal with this kind of tasks.

Within this project a clojure (server component) and clojurescript
(client component) application will be developed.
The application will internally represents configurations as S-
expression while offering an intuitive UI that will enable non
technical user to edit configuration data while enforcing formal
correctness by applying quantitative and logic constraints and
exporting configurations in other formats. As an advanced task
compilation of configurations to code in a destination programming
language could be considered.

The thesis will be developed on site in our office in Berlin, you’ll
be embedded in a game team and mentored by one engineer. If you’re
interested in this project you can contact me directly
paolo.ne...@wooga.com or write to a...@wooga.com with the reference
“GSE clojure”

[1] Wooga is the third largest social game developer on facebook,
every day 9 million persons play one or more of our games. If you’re
curious about the company you can check our website http://www.wooga.com,
our github page https://github.com/wooga or you can take a look at our
engineering conference talks http://www.slideshare.net/wooga/tag/backend

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: mcache 0.1.0 released

2012-02-22 Thread DHM
On Feb 21, 5:58 am, Jim Crossley jcrossl...@gmail.com wrote:
 DHM davidhmar...@gmail.com writes:
  I want to announce the release of mcache 0.1.0:
 https://github.com/davidhmartin/mcache

 Very nice. One thing you might consider is implementing
 core.cache/CacheProtocol [1] in terms of mcache. I've done this [2] for
 the Infinispan data grid in Immutant. It'd be great to see another
 distributed option for pluggable memoization.

 Jim

 [1]https://github.com/clojure/core.cache
 [2]https://github.com/immutant/immutant/blob/master/modules/cache/src/ma...

Thanks, I'll take a look at that.

-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: mcache 0.1.0 released

2012-02-22 Thread David Martin
I had looked at that but it wouldn't be a good candidate for forking in
this case, because the approaches are different. Clojure-memcached talks to
the low-level memcached api via socket connections, whereas mcache uses the
spymemcached Java library via java interop.

-Dave



On Mon, Feb 20, 2012 at 8:20 PM, Leonardo Borges 
leonardoborges...@gmail.com wrote:

 There's this one: https://github.com/shughes/clojure-memcached

 It's two years old so definitely out of date but maybe worth forking?

 Cheers,
 Leonardo Borges
 www.leonardoborges.com


 On Sun, Feb 19, 2012 at 12:14 PM, DHM davidhmar...@gmail.com wrote:

 Hi,

 I want to announce the release of mcache 0.1.0:
 https://github.com/davidhmartin/mcache

 This provides protocol-based support for memcached and memcached-like
 clients, with an implementation using spymemcached.

 I coded this up in support of a web site I'm developing. I didn't find
 much in the way of existing clojure-based memcached support. I assume
 this is because it's easy enough to use the java apis directly, but it
 seemed like there can still be a benefit to putting a wrapper around
 these and adding some higher-level functionality.
 This initial version provides functions for add, set, replace, get,
 and incr/decr, plus a couple of additional functions supporting the
 caching of data fetched from a persistent store.

 I'm quite new to Clojure, so any feedback or suggestions of better
 ways to do things are more than welcome.

 Thanks!

 -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

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

2012-02-22 Thread Adrian Mowat
Hi David

That worked a treat.  Thanks!

Adrian

On Feb 21, 4:55 am, David Nolen dnolen.li...@gmail.com wrote:
 for creates lazy sequences - this can be a problem if you need side
 effects. I suggest using doseq instead.

 David

 On Mon, Feb 20, 2012 at 11:26 AM, Adrian Mowat adrian.mo...@gmail.comwrote:







  Hi Everyone,

  I have been coding clojure for a few months and I've just started
  using clojurescript and I am struggling to use for forms inside event
  handlers.  Sorry if this is covered elsewhere but I have searched as
  best I can without finding the answers.

  I have an event handler that listens for changes in an input element

  (def search-input (dom/get-element search))
  (def test-area (dom/get-element test-area))
  (event/listen search-input
   :keyup
   (fn [e]
     (let [search-results [a b]]
       (dom/append test-area (dom/element :p {} (first search-
  results)))
       (dom/append test-area (dom/element :p {} (second search-
  results))

  It works fine.  Everytime I type in the input box, some text is
  appended to 'test-area'

  However, this doesn't work any more when I switch to using for

  (event/listen search-input
   :keyup
   (fn [e]
     (let [search-results [a b]]
       (for [x search-results] (dom/append test-area (dom/element :p {}
  x))

  Stepping through the generated code, I noticed that the generated
  javascript calls the function with null as the first argument (second
  last line below) but I can't figure out why or how to change the
  behaviour.

  clojure.browser.event.listen.call(null,
  smws_numbers.cljs.smws_numbers.search_input, \ufdd0'keyup,
  function() {
   return function b(c) {
     return new cljs.core.LazySeq(null, !1, function() {
       for(;;) {
         if(cljs.core.truth_(cljs.core.seq.call(null, c))) {
           var d = cljs.core.first.call(null, c);
           return cljs.core.cons.call(null,
  clojure.browser.dom.append.call(null,
  smws_numbers.cljs.smws_numbers.test_area,
  clojure.browser.dom.element.call(null, \ufdd0'p,
  cljs.core.ObjMap.fromObject([], {}), d)), b.call(null,
  cljs.core.rest.call(null, c)))
         }
         return null
       }
     })
   }.call(null, cljs.core.Vector.fromArray([a, b]))
  });

  I fell sure I'm missing something fairly basic, but it's escaping me
  for now so any help you can provide would be greatly appreciated.

  Many Thanks

  Adrian

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


Trouble using the fetch Clojurescript library.

2012-02-22 Thread James Sofra
hi,

I am putting together a small Clojurescript project and trying out Chris 
Granger's library, fetch.

I can call functions defined in the fetch.util namespace no problem but 
when ever I try and use things defined in the fetch.remotes namespace it 
fails.

The compilation is successful but the browser spits an error saying that 
the function in fetch.remotes is undefined.

Anyone got any ideas?

here is the namespace imports, second one work, first doesn't

  (:require [fetch.remotes :as fr])
  (:use [fetch.util :only [clj-js]])

Here is a sample of my project.clj file

(defproject my-proj 1.0.0-SNAPSHOT
  :description FIXME: write description
  :dependencies [[org.clojure/clojure 1.3.0]
 [noir 1.3.0-alpha10]
 [seesaw 1.3.1-SNAPSHOT]
 [jayq 0.1.0-SNAPSHOT]
 [fetch 0.1.0-SNAPSHOT]]
  :cljsbuild [{:source-path src
   :crossovers [proj.core]
   :compiler {:output-dir resources/public/js
  :output-to resources/public/js/my_proj.js
  :externs [resources/externs/highcharts.js]
  :optimizations :simple
  :pretty-print false}}])

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

Compilation model

2012-02-22 Thread T.Y Chew


Hi all,

I had a question about clojure's compilation model, which my co-worker
suggest to redirect here :-)

I wonder what clojure does during compilation of a file? Can
side-effects occur (definition of variables, functions, macros, etc in
the compiler)? Does clojure have an EVAL-WHEN construct for specifying
compile-time evaluations, or is there a convention for splitting code
across different source files? And then, how does this tie in to a
module system?

Thanks in advance for any information or references :-)

Yong


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

2012-02-22 Thread Chip Collier
You, sir, are doing it right! Thanks for posting this. :)


On 2/20/12 7:09 PM, Chris Granger wrote:
 People have been asking for an example using Noir and CLJS for a
 while, so today I threw together a recording and a blog post of me
 building an iPad controller for overtone :)

 HN link: http://news.ycombinator.com/item?id=3615022
 Post: http://www.chris-granger.com/2012/02/20/overtone-and-clojurescript/

 Cheers,
 Chris.





signature.asc
Description: OpenPGP digital signature


Re: MacOS menu bar time tracker in Clojure

2012-02-22 Thread number 23
it is cool

On Tue, Feb 21, 2012 at 04:12, Philip K p...@eleven-percent.at wrote:

 Hey,

 I just made a text file based menu bar timer tracker as a weekend
 project in Clojure. It allows for easy task management using your
 favorite text editor, easy prioritization, time tracking and easy
 Dropbox integration; it doesn't scale well beyond a single person, but
 for small projects it may be a good alternative.

 If anybody wants to take a look, here is the repo:
 https://github.com/pkamenarsky/atea

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




-- 
https://twitter.com/number23_cn

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Trouble using the fetch Clojurescript library.

2012-02-22 Thread James Sofra
Sorry for the noise, this is working now. Really not sure what the problem 
was.
Either I am misunderstanding something or the compilation process is a 
bit flaky.

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

Re: Help me improve and/or simplify this code

2012-02-22 Thread Softaddicts
 love ?


 2012/2/22 Cedric Greevey cgree...@gmail.com
 
  If I may venture an opinion here: aren't some people over-thinking and
  maybe even gold-plating this? My own version is succinct, and moreover
  when the requirements were changed/clarified it required only changing
  a single constants to [] in a single spot in a single line of code
  to adjust it.
 
  YAGNI, folks. *If and when* you need multimethods and other
  complications rather than condp etc. sufficing, due to evolving
  requirements, then elaborate. Until then, do the simplest thing that
  works. :)
 
 
 Peace :)
 
 
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  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
--
Softaddictslprefonta...@softaddicts.ca sent by ibisMail!

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Help me improve and/or simplify this code

2012-02-22 Thread Laurent PETIT
2012/2/22 Softaddicts lprefonta...@softaddicts.ca

  love ?


I will always love you, Luc :-D




  2012/2/22 Cedric Greevey cgree...@gmail.com
 
   If I may venture an opinion here: aren't some people over-thinking and
   maybe even gold-plating this? My own version is succinct, and moreover
   when the requirements were changed/clarified it required only changing
   a single constants to [] in a single spot in a single line of code
   to adjust it.
  
   YAGNI, folks. *If and when* you need multimethods and other
   complications rather than condp etc. sufficing, due to evolving
   requirements, then elaborate. Until then, do the simplest thing that
   works. :)
  
 
  Peace :)
 
 
  
   --
   You received this message because you are subscribed to the Google
   Groups Clojure group.
   To post to this group, send email to clojure@googlegroups.com
   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
 --
 Softaddictslprefonta...@softaddicts.ca sent by ibisMail!

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 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: Help me improve and/or simplify this code

2012-02-22 Thread Aaron Cohen
On Wed, Feb 22, 2012 at 6:51 AM, Laurent PETIT laurent.pe...@gmail.com wrote:


 2012/2/22 Cedric Greevey cgree...@gmail.com

 If I may venture an opinion here: aren't some people over-thinking and
 maybe even gold-plating this? My own version is succinct, and moreover
 when the requirements were changed/clarified it required only changing
 a single constants to [] in a single spot in a single line of code
 to adjust it.

 YAGNI, folks. *If and when* you need multimethods and other
 complications rather than condp etc. sufficing, due to evolving
 requirements, then elaborate. Until then, do the simplest thing that
 works. :)


 Peace :)

I learned a lot from both solutions, thanks again to both. :)

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

2012-02-22 Thread Raju Bitter
This might interest you, it's not Clojure, but Lisp. Do you know the
online game Vendetta? They  have used Lisp extensively for non-player
character behavior, and have a REPL integrated into the game.
http://www.vendetta-online.com
Vendetta Online has a Lisp environment (using SBCL) which controls
much of its NPC behavior and will soon be in charge of generating
player and NPC missions. Partly in order to get around some
thread-safety issues, and partly for convenience we built an REPL into
a secret chat channel. (it only responds to developer accounts)
http://www.a1k0n.net/2005/11/04/lisp-repl-vendetta-online.html

Later they started using Erlang in combination with Lisp since they
had some problems with concurrency and garbage collection in SBCL.
http://www.vendetta-online.com/x/msgboard/1/15560#196333

 We chose common lisp primarily for its rapid-prototyping capabilities. In CL, 
 it is very easy to
 define 'mini-languages', which is what I've done for missions, objectives, 
 senses, reflexes,
 state-machines, business-models and more. All the code written in these 
 special languages
 will remain untouched, and be auto-translated (by CL code) into erlang. As I 
 develop new
 missions, reflexes, etc, I will continue to use the mini-languages; the 
 processes they describe
  will simply be running on a distributed, fault-tolerant, erlang-based 
 platform instead of the
  simplistic single-threaded one they have been running on. We had hoped for 
 the simplistic
  system to continue to serve for a while yet, so that we could focus on 
 player-visible
 features, but we always knew it would need to be made more scalable at some 
 point.
 If you know of a 'more mainstream (/debugged/tested/reliable)' 
 language/runtime than erlang that provides:

   1) *very* light-weight processes
   2) distributed, message-passing concurrency;
   3) unification/pattern-matching
   4) a soft-real-time, distributed, disk and/or ram-based relational/object 
 database usable
   with or without transactions (just a few of mnesia's features),
   5) facilities for zero-downtime code-upgrades, and other high-availability 
 features
 6) a powerful enough set of semantics (eg. closures) to make auto-translation 
 from lisp less painful than a complete rewrite

- Raju

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Help me improve and/or simplify this code

2012-02-22 Thread Cedric Greevey
You're 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


Re: clojure thesis opportunity

2012-02-22 Thread Cedric Greevey
Erlang's actor model seems like a perfect fit to MMORPG development --
maybe even more so than Lisp.

On the other hand, Lisp letting you update things on the fly is also
of obvious value to an MMORPG, which tends to involve adding and
tweaking stuff from time to time but you really don't want to take the
game servers down, ever, if you can avoid 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 thesis opportunity

2012-02-22 Thread Timothy Baldridge
 On the other hand, Lisp letting you update things on the fly is also
 of obvious value to an MMORPG, which tends to involve adding and
 tweaking stuff from time to time but you really don't want to take the
 game servers down, ever, if you can avoid it.

That's also a major feature of Erlang. On-the-fly code updating is
actually one of its strengths.

http://en.wikipedia.org/wiki/Erlang_(programming_language)#Hot_code_loading_and_modules


That being said, the syntax of Erlang is so insanely bad, I can't
bring myself to touch it.

Timothy

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

2012-02-22 Thread Andy Fingerhut
I haven't written such code myself, but one motivation for creating Erlang was 
software for telecommunications systems, where they have very high uptime 
requirements and needed the ability to update code on a running system.  It can 
replace definitions of functions in place as well as any Lisp.

Andy

On Feb 22, 2012, at 8:37 AM, Cedric Greevey wrote:

 Erlang's actor model seems like a perfect fit to MMORPG development --
 maybe even more so than Lisp.
 
 On the other hand, Lisp letting you update things on the fly is also
 of obvious value to an MMORPG, which tends to involve adding and
 tweaking stuff from time to time but you really don't want to take the
 game servers down, ever, if you can avoid 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

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

2012-02-22 Thread Cedric Greevey
On Wed, Feb 22, 2012 at 11:40 AM, Timothy Baldridge
tbaldri...@gmail.com wrote:
 On the other hand, Lisp letting you update things on the fly is also
 of obvious value to an MMORPG, which tends to involve adding and
 tweaking stuff from time to time but you really don't want to take the
 game servers down, ever, if you can avoid it.

 That's also a major feature of Erlang. On-the-fly code updating is
 actually one of its strengths.

 http://en.wikipedia.org/wiki/Erlang_(programming_language)#Hot_code_loading_and_modules


 That being said, the syntax of Erlang is so insanely bad, I can't
 bring myself to touch it.

Sounds like what we need is a Lisp with the actor model. Ideally,
Clojure with a distributed version of agents, maybe built on top of
agents and Java's RMI.

Then again, what you said about Erlang's syntax lots of people say
about Lisp's. ;)

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

2012-02-22 Thread Adam
Have you looked at Akka http://akka.io/ at all?

~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: clojure thesis opportunity

2012-02-22 Thread Cedric Greevey
On Wed, Feb 22, 2012 at 12:08 PM, Adam les...@gmail.com wrote:
 Have you looked at Akka at all?

Looks like it's a Java library. Using it apparently involves a fair
amount of subclassing, so we'd probably want to write at least a
partial clojure wrapper instead of users having to write proxy this,
reify that all over their code. :)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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 travis-ci.org, a hosted CI service for the open source community with first class Clojure support

2012-02-22 Thread Chas Emerick

On Feb 21, 2012, at 5:44 PM, Phil Hagelberg wrote:

 Michael Klishin michael.s.klis...@gmail.com writes:
 
 travis-ci.org is a hosted continuous integration system for the open
 source community. It started in the Ruby community in 2011; since
 then, it has grown to support Erlang, Clojure, Node.js, PHP, Java,
 Groovy, and Scala, and now hosts over 6000 projects, including some
 big names like Ruby on Rails, RubyGems, Bundler, Leiningen, parts of
 JRuby, Node.js, Rubinius and so on.
 
 We've been using Travis for Leiningen and it's been quite useful.
 Looking forward to seeing where it goes from here.

Seconded.  I started using it with Clutch a few months ago, joyfully.  The 
build pass/fail badges are particularly nice (you can see one @ 
https://github.com/clojure-clutch/clutch), as they give potential new users of 
libraries a clear indication of the health and sanity of the project.

All in all, a much more pleasant and productive experience than mucking about 
with hudson/jenkins.

- Chas

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


Clojure training in Europe/UK??

2012-02-22 Thread Urckle
I'm interested in taking some hands-on, training in Clojure. Is there
anyone in Europe that offers such public training courses?

thanks in advance.

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

2012-02-22 Thread Eduardo Bellani
Perhaps SXML could help the writer a bit

http://en.wikipedia.org/wiki/SXML

On 02/21/2012 02:55 PM, Paolo Negri wrote:
 Dear list,
 
 In the company where I work [1] we have an opening for a thesis 
 project involving clojure, I’m posting the abstract proposal on
 this list since some reader might be interested.
 
 Here’s some information about the thesis
 
 Games configurations are structured collections of connected data 
 represented by documents that drive game logic execution. 
 Configurations need to be easily edited by non technical staff and 
 then rendered in a variety of machine readable formats like xml,
 json or code.
 
 The topic of this thesis is to research the suitability of S- 
 expression as primary representation format of game configurations
 and a lisp dialect as a primary mean of modifying, analysing,
 validating and converting configurations. The explicit intent is to
 take advantage of homoiconicity. Focus of the thesis is to assess
 and demonstrate advantages deriving by the adoption of S-expression
 and clojure versus the XML + XSD + OO programming language tool
 chain usually adopted to deal with this kind of tasks.
 
 Within this project a clojure (server component) and clojurescript 
 (client component) application will be developed. The application
 will internally represents configurations as S- expression while
 offering an intuitive UI that will enable non technical user to
 edit configuration data while enforcing formal correctness by
 applying quantitative and logic constraints and exporting
 configurations in other formats. As an advanced task compilation of
 configurations to code in a destination programming language could
 be considered.
 
 The thesis will be developed on site in our office in Berlin,
 you’ll be embedded in a game team and mentored by one engineer. If
 you’re interested in this project you can contact me directly 
 paolo.ne...@wooga.com or write to a...@wooga.com with the
 reference “GSE clojure”
 
 [1] Wooga is the third largest social game developer on facebook, 
 every day 9 million persons play one or more of our games. If
 you’re curious about the company you can check our website
 http://www.wooga.com, our github page https://github.com/wooga or
 you can take a look at our engineering conference talks
 http://www.slideshare.net/wooga/tag/backend
 


-- 
Eduardo Bellani

omnia mutantur, nihil interit.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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 training in Europe/UK??

2012-02-22 Thread Stuart Sierra
Yes!  Luke VanderHart and I will be teaching a 3-day Clojure course at 
EuroClojure in May.

http://euroclojure.com/2012/3-day-clojure-training/

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

options for a function

2012-02-22 Thread Michael
clojure.data.csv has options for the following:

(defn write-csv
  Writes data to writer in CSV-format.

   Valid options are
 :separator (Default \\,)
 :quote (Default \\\)
 :guote? (A predicate function which determines if a string should
be quoted. Defaults to quoting only when necessary.)
 :newline (:lf (default) or :cr+lf)
  [writer data  options]
  (let [opts (into {} options)
separator (or (:separator opts) \,)
quote (or (:quote opts) \)
quote? (or (:quote? opts) #(some #{separator quote \return
\newline} %))
newline (or (:newline opts) :lf)]
snip

Since (into {} options) is used to get the options into a map, it
seems that you need to specify options in this (write-csv writer data
[:separator \;] [:newline :lf+cr]).

Is this the recommended way to offer options? I was expecting (write-
csv writer data :separator \; :newline :lf+cr).


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: options for a function

2012-02-22 Thread Mark Rathwell
I don't know that there is necessarily a recommended way to offer
options.  Sometimes people want keyword options, sometime the want to
take options as a map, sometimes they need to do it one way or another
for various reasons, sometime they do it one way and later learn of a
better way.

To take options in the way you have specified, you can use
destructuring to simplify:

(defn write-csv [writer data  {:as opts}] ...)
  - or -
(defn write-csv [writer data  {:keys [separator quote ...]}] ...)
  - or -
(defn write-csv [writer data  {:keys [separator quote ...] :as opts}] ...)


On Wed, Feb 22, 2012 at 3:47 PM, Michael michael-a...@db.com wrote:
 clojure.data.csv has options for the following:

 (defn write-csv
  Writes data to writer in CSV-format.

   Valid options are
     :separator (Default \\,)
     :quote (Default \\\)
     :guote? (A predicate function which determines if a string should
 be quoted. Defaults to quoting only when necessary.)
     :newline (:lf (default) or :cr+lf)
  [writer data  options]
  (let [opts (into {} options)
        separator (or (:separator opts) \,)
        quote (or (:quote opts) \)
        quote? (or (:quote? opts) #(some #{separator quote \return
 \newline} %))
        newline (or (:newline opts) :lf)]
 snip

 Since (into {} options) is used to get the options into a map, it
 seems that you need to specify options in this (write-csv writer data
 [:separator \;] [:newline :lf+cr]).

 Is this the recommended way to offer options? I was expecting (write-
 csv writer data :separator \; :newline :lf+cr).


 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 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: Help me improve and/or simplify this code

2012-02-22 Thread Cedric Greevey
It occurs to me that a simpler no-library-needed way to get something
like actors in Clojure would be to just send forms over the network to
other nodes.

The simplest thing would be to send forms to *eval*. But that requires
some serious security precautions. Like, say, authentication plus
encryption of the links.

Another thing would be to set up an agent server which receives
forms the reader can read. These would *not* be sent to eval; instead,
just passed through the reader (with read-eval false to close a
possible security hole) and then (apply send-off (map my-resolve
form)). The first element of the form should, therefore, name an agent
on the target node; the next, a function that exists in the namespace
where the agent server is in that node; and optional arguments to that
function. If the nodes all share a common codebase then the defs and
defns will be the same, including the defs of agents and the defns of
functions to invoke them on.

The my-resolve function is a tricky detail: it needs to resolve
symbols to Vars and leave everything else alone, a kind of weak
eval.

This could still be maliciously misused, by triggering arbitrary
actions by arbitrary actors (enabling cheating in games, for instance)
and by sending lots of CPU-heavy requests as a denial of service
attack. Authentication and encryption would still be a good idea here,
but not using full eval on the traffic adds another layer of
protection. Someone who cracks the encryption can cheat at your MMORPG
but not send, say, (System/exec rm -rf /). (Not running the nodes as
root provides still more damage limitation, of course.)

Also, handing the guys that might want to cheat the decryption key
would be stupid, so this protocol would obviously be used internally
by the server (a distributed network of game hosting machines) with
some other, much less generally-capable protocol between these and
clients to limit the possibilities for cheating using a nonstandard
client. (Things analogous to client-side gold-farming bots or
super-reflex-equipped combat bots will always be possible, of course.
There's no in-principle way to be sure it's carbon rather than silicon
sitting in the player's chair, other than if commands are sent
absurdly fast. Even 24/7 farming for weeks without letup could be
humans working in shifts.)

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

2012-02-22 Thread Paolo Negri

On Feb 22, 6:00 pm, Cedric Greevey cgree...@gmail.com wrote:
 On Wed, Feb 22, 2012 at 11:40 AM, Timothy Baldridge

 tbaldri...@gmail.com wrote:
  On the other hand, Lisp letting you update things on the fly is also
  of obvious value to an MMORPG, which tends to involve adding and
  tweaking stuff from time to time but you really don't want to take the
  game servers down, ever, if you can avoid it.

  That's also a major feature of Erlang. On-the-fly code updating is
  actually one of its strengths.

 http://en.wikipedia.org/wiki/Erlang_(programming_language)#Hot_code_l...

  That being said, the syntax of Erlang is so insanely bad, I can't
  bring myself to touch it.

 Sounds like what we need is a Lisp with the actor model. Ideally,
 Clojure with a distributed version of agents, maybe built on top of
 agents and Java's RMI.

 Then again, what you said about Erlang's syntax lots of people say
 about Lisp's. ;)

Thanks everyone for the interesting replies and pointers to other
resources.

I find pretty intriguing that erlang and the actors came up in this
thread since we already do write game backend in erlang and we
reported reported regularly about our experience at conferences [1],
[2], [3].
Indeed the actor pattern is a very effective way of modeling game
servers and the erlang OTP framework offers out of the box with tools
and constructs that simplify dealing with the complexity of a
multitude of concurrently evolving states.

Still, the topic of this thesis is not really focused on game servers
but about improving how games are configured, balancing the values
that drive the evolution and progresse in virtual words is a very
interesting and complex task, configurations appears as naked data but
they actively drive the execution of many aspects of games, in some
way you might think about configuration as a form of execution plan
game logic, this is why having configuration in a form that can be
interpreted both as data and code is of special interest.
Another interesting aspect is that in our erlang game server we take
XML configurations files and generate code (each XML file is compiled
into an erlang module) so our servers effectively are configured by
code, not data, this also make it easier to upgrade configurations on
a running system thanks to the erlang hot code reload facilities,
changin configuration actually mean running a newer version of the
configuration code.

I'm looking forward to your comments and ideas on the topic.

[1] http://www.slideshare.net/wooga/from-0-to-100-daily-users-with-erlang
[2] http://www.erlang-factory.com/conference/London2011/speakers/PaoloNegri
[3] http://www.erlang-factory.com/conference/SFBay2011/speakers/PaoloNegri

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


Re: options for a function

2012-02-22 Thread Sean Corfield
This seems like a bug in clojure.data.csv and someone should create a
JIRA ticket for it, perhaps with a patch?

http://dev.clojure.org/jira/browse/DCSV

This once again makes me question why this CSV library ended up in
contrib (without any discussion) rather than the more actively
maintained and widely used clojure-csv library by David Santiago -
https://github.com/davidsantiago/clojure-csv

On Wed, Feb 22, 2012 at 1:17 PM, Mark Rathwell mark.rathw...@gmail.com wrote:
 I don't know that there is necessarily a recommended way to offer
 options.  Sometimes people want keyword options, sometime the want to
 take options as a map, sometimes they need to do it one way or another
 for various reasons, sometime they do it one way and later learn of a
 better way.

 To take options in the way you have specified, you can use
 destructuring to simplify:

 (defn write-csv [writer data  {:as opts}] ...)
  - or -
 (defn write-csv [writer data  {:keys [separator quote ...]}] ...)
  - or -
 (defn write-csv [writer data  {:keys [separator quote ...] :as opts}] ...)


 On Wed, Feb 22, 2012 at 3:47 PM, Michael michael-a...@db.com wrote:
 clojure.data.csv has options for the following:

 (defn write-csv
  Writes data to writer in CSV-format.

   Valid options are
     :separator (Default \\,)
     :quote (Default \\\)
     :guote? (A predicate function which determines if a string should
 be quoted. Defaults to quoting only when necessary.)
     :newline (:lf (default) or :cr+lf)
  [writer data  options]
  (let [opts (into {} options)
        separator (or (:separator opts) \,)
        quote (or (:quote opts) \)
        quote? (or (:quote? opts) #(some #{separator quote \return
 \newline} %))
        newline (or (:newline opts) :lf)]
 snip

 Since (into {} options) is used to get the options into a map, it
 seems that you need to specify options in this (write-csv writer data
 [:separator \;] [:newline :lf+cr]).

 Is this the recommended way to offer options? I was expecting (write-
 csv writer data :separator \; :newline :lf+cr).

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


clojure.java.jmx 0.1 - problem getiing java.lang:type=Threading :AllThreadIds attribute

2012-02-22 Thread zoka
I was trying to convert result of JMX attributes query to JSON, and
encountered  problem while reading one particular attribute value of
java.lang:type=Threading. Here is the REPL transcript:

demo.server= (require '[clojure.java.jmx :as jmx])
nil
demo.server= (jmx/read  java.lang:type=Threading :AllThreadIds)
#long[] [J@1bd97d0d
demo.server=

This seems to be Java long array reference,

The jmx/mbean function that returns all attribute name as keywords
associated with their values carries this value through. Attempt to
convert such map to JSON string  causes exception, since in this case
a clojure vector of longs would be expected instead of Java array.

This particular piece information (list of application ThreadIs) is
not of particular interest to me anyway, so it is easy just to remove
the offending map entry as a workaround.

I have noticed some recent activity in clojure.java.jmx github repo,
so I thought it would be appropriate to rise this issue, since it may
be affecting some other attributes as well.

Regards
Zoka

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: options for a function

2012-02-22 Thread Jonas
I'll fix this today. 

Thanks,
Jonas

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: options for a function

2012-02-22 Thread Jonas
I just pushed the fix to github and released version 0.1.2. Sorry for the 
inconvenience.

I'm not really happy with the write part of data.csv. In the clojure spirit 
of simplicity it complects quoting of values with writing to disk. There 
might be different policies for when an api-user wants there values to be 
quoted:

* Quote everything (this can be done by setting :quote? to (constantly true)
* Quote nothing (this can be done by setting :quote? to (constantly false))
* Quote only when necessary (this is the default)
* Quote only the first row (i.e,, header)
* Quote (for example) the first and third column
* etc.

I thought about this a couple of days ago and the best I could come up with 
was to remove quoting from the writing part and have users quote there 
values as a pre-processing step before writing. If that is the way forward 
then there is almost nothing more to do in the writing part of the 
data.csv, e.g., you could just as well write

(with-open [w (io/writer some-file)]
  (with-binding [*out* w]
(doseq [row data] 
  (println (string/join , row)))

So It's not entirely clear to me if csv-write is needed at all and instead 
have a few helper functions, for example (quote-string s \'), together with 
a good description of how to use with-binding, doseq, str/join etc. in the 
README file.

Ideas welcome.

Jonas




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