Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Stuart Campbell
On 2 May 2012 14:44, Baishampayan Ghose b.gh...@gmail.com wrote:

 You can't use `map` because `map` will return a sequence of the same
 size and that can blow your heap.


Isn't `map` lazy too?

Regards,
Stuart

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Sean Neilan
I don't think so.

On Wed, May 2, 2012 at 1:22 AM, Stuart Campbell stu...@harto.org wrote:

 On 2 May 2012 14:44, Baishampayan Ghose b.gh...@gmail.com wrote:

 You can't use `map` because `map` will return a sequence of the same
 size and that can blow your heap.


 Isn't `map` lazy too?

 Regards,
 Stuart

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread László Török
Map IS lazy but it still returns the entire realized sequence, as expected.
On May 2, 2012 8:31 AM, Sean Neilan s...@seanneilan.com wrote:

 I don't think so.

 On Wed, May 2, 2012 at 1:22 AM, Stuart Campbell stu...@harto.org wrote:

 On 2 May 2012 14:44, Baishampayan Ghose b.gh...@gmail.com wrote:

 You can't use `map` because `map` will return a sequence of the same
 size and that can blow your heap.


 Isn't `map` lazy too?

 Regards,
 Stuart

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Baishampayan Ghose
On Wed, May 2, 2012 at 12:01 PM, Sean Neilan s...@seanneilan.com wrote:
 I don't think so.

Of course it is. The problem is not in laziness, but in holding on to the head.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.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


Re: Pulling constants out of interfaces

2012-05-02 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Dienstag, 1. Mai 2012 20:17:21 UTC+2 schrieb Chris Perkins:


 I wouldn't put too much stock in what it says at clojure.org/reader - it 
 hasn't been updated in a long time. The implementation is probably a more 
 definitive definition of what characters are allowed.


In the past, Rich stated explicitely that the implementation is *not* a 
definition of what is allowed.

Kind regards,
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: Arithmethic Evaluation

2012-05-02 Thread Jim - FooBar();

On 02/05/12 04:19, Asranz wrote:

so i need some others functions to parse it and then just doing the
infix i guess?
basically you need to find a way to convert your string into a 
data-structure (a list) and then you can use a macro to rearrange things 
in any way you like...as long as it is a string you cannot do much 
unless you get down and dirty...


Jim

ps: i've got some useful macros on my website including one that 
transforms infix to prefix (lists)

check it out at www.cs.man.ac.uk/~piliourd/

--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


unicode support in clojurescript reader

2012-05-02 Thread Dave Sann
I needed unicode support for the clojurescript reader so I have made an 
attempt at adding it.

This works for me - but it is my first foray into changes to this source.

my commit is here 
https://github.com/davesann/clojurescript/commit/1f142d283959eead06ba0d00f9cba7fe3053d4a8

I have done the initial change in a relatively simple fashion.

I would appreciate if someone could review and make constructive comments 
as to changes that might need to be made.

if/when it passes scrutiny - I can submit a pull request or patch as 
required.

Cheers

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: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Allen Johnson
My example included a use of `map`. It is lazy and will work but you
have to be sure that you aren't using it in a way that would hold onto
the head of the sequence.

When experimenting in a repl it might not seem that it is lazy since
the repl will attempt to print the result of calling map when that is
the only expression.

AJ

On Wed, May 2, 2012 at 4:06 AM, Baishampayan Ghose b.gh...@gmail.com wrote:
 On Wed, May 2, 2012 at 12:01 PM, Sean Neilan s...@seanneilan.com wrote:
 I don't think so.

 Of course it is. The problem is not in laziness, but in holding on to the 
 head.

 Regards,
 BG

 --
 Baishampayan Ghose
 b.ghose at gmail.com

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Data vs API

2012-05-02 Thread Mark
I've read in some recent posts that Clorujians prefer data to APIs.  I'm 
not sure I understand what this means, in practice.  When I'm in the early 
stages of developing an application, the data structures undergo a great 
deal of change.  One of the ways, I isolate parts of the code from these 
sorts of changes is by writing accessor functions.  Maybe this is OO 
thinking but it seems to me a wise application of DRY.  

Would these accessor functions be considered an API?  If so, why should I 
prefer accessing the raw data structure?  If not, what is constitutes an 
API?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Data vs API

2012-05-02 Thread Baishampayan Ghose
 I've read in some recent posts that Clorujians prefer data to APIs.  I'm not
 sure I understand what this means, in practice.  When I'm in the early
 stages of developing an application, the data structures undergo a great
 deal of change.  One of the ways, I isolate parts of the code from these
 sorts of changes is by writing accessor functions.  Maybe this is OO
 thinking but it seems to me a wise application of DRY.

 Would these accessor functions be considered an API?  If so, why should I
 prefer accessing the raw data structure?  If not, what is constitutes an
 API?

Good question. Now drop everything and go watch this talk by Rich -

http://www.confreaks.com/videos/860-railsconf2012-keynote-simplicity-matters

I hope the talk will answer some of your questions, if you have some
more, feel free to ask this list :-)

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.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


Re: Data vs API

2012-05-02 Thread Raoul Duke
On Wed, May 2, 2012 at 7:03 AM, Mark markaddle...@gmail.com wrote:
 I've read in some recent posts that Clorujians prefer data to APIs.  I'm not
 sure I understand what this means, in practice.  When I'm in the early
 stages of developing an application, the data structures undergo a great
 deal of change.  One of the ways, I isolate parts of the code from these
 sorts of changes is by writing accessor functions.  Maybe this is OO
 thinking but it seems to me a wise application of DRY.

not clojure, but a lisp, and representative of the Great Divide.

http://lists.racket-lang.org/users/archive/2010-April/038935.html

:-)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Arithmethic Evaluation

2012-05-02 Thread Armando Blancas
Though I'm opposed to posting solutions to school assignments --in 
principle-- here's this little something in the hope that it might get you 
interested in lisp:

(defn value [e]
  (cond (number? e) e
(= (second e) '+) (+ (value (first e)) (value (nth e 2)))
(= (second e) '-) (- (value (first e)) (value (nth e 2)))
(= (second e) '*) (* (value (first e)) (value (nth e 2)))
(= (second e) '/) (quot (value (first e)) (value (nth e 2)

(defn e [s] (value (read-string s)))

Then you use (e) like so:
user= (e (1 + (2 * (4 * 5   
  
41

Function e converts the string into a list and calls function value with 
it. Function value accepts wither a number or a binary operation in a list 
and applies the corresponding operator to the operands. Since operands can 
themselves be operations, it calls itself recursively on the first and 
third elements of the list, which are the operands.

On Tuesday, May 1, 2012 8:19:04 PM UTC-7, Asranz wrote:

 oh please if u can teach me! 


 On 1 mayo, 21:29, Armando Blancas abm221...@gmail.com wrote: 
   i just need to evaluate in infix a string (1 +2 (4 * 5) 
  
  Check out The Little Schemer. It'll teach you the techniques for doing 
 this.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: apply a function to every item in a sequence without realizing the sequence

2012-05-02 Thread Michał Marczyk
Note also that in the REPL the last three values returned are kept
available under *1, *2 and *3.

M.


On 2 May 2012 15:40, Allen Johnson akjohnso...@gmail.com wrote:
 My example included a use of `map`. It is lazy and will work but you
 have to be sure that you aren't using it in a way that would hold onto
 the head of the sequence.

 When experimenting in a repl it might not seem that it is lazy since
 the repl will attempt to print the result of calling map when that is
 the only expression.

 AJ

 On Wed, May 2, 2012 at 4:06 AM, Baishampayan Ghose b.gh...@gmail.com wrote:
 On Wed, May 2, 2012 at 12:01 PM, Sean Neilan s...@seanneilan.com wrote:
 I don't think so.

 Of course it is. The problem is not in laziness, but in holding on to the 
 head.

 Regards,
 BG

 --
 Baishampayan Ghose
 b.ghose at gmail.com

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Data vs API

2012-05-02 Thread Stuart Sierra
The data *is* the API. Design the data structures you're going to accept  
return at all the public entry-points of your library or application. 
That's your API design.

It's kind of like web APIs returning JSON or XML: the structure of the data 
you get back is part of the contract.

-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

ClojureScript and Google Closure Type Annotations

2012-05-02 Thread Robert Stuttaford
Forgive me if this has been asked before.

I am writing a GClosure app at the moment (using the long-form java-style 
Google Closure javascript *blecch*), and I'm using JSDoc type-annotations 
for everything:

/** @type {number} */
var x = parseInt( data['foo'], 10 );

These annotations allow ADVANCED_MODE Closure compilation to type-check and 
also more tightly compress the resultant Javascript 'binary'. 

Looking at the size of the ClojureScript One production 'binary', it's 
187kb big.

I'm wondering if there's any plans or work underway to work on reducing 
this size, both in terms of having the ClojureScript backend include JSDoc 
style type annotations and in other ways?

Related question: 

As I already have a large GClosure codebase, I would like to use CLJS to 
build out the backend of this app, and bring the CLJS binary in as a module 
for my app to use.  I know I can export symbols in CLJS, and I'm guessing 
it can't be that hard to generate an externs.js containing all those 
exported symbols for use in my main app? If anyone is doing, this, please 
let me know how!

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

question with macro!

2012-05-02 Thread 金山
I defined a macro like this:
(defmacro randomly [ exprs]
  (let [len (count exprs)
ind (rand-int len)
conditions (map #(list '= ind %) (range len))]
`(cond ~@(interleave conditions exprs

and then defined a function :
(defn randomly-fn [ exprs]
 (randomly exprs))

I think there may be a mistake because of the randomly-fn didn't work
as expected.

(randomly-fn (print 1) (print 2) (print 3))

expected:
1 or 2 or 3.
but returned:
123

where is the mistake?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] Leiningen 2.0.0-preview3

2012-05-02 Thread adrians
I'm also getting this error, with same spec Windows but with Java 7. 
Unfortunately, I also get this with lein 1.7.1. Tried to build from source, 
but lein install generates a snapshot jar that only includes a few source 
files. Can anyone offer a solution to building your own lein?

Thanks,
Adrian

On Sunday, April 15, 2012 4:05:08 PM UTC-4, Niels wrote:

 lein new error under Windows 7 x64:

 lein version
 Leiningen 2.0.0-preview3 on Java 1.6.0_31 Java HotSpot(TM) 64-Bit Server VM

 lein new quiltest
 Generating a project called quiltest based on the 'default' template.
 java.lang.IllegalArgumentException: No implementation of method: 
 :make-reader of
  protocol: #'clojure.java.io/IOFactory found for class: nil
 at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:495)
 at clojure.java.io$fn__7795$G__7790__7802.invoke(io.clj:63)
 at clojure.java.io$reader.doInvoke(io.clj:96)
 at clojure.lang.RestFn.invoke(RestFn.java:410)
 at leiningen.new.templates$slurp_resource.invoke(templates.clj:29)
 at 
 leiningen.new.templates$renderer$fn__713.doInvoke(templates.clj:79)
 at clojure.lang.RestFn.invoke(RestFn.java:423)
 at leiningen.new.default$default.invoke(default.clj:15)
 at clojure.lang.Var.invoke(Var.java:401)
 at clojure.lang.AFn.applyToHelper(AFn.java:161)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.core$apply.invoke(core.clj:602)
 at leiningen.new$create.doInvoke(new.clj:54)
 at clojure.lang.RestFn.invoke(RestFn.java:425)
 at leiningen.new$create.invoke(new.clj:47)
 at clojure.lang.AFn.applyToHelper(AFn.java:161)
 at clojure.lang.RestFn.applyTo(RestFn.java:132)
 at clojure.core$apply.invoke(core.clj:600)
 at leiningen.new$new.doInvoke(new.clj:101)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.core$apply.invoke(core.clj:602)
 at leiningen.core.main$resolve_task$fn__699.doInvoke(main.clj:66)
 at clojure.lang.RestFn.applyTo(RestFn.java:139)
 at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
 at clojure.lang.RestFn.applyTo(RestFn.java:137)
 at clojure.core$apply.invoke(core.clj:602)
 at leiningen.core.main$apply_task.invoke(main.clj:88)
 at leiningen.core.main$_main$fn__731.invoke(main.clj:140)
 at leiningen.core.main$_main.doInvoke(main.clj:140)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.core$apply.invoke(core.clj:600)
 at clojure.main$main_opt.invoke(main.clj:323)
 at clojure.main$main.doInvoke(main.clj:426)
 at clojure.lang.RestFn.invoke(RestFn.java:457)
 at clojure.lang.Var.invoke(Var.java:413)
 at clojure.lang.AFn.applyToHelper(AFn.java:172)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.main.main(main.java:37)

 Op donderdag 12 april 2012 19:39:28 UTC+2 schreef Phil Hagelberg het 
 volgende:


 Hello folks.

 I'm happy to announce the release of the third preview of Leiningen 2.0.0.

 Highlights include the ability to show a full dependency tree a la mvn
 dependency:tree, a host of repl improvements, better offline support,
 and the ability to load lein new templates on-demand.

 * Add HTTP nREPL support for repl task via :connect option. (Chas Emerick,
   Phil Hagelberg)
 * Improve repl startup time, output consistency, Windows support. (Lee 
 Hinman,
   Colin Jones)
 * Stop using numeric exit codes for task failures.
 * Dynamically resolve unknown templates in new task.
 * Automatically activate offline profile when needed.
 * Honor $http_proxy environment variable. (Juergen Hoetzel)
 * Allow arbitrary :filespecs to be included in jars.
 * Let custom :prep-tasks be specified in project.clj.
 * Include :java-source-paths and dev/test deps in pom. (Nelson Morris)
 * Add offline profile.
 * Prevent project JVMs from outlasting Leiningen's process. (Colin Jones)
 * Update lein.bat to work with version 2. (Andrew Kondratovich)
 * Show a dependency tree in deps task. (Chas Emerick, Nelson Morris)
 * Support connecting to nrepl server in repl task. (Chas Emerick, Colin 
 Jones)
 * Pretty-print pom.xml. (Nelson Morris)
 * Display task aliases in help task. (Michael S. Klishin)
 * Only compile stale java source files. (Stephen C. Gilardi)
 * Respect :java-cmd in project.clj. (Michael S. Klishin)
 * Show progress when downloading search indices. (Justin Kramer)

 If you have an earlier preview version, you can pull this in via lein
 upgrade. If you only have Leiningen 1.x installed, you will have to
 download preview3 by hand:

 

Re: Data vs API

2012-05-02 Thread Raoul Duke
On Wed, May 2, 2012 at 12:27 PM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 The data *is* the API. Design the data structures you're going to accept 
 return at all the public entry-points of your library or application. That's
 your API design.

 It's kind of like web APIs returning JSON or XML: the structure of the data
 you get back is part of the contract.

hmm. entities can be represented in different ways, even with
different views of them, e.g. in REST, no? and with HATEOAS exposing
the actions in a context-sensitive way. and you need to define what
the REST HTTP action verbs mean for them. otherwise you just have
something more CRUDy than RESTy? (not that one can never desire CRUD.)
so design it seems would have to take into consideration both data and
behaviour, they are inter-twined, at least. of course one might wish
to pick one or the other as the starting off point for thinking about
the design.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Data vs API

2012-05-02 Thread kovas boguta
Can you give an example of how your data structure changes?

Getters and setters are only a problem when they come baked into your
datastructure, as the only way to access the contents.

If you require more custom getting/setting logic than the built-in
datastructures provide, you can always just write a function that does
something more complex, and pass the datastructure in as an argument.

Its useful to realize that in datastructures, complexity bubbles up,
and thus having simpler components makes your problem go away.

If your datastructure contains a bunch of components that themselves
have their own setters and getters, your datastructure needs to define
yet another pair of setters and getters because you need to abstract
away the variations in your components.

If the components all all just clojure maps, sets, and vectors, then
you don't have this problem of needing to account for all this
variation.


On Wed, May 2, 2012 at 10:03 AM, Mark markaddle...@gmail.com wrote:
 I've read in some recent posts that Clorujians prefer data to APIs.  I'm not
 sure I understand what this means, in practice.  When I'm in the early
 stages of developing an application, the data structures undergo a great
 deal of change.  One of the ways, I isolate parts of the code from these
 sorts of changes is by writing accessor functions.  Maybe this is OO
 thinking but it seems to me a wise application of DRY.

 Would these accessor functions be considered an API?  If so, why should I
 prefer accessing the raw data structure?  If not, what is constitutes an
 API?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from 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: question with macro!

2012-05-02 Thread Joop Kiefte
randomly-fn reads the commands first (that's why you need a macro in the
first place) so it prints 1 2 and 3 straight away. If you really need a
function, use lambdas (as in #(print 1) #(print 2) #(print 3))

2012/5/2 金山 si262...@gmail.com

 I defined a macro like this:
 (defmacro randomly [ exprs]
  (let [len (count exprs)
ind (rand-int len)
conditions (map #(list '= ind %) (range len))]
`(cond ~@(interleave conditions exprs

 and then defined a function :
 (defn randomly-fn [ exprs]
 (randomly exprs))

 I think there may be a mistake because of the randomly-fn didn't work
 as expected.

 (randomly-fn (print 1) (print 2) (print 3))

 expected:
 1 or 2 or 3.
 but returned:
 123

 where is the mistake?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: Data vs API

2012-05-02 Thread kovas boguta
A nice example of this in clojure is ring: https://github.com/mmcgrana/ring

The essence of it is what keys are present in the request/response
maps, laid out here

https://github.com/mmcgrana/ring/blob/master/SPEC


On Wed, May 2, 2012 at 3:27 PM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 The data *is* the API. Design the data structures you're going to accept 
 return at all the public entry-points of your library or application. That's
 your API design.

 It's kind of like web APIs returning JSON or XML: the structure of the data
 you get back is part of the contract.

 -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

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] Leiningen 2.0.0-preview3

2012-05-02 Thread Stuart Sierra
Just want to say thanks to Phil and everyone else who has contributed to 
Leiningen. It's been pleasing to see the evolution from a limited script to 
a solid development tool.
-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: [ANN] Leiningen 2.0.0-preview3

2012-05-02 Thread Jim - FooBar();

On 02/05/12 20:56, Stuart Sierra wrote:
Just want to say thanks to Phil and everyone else who has contributed 
to Leiningen. It's been pleasing to see the evolution from a limited 
script to a solid development tool.

-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 


(+ 10) !!!

Thanks Phil for such a wonderful tool... :)

--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: question with macro!

2012-05-02 Thread thomas
the arguments to randomly-fn are evaluated before the macro-expansion of 
randomly kicks in.
(that's what macros are for: control if, where and how often an expression is 
evaluated) 
So why would you need randomly-fn anyway?
You can just write 

randomly (print 1) (print 2) (print 3)) 

and this works. 


Am 02.05.2012 um 16:09 schrieb 金山:

 I defined a macro like this:
 (defmacro randomly [ exprs]
  (let [len (count exprs)
ind (rand-int len)
conditions (map #(list '= ind %) (range len))]
`(cond ~@(interleave conditions exprs
 
 and then defined a function :
 (defn randomly-fn [ exprs]
 (randomly exprs))
 
 I think there may be a mistake because of the randomly-fn didn't work
 as expected.
 
 (randomly-fn (print 1) (print 2) (print 3))
 
 expected:
 1 or 2 or 3.
 but returned:
 123
 
 where is the mistake?
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from 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


infix-to-prefix macro dead-end!!!

2012-05-02 Thread Jim - FooBar();

Hey everyone,

I've been trying all morning (more than 3 hours) to improve my macro but 
with little success...basically what I had before i started fiddling 
with it was a macro which would take an expression of the form (1 + 4 * 
5 - 1 /  2) and would return the expression in prefix form: (/ (- (* (+ 
1 4) 5) 1) 2)...it would not handle nested parens and no operator 
precedence...This is it:

---
(defmacro functionize [macro]
  `(fn [ args#] (eval (cons '~macro args#

(defmacro infix-to-prefix [expr]
(if-not (empty? (filter #(list? %))  '~expr))
(infix-to-prefix
   (map #(if (list? %)
 (apply (functionize infix-to-prefix) %) %) 'expr))
`(loop [
  ops#   (filter #(not (number? %)) '~expr)
  args#  (filter #(number? %) '~expr)
 ]
 (if (empty? ops#) (first args#)
 (let [[a# b#  more#] args#]
 (recur
 (rest ops#)
 (conj more#
 (list (first ops#) a# b#

;;usage : (infix-to-prefix (1 + 4 * 6))
;;= (* (1 + 4) 6)
--
I know for a fact that the bit after the back-quote works exactly as 
explained above...all the new code is above the back-quoted loop - recur 
form. all i'm trying to do is replace all the parens at each level with 
values calculated recursively using eval on the returned 
expressionHowever i can't seem to go any further...I am literally 
about to give up...I know this may not be necessarily the best approach 
but i 've worked hard on this  and  i want to see it succeed!


Any help is greatly appreciated...

Jim




--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Data vs API

2012-05-02 Thread Stuart Halloway
 I've read in some recent posts that Clorujians prefer data to APIs.  I'm not 
 sure I understand what this means, in practice.  When I'm in the early stages 
 of developing an application, the data structures undergo a great deal of 
 change.  One of the ways, I isolate parts of the code from these sorts of 
 changes is by writing accessor functions.  Maybe this is OO thinking but it 
 seems to me a wise application of DRY.  
 
 Would these accessor functions be considered an API?  If so, why should I 
 prefer accessing the raw data structure?  If not, what is constitutes an API?

(1) You always have to choose a representation for your data.

(2) Having chosen a data representation, if you make an accessor function API, 
you now have two representations. This is the very opposite of DRY. If you 
think that the representation implied by the accessor functions is better/more 
stable than the data representation, then choose a data representation like the 
one implied by your accessor functions.

(3) If you have helper functions for dealing with a particular representation, 
those helpers can and should be separate from the representation itself. For 
example, a customer order is some combination of maps, vectors, etc.  
totalPrice is never a member function of some accessor-riddled Order object -- 
it is instead a plain function that knows how to navigate a data representation 
(or, via a la carte polymorphism, many different representations).

Cheers,
Stu


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

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Aaron Cohen
On Wed, May 2, 2012 at 4:24 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

 Hey everyone,

 I've been trying all morning (more than 3 hours) to improve my macro but
 with little success...basically what I had before i started fiddling with
 it was a macro which would take an expression of the form (1 + 4 * 5 - 1 /
  2) and would return the expression in prefix form: (/ (- (* (+ 1 4) 5) 1)
 2)...it would not handle nested parens and no operator precedence...This is
 it:
 --**--**
 --**--**
 ---
 (defmacro functionize [macro]
  `(fn [ args#] (eval (cons '~macro args#

 (defmacro infix-to-prefix [expr]
 (if-not (empty? (filter #(list? %))  '~expr))


This looks suspicious. filter is being called with 1st parameter anon
function, and no second parameter. How does that compile?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 long polling questions

2012-05-02 Thread Daniel Renfer
I think your issue is, you say you want long polling, but it seems
like what you're looking for is more of HTTP streaming. The result
channel you get in the aleph handler is set up to receive only a
single message and then close. If you want a streaming response,
create a new channel and a request map with that channel as it's body.
Enqueue that response map into the result channel and then siphon the
the messages from your source channel to the body channel.

I've found that it's best / you need to put a newline between messages
so that the response will be properly flushed.

I'm pretty sure I don't need the future, but here's how I've done it.
https://github.com/duck1123/jiksnu/blob/8d66c34f1be8b0b29b0959a18cfdc315346c2bd2/src/jiksnu/actions/stream_actions.clj#L128

Hope that helps.

On Tue, May 1, 2012 at 7:17 AM, Dusan Miloradovic
dusan.milorado...@gmail.com wrote:
 Unfortunaltely that does not work either, thank you for the help. It stops
 receiving after the first message, just like before. Here is the updated
 version:

 (defn long-poll-newest
   ([url callback error-callback]
  (long-poll-newest  url callback error-callback (net/xhr-connection)))
   ([url callback error-callback xhr1]
  (do
    (event/listen xhr1
  :success
  (fn[e]
  (callback (. xhr1 (getResponseText)))
  (long-poll-newest  url callback error-callback
 xhr1)

  ))
    (event/listen xhr1
  :error
  (fn[e]
    (when error-callback
    (println entered the error callback)
    (error-callback e)
  )))
    (event/listen xhr1
  :timeout
  (fn[e]
  (long-poll-newest  url callback error-callback
 xhr1)
    ))
    (net/transmit xhr1 url

 Here is the working version with opening and closing of the connection on
 every call, at least it should not leak xhr connections:
 (defn long-poll
   ([url callback error-callback]
  (let [kk (net/xhr-connection)]
    (do
  (event/listen-once kk
     :complete
     (fn[e]
   (let [isSucc (. kk (isSuccess))
     ek (. kk (getLastErrorCode))
     isErr (or (= ek ec/EXCEPTION) (= ek
 ec/HTTP_ERROR))]
     (do
   (when isSucc
     (callback (. kk (getResponseText
   (. kk (dispose))
   (if isErr
     (error-callback e)
     (long-poll url callback error-callback))
   
  (net/transmit kk url)))
  ))

 Thx




 On Tue, May 1, 2012 at 2:17 PM, Gijs S. gijsstuur...@gmail.com wrote:

 The order of arguments you pass to long-poll-newest doesn't look
 right.

 You defined long-poll-newest to optionally take a fourth parameter for
 the existing xhr connection. However, when calling long-poll-newest
 you pass the existing xhr connection as the first argument.

 Replace
 (long-poll-newest xhr1 url callback error-callback)
 with
 (long-poll-newest url callback error-callback xhr1)

 Also, all of the (do ..)'s are unnecessary. 'let', 'fn' and 'when'
 evaluate the body in an implicit 'do' themselves.

 The overall approach to reuse the connection looks fine otherwise.

 -Gijs

 On Apr 30, 12:00 pm, Dusan dusan.milorado...@gmail.com wrote:
  I am trying to figure out how to setup the long polling from the
  clojurescript.
 
  I use aleph on the server side. Here is the trivial aleph handler and
  related code:
 
  (def k (permanent-channel))
 
  (receive-all k (fn[x] (println got  x)))
 
  (defn longpoll-new [ch request]
    (siphon k ch)
    )
 
  (defn send-mes [k mes]
    (enqueue k ((comp r/response pr-str) mes)))
 
  On the clojurescript side I am trying to open one xhr connection, and
  use
  it for all subsequent calls:
 
  (defn long-poll-newest
    ([url callback error-callback]
       (long-poll-newest  url callback error-callback
  (net/xhr-connection)))
    ([url callback error-callback xhr1]
       (do
         (event/listen xhr1
                       :success
                       (fn[e]
                         (do
                           (callback (. xhr1 (getResponseText)))
                           (long-poll-newest xhr1 url callback
  error-callback)
                           )))
         (event/listen xhr1
                       :error
                       (fn[e]
                         (when error-callback
                           (do
                             (println entered the error callback)
                   

Re: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Jim - FooBar();

On 02/05/12 21:33, Aaron Cohen wrote:


(if-not (empty? (filter #(list? %))  '~expr))


This looks suspicious. filter is being called with 1st parameter anon 
function, and no second parameter. How does that compile?


I apologise for the typo...it was originally (filter (fn [k] (list? k)) 
'~expr)
and i changed it to an anonymous function just for the email and forgot 
the closing paren of fn ...NIce catch!it should be:



(defmacro infix-to-prefix [expr]
(if-not (empty? (filter #(list? %)  '~expr))
(infix-to-prefix
   (map #(if (list? %)
 (apply (functionize infix-to-prefix) %) %) 'expr))
`(loop [
  ops#   (filter #(not (number? %)) '~expr)
  args#  (filter #(number? %) '~expr)
 ]
 (if (empty? ops#) (first args#)
 (let [[a# b#  more#] args#]
 (recur
 (rest ops#)
 (conj more#
 (list (first ops#) a# b#


--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: New release of Domina (now with reworked eventing)

2012-05-02 Thread David Nolen
Michal Marczyk submitted a patch - should be fixed in master.

David

On Sat, Apr 28, 2012 at 3:26 PM, Luke VanderHart
luke.vanderh...@gmail.comwrote:

 Yep, still happens against master.

 Trying to reduce it to a simpler test case now (and also see if it still
 happens when I take lein-cljsbuild out of the equation).


 On Saturday, April 28, 2012 1:29:07 PM UTC-4, David Nolen wrote:

 Which version of ClojurScript? Have you tried building against master?

 David

 On Sat, Apr 28, 2012 at 1:19 PM, Luke VanderHart 
 luke.vanderh...@gmail.com wrote:

 David,

 Yes. I've been looking at that today. Something is going on that is not
 so straightforward, though - I think there might be a compiler issue (or
 else I'm misunderstanding some aspect of the compiler).

 For example, I'm getting the warning on compiler-generated vars. e.g:

 WARNING: Use of undeclared Var domina.css/t7256 at line 14

 Still investigating (though if you happen to know what's going on,
 please let me know)


 On Friday, April 27, 2012 3:26:43 PM UTC-4, David Nolen wrote:

 lein-cljsbuild is now becoming the tool of choice for many CLJS devs.
 One thing I've noticed about domina is that it's not particularly careful
 about declaration order. This results in a spew of compiler warnings when
 building your project with domina. It would be nice to sprinkle the code
 with the necessary declares to eliminate these warnings.

 David

 On Fri, Apr 27, 2012 at 10:47 AM, Luke VanderHart wrote:

 Some of you may already be aware of of Domina, a jQuery-inspired DOM
 manipulation library I've been working on. It's been out there for a 
 while,
 but I just finished up a round of changes that I think bring it to a
 certain degree of completion for basic use (although there's definitely a
 lot of cool stuff that still remains to be added).

 Most notable is a new set of eventing functions; I hope they'll
 provide an easy-to-use, low-level foundation for building more complex
 data- and event-driven web applications.

 Please check it out: 
 https://github.com/levand/**domi**na/https://github.com/levand/domina/

 Feedback, pull request, etc. are welcome.

 Thanks!

 -Luke

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient
 with your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscribe@**googlegrou**ps.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group**/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Sam Ritchie
Hey Jim, what do you think of something like this?

(defmacro infix-prefix [form]
  (loop [[a op b  more :as form] form]
(if (not op)
  a
  (recur (cons (list op a b) more)

This transforms the list by plucking off three items at a time, rearranging
them into prefix notation then popping them back onto the list in the
recursion. When only one form's left inside the list, the macro returns
that form, passing it into the compiler. Here's an example expansion:

user (infix-prefix (1 * 2 + 3 - 6))
(1 * 2 + 3 - 6)
((* 1 2) + 3 - 6)
((+ (* 1 2) 3) - 6)
((- (+ (* 1 2) 3) 6))
-1

On Wed, May 2, 2012 at 1:24 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

 Hey everyone,

 I've been trying all morning (more than 3 hours) to improve my macro but
 with little success...basically what I had before i started fiddling with
 it was a macro which would take an expression of the form (1 + 4 * 5 - 1 /
  2) and would return the expression in prefix form: (/ (- (* (+ 1 4) 5) 1)
 2)...it would not handle nested parens and no operator precedence...This is
 it:
 --**--**
 --**--**
 ---
 (defmacro functionize [macro]
  `(fn [ args#] (eval (cons '~macro args#

 (defmacro infix-to-prefix [expr]
 (if-not (empty? (filter #(list? %))  '~expr))
 (infix-to-prefix
   (map #(if (list? %)
 (apply (functionize infix-to-prefix) %) %) 'expr))
 `(loop [
  ops#   (filter #(not (number? %)) '~expr)
  args#  (filter #(number? %) '~expr)
 ]
  (if (empty? ops#) (first args#)
 (let [[a# b#  more#] args#]
 (recur
 (rest ops#)
 (conj more#
 (list (first ops#) a# b#

 ;;usage : (infix-to-prefix (1 + 4 * 6))
 ;;= (* (1 + 4) 6)
 --**--**
 --**--**
 --
 I know for a fact that the bit after the back-quote works exactly as
 explained above...all the new code is above the back-quoted loop - recur
 form. all i'm trying to do is replace all the parens at each level with
 values calculated recursively using eval on the returned
 expressionHowever i can't seem to go any further...I am literally about
 to give up...I know this may not be necessarily the best approach but i 've
 worked hard on this  and  i want to see it succeed!

 Any help is greatly appreciated...

 Jim




 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en




-- 
Sam Ritchie, Twitter Inc
703.662.1337
@sritchie09

(Too brief? Here's why! http://emailcharter.org)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Alex Baranosky
Nice one Sam.  I think you could add order of operations by transforming
the form in multiple passes. First /, then *, then + and -.  Not the most
efficient solution but a start.

Alex

On Wed, May 2, 2012 at 6:14 PM, Sam Ritchie sritchi...@gmail.com wrote:

 Hey Jim, what do you think of something like this?

 (defmacro infix-prefix [form]
   (loop [[a op b  more :as form] form]
 (if (not op)
   a
   (recur (cons (list op a b) more)

 This transforms the list by plucking off three items at a time,
 rearranging them into prefix notation then popping them back onto the list
 in the recursion. When only one form's left inside the list, the macro
 returns that form, passing it into the compiler. Here's an example
 expansion:

 user (infix-prefix (1 * 2 + 3 - 6))
 (1 * 2 + 3 - 6)
 ((* 1 2) + 3 - 6)
 ((+ (* 1 2) 3) - 6)
 ((- (+ (* 1 2) 3) 6))
 -1

 On Wed, May 2, 2012 at 1:24 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

 Hey everyone,

 I've been trying all morning (more than 3 hours) to improve my macro but
 with little success...basically what I had before i started fiddling with
 it was a macro which would take an expression of the form (1 + 4 * 5 - 1 /
  2) and would return the expression in prefix form: (/ (- (* (+ 1 4) 5) 1)
 2)...it would not handle nested parens and no operator precedence...This is
 it:
 --**--**
 --**--**
 ---
 (defmacro functionize [macro]
  `(fn [ args#] (eval (cons '~macro args#

 (defmacro infix-to-prefix [expr]
 (if-not (empty? (filter #(list? %))  '~expr))
 (infix-to-prefix
   (map #(if (list? %)
 (apply (functionize infix-to-prefix) %) %) 'expr))
 `(loop [
  ops#   (filter #(not (number? %)) '~expr)
  args#  (filter #(number? %) '~expr)
 ]
  (if (empty? ops#) (first args#)
 (let [[a# b#  more#] args#]
 (recur
 (rest ops#)
 (conj more#
 (list (first ops#) a# b#

 ;;usage : (infix-to-prefix (1 + 4 * 6))
 ;;= (* (1 + 4) 6)
 --**--**
 --**--**
 --
 I know for a fact that the bit after the back-quote works exactly as
 explained above...all the new code is above the back-quoted loop - recur
 form. all i'm trying to do is replace all the parens at each level with
 values calculated recursively using eval on the returned
 expressionHowever i can't seem to go any further...I am literally about
 to give up...I know this may not be necessarily the best approach but i 've
 worked hard on this  and  i want to see it succeed!

 Any help is greatly appreciated...

 Jim




 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en




 --
 Sam Ritchie, Twitter Inc
 703.662.1337
 @sritchie09

 (Too brief? Here's why! http://emailcharter.org)

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: infix-to-prefix macro dead-end!!!

2012-05-02 Thread Jim - FooBar();
Hmm, it does look neater with destructuring i have to admit, but it 
won't handle nested parens will it? basically we 're doing the same 
thing -  mine is just more verbose and self-explanatory. what to do next 
though? how do you expose all nested parens to the reader and feed the  
result value back to the list in order to get the effect of 'parenthesis 
first'?


Jim

ps: btw thanks for your time :)


On 02/05/12 23:14, Sam Ritchie wrote:

Hey Jim, what do you think of something like this?

(defmacro infix-prefix [form]
  (loop [[a op b  more :as form] form]
(if (not op)
  a
  (recur (cons (list op a b) more)

This transforms the list by plucking off three items at a time, 
rearranging them into prefix notation then popping them back onto the 
list in the recursion. When only one form's left inside the list, the 
macro returns that form, passing it into the compiler. Here's an 
example expansion:


user (infix-prefix (1 * 2 + 3 - 6))
(1 * 2 + 3 - 6)
((* 1 2) + 3 - 6)
((+ (* 1 2) 3) - 6)
((- (+ (* 1 2) 3) 6))
-1

On Wed, May 2, 2012 at 1:24 PM, Jim - FooBar(); jimpil1...@gmail.com 
mailto:jimpil1...@gmail.com wrote:


Hey everyone,

I've been trying all morning (more than 3 hours) to improve my
macro but with little success...basically what I had before i
started fiddling with it was a macro which would take an
expression of the form (1 + 4 * 5 - 1 /  2) and would return the
expression in prefix form: (/ (- (* (+ 1 4) 5) 1) 2)...it would
not handle nested parens and no operator precedence...This is it:

---
(defmacro functionize [macro]
 `(fn [ args#] (eval (cons '~macro args#

(defmacro infix-to-prefix [expr]
(if-not (empty? (filter #(list? %))  '~expr))
(infix-to-prefix
  (map #(if (list? %)
(apply (functionize infix-to-prefix) %) %) 'expr))
`(loop [
 ops#   (filter #(not (number? %)) '~expr)
 args#  (filter #(number? %) '~expr)
]
 (if (empty? ops#) (first args#)
(let [[a# b#  more#] args#]
(recur
(rest ops#)
(conj more#
(list (first ops#) a# b#

;;usage : (infix-to-prefix (1 + 4 * 6))
;;= (* (1 + 4) 6)

--
I know for a fact that the bit after the back-quote works exactly
as explained above...all the new code is above the back-quoted
loop - recur form. all i'm trying to do is replace all the parens
at each level with values calculated recursively using eval on the
returned expressionHowever i can't seem to go any further...I
am literally about to give up...I know this may not be necessarily
the best approach but i 've worked hard on this  and  i want to
see it succeed!

Any help is greatly appreciated...

Jim




-- 
You received this message because you are subscribed to the Google

Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
mailto:clojure@googlegroups.com
Note that posts from new members are moderated - please be patient
with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
mailto:clojure%2bunsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en




--
Sam Ritchie, Twitter Inc
703.662.1337
@sritchie09

(Too brief? Here's why! http://emailcharter.org)

--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient 
with your first post.

To unsubscribe from 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

Interaction of map-R and AOT compilation

2012-05-02 Thread Edmund
Hi Folks,

   It seems that map-R returns different types in the presence/absence of 
AOT classes.  I have constructed a minimal example here:

https://github.com/ejackson/aotquestion

The namespace in 
https://github.com/ejackson/aotquestion/blob/master/src/aots/core.clj is 
not AOT compiled and behaves as expected.
The namespace 
in https://github.com/ejackson/aotquestion/blob/master/src/aots/death.clj#L9 
is AOT compiled and the class returned by map-Dontwork is not as expected. 
(Turn off AOT and this expression becomes true).

Am I misunderstanding something here or is this a bug ?  

I'd really appreciate some help and advice.

 Edmund

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] lein-license 0.1.0

2012-05-02 Thread Phil Hagelberg

Hello folks.

I just released a Leiningen plugin that walks your dependencies and
lists the licenses of each. You can see the output below.

This should be helpful for folks needing to do an audit on the licenses
of their projects before releasing. It gets license information from the
pom file, so if you maintain a project that doesn't have its license
exposed programmatically I encourage you to add it. Here's how it looks
using Leiningen in project.clj:

(defproject lein-licenses 0.1.0
  :description List the license of each of your dependencies.
  :url https://github.com/technomancy/lein-licenses;
  :license {:name Eclipse Public License
:url http://www.eclipse.org/legal/epl-v10.html}
  :eval-in-leiningen true)

Just adding a :license map with a :name is enough, but it's best to link
to the full license text with a :url as well.

-Phil

$ lein licenses # in the leiningen-core library
nekohtml/xercesMinimal - Unknown
org.apache.maven.wagon/wagon-http - The Apache Software License, Version 2.0
org.sonatype.aether/aether-connector-file - Eclipse Public License, Version 
1.0
classlojure - Unknown
org.codehaus.plexus/plexus-interpolation - The Apache Software License, 
Version 2.0
org.sonatype.sisu/sisu-inject-bean - The Apache Software License, Version 
2.0
org.codehaus.plexus/plexus-component-annotations - The Apache Software 
License, Version 2.0
org.codehaus.plexus/plexus-utils - The Apache Software License, Version 2.0
commons-logging - The Apache Software License, Version 2.0
com.cemerick/pomegranate - Eclipse Public License 1.0
org.apache.maven/maven-model-builder - The Apache Software License, Version 
2.0
org.clojure/tools.macro - Eclipse Public License 1.0
org.sonatype.aether/aether-util - Eclipse Public License, Version 1.0
nekohtml - Apache License
org.apache.maven/maven-aether-provider - The Apache Software License, 
Version 2.0
org.sonatype.aether/aether-api - Eclipse Public License, Version 1.0
org.apache.maven.wagon/wagon-http-shared - The Apache Software License, 
Version 2.0
commons-codec - /*
org.clojure/clojure - Eclipse Public License 1.0
org.codehaus.plexus/plexus-classworlds - The Apache Software License, 
Version 2.0
org.sonatype.aether/aether-impl - Eclipse Public License, Version 1.0
org.sonatype.sisu/sisu-guice - Apache License
robert/hooke - Unknown
org.apache.maven/maven-repository-metadata - The Apache Software License, 
Version 2.0
org.sonatype.aether/aether-spi - Eclipse Public License, Version 1.0
commons-httpclient - Apache License
useful - Unknown
org.apache.maven/maven-model - The Apache Software License, Version 2.0
org.apache.maven.wagon/wagon-provider-api - The Apache Software License, 
Version 2.0
org.sonatype.aether/aether-connector-wagon - Eclipse Public License, 
Version 1.0
org.sonatype.sisu/sisu-inject-plexus - Eclipse Public License, Version 1.0
ordered - Unknown

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 handle dependencies on multiple versions of the same library?

2012-05-02 Thread Andy Fingerhut
I haven't actually run across this before, but I suspect someone else has.  I 
was curious how people handle it.

Suppose you have your project A, and it uses Leiningen (the issue is more 
widely applicable, but for the sake of example).

* A depends on some version of library B, which in turn depends on library Z 
version 2
* A also depends on some version of library C, which in turn depends on library 
Z version 3

Simple case 1:  B also works with Z v3, so update its dependency, use Z v3, and 
everything works.  (similarly easy if Z v2 works for C)

Hard case: B only works with Z v2, and C only works with Z v3.

Is there a straightforward way to load in both versions of Z to a single JVM, 
and make everything work?

Perhaps this is the kind of situation that Gradle, OSGi, and probably other 
tools/frameworks are meant to help address?

Thanks,
Andy

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Data vs API

2012-05-02 Thread Takahiro
 I've read in some recent posts that Clorujians prefer data to APIs.  I'm not
 sure I understand what this means, in practice.  When I'm in the early
 stages of developing an application, the data structures undergo a great
 deal of change.  One of the ways, I isolate parts of the code from these
 sorts of changes is by writing accessor functions.  Maybe this is OO
 thinking but it seems to me a wise application of DRY.

 Would these accessor functions be considered an API?  If so, why should I
 prefer accessing the raw data structure?  If not, what is constitutes an
 API?

I think Rich's comments in an interview with Fogus is helpful.
http://www.codequarterly.com/2011/rich-hickey/

Fogus: Following that idea—some people are surprised by the fact that
Clojure does not engage in data-hiding encapsulation on its types. Why
did you decide to forgo data-hiding?
Hickey: Let’s be clear that Clojure strongly emphasizes programming to
abstractions. At some point though, someone is going to need to have
access to the data. And if you have a notion of “private”, you need
corresponding notions of privilege and trust. And that adds a whole
ton of complexity and little value, creates rigidity in a system, and
often forces things to live in places they shouldn’t. This is in
addition to the other losing that occurs when simple information is
put into classes. To the extent the data is immutable, there is little
harm that can come of providing access, other than that someone could
come to depend upon something that might change. Well, okay, people do
that all the time in real life, and when things change, they adapt.
And if they are rational, they know when they make a decision based
upon something that can change that they might in the future need to
adapt. So, it’s a risk management decision, one I think programmers
should be free to make.
If people don’t have the sensibilities to desire to program to
abstractions and to be wary of marrying implementation details, then
they are never going to be good programmers.

2012/5/2 Mark markaddle...@gmail.com:
 I've read in some recent posts that Clorujians prefer data to APIs.  I'm not
 sure I understand what this means, in practice.  When I'm in the early
 stages of developing an application, the data structures undergo a great
 deal of change.  One of the ways, I isolate parts of the code from these
 sorts of changes is by writing accessor functions.  Maybe this is OO
 thinking but it seems to me a wise application of DRY.

 Would these accessor functions be considered an API?  If so, why should I
 prefer accessing the raw data structure?  If not, what is constitutes an
 API?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from 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: Leiningen-noobie question

2012-05-02 Thread Larry Travis

Phil:
I now can't get the behavior to reproduce either.  I have no idea what 
kind of dumb mistake I was making in the first place, and I'm very sorry 
to have wasted your time. (For what it's worth, both dependency-vector 
versions work in my reproduction attempts -- but you probably already 
knew that they would!)

  --Larry




On 5/1/12 11:22 AM, Phil Hagelberg wrote:

On Mon, Apr 30, 2012 at 9:28 PM, Larry Travistra...@cs.wisc.edu  wrote:

Phil, Neale, Sean:
You guys are all way ahead of me as to why I am getting the results I am
getting, but it is only Neale's advice that works.  That is

[prjctOne/prjctOne 1.0.0-SNAPSHOT]   works, but


[prjctOne 1.0.0-SNAPSHOT]  does not.

Interesting. I've never seen that behaviour before; it sounds like a bug.

I'm trying to reproduce this problem here but am unable to. Can you
provide steps to reproduce it locally? What version of Leiningen is
this?

-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


How to handle dependencies on multiple versions of the same library?

2012-05-02 Thread kurtharriger
OSGI is one way to solve this problem, but it is rarely worth the effort.  It 
requires adding lots of meta data to every dependency which only a few major 
libraries actually provide. There are some tools to help with this process but 
they dont generally work with dynamic languages.  Honestly, unless you know 
someone that has significant experience with OSGi, you will spend far more time 
trying to get everything working under OSGi than it would take to update the 
library with the old dependency to work with the latest version of the shared 
dependency - providing of course the source is available, and one of the 
reasons I avoid closed source libraries whenever possible.  Even still running 
multiple versions of the same jar in osgi is still not ideal and can cause 
other issues.  You can also implement you own classloaders, which is basically 
how OSGi is implemented, but much less painful then OSGi.

Gradle is just a build tool, it will basically just select the newest version 
of the shared dependency.  It will not help them coexist.

If updating the library is not an option or to overwelming, then the next best 
thing is to create a seperate application for the old library and use ipc of 
some sort such as a rest api to allow the libraries to collaberate yet live in 
separate jvms.  

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


what is js/ in clojurescript?

2012-05-02 Thread Rob
Hi,

Syntax like this doesn't work in normal Clojure, right?

js/document.body.style

It just did in a ClojureScript repl.  Is there something magic about js/ 
?  What is it?

thanks,
Rob

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: what is js/ in clojurescript?

2012-05-02 Thread Tamreen Khan
A quick explanation is that functions/other javascript objects that
otherwise exist in the global namespace (ie. document, console, window) are
accessed through the js/ in Clojurescript. This is a JS-specific thing and
therefore you don't find js/ in regular Clojure.

However, doing the form (MyClass/MyStaticMethod arg1 arg2 ...) *does* exist
in Clojure. It's a way of calling static Java methods or accessing static
fields. See  http://clojure.org/java_interop for more info.

On Thu, May 3, 2012 at 12:12 AM, Rob rob.nikan...@gmail.com wrote:

 Hi,

 Syntax like this doesn't work in normal Clojure, right?

 js/document.body.style

 It just did in a ClojureScript repl.  Is there something magic about js/
 ?  What is it?

 thanks,
 Rob

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: question with macro!

2012-05-02 Thread Qiu Xiafei
all function arguments will be evaluated  so, 123 was printed

On Thu, May 3, 2012 at 4:06 AM, thomas thomas.ka...@googlemail.com wrote:

 the arguments to randomly-fn are evaluated before the macro-expansion of
 randomly kicks in.
 (that's what macros are for: control if, where and how often an expression
 is evaluated)
 So why would you need randomly-fn anyway?
 You can just write

 randomly (print 1) (print 2) (print 3))

 and this works.


 Am 02.05.2012 um 16:09 schrieb 金山:

  I defined a macro like this:
  (defmacro randomly [ exprs]
   (let [len (count exprs)
 ind (rand-int len)
 conditions (map #(list '= ind %) (range len))]
 `(cond ~@(interleave conditions exprs
 
  and then defined a function :
  (defn randomly-fn [ exprs]
  (randomly exprs))
 
  I think there may be a mistake because of the randomly-fn didn't work
  as expected.
 
  (randomly-fn (print 1) (print 2) (print 3))
 
  expected:
  1 or 2 or 3.
  but returned:
  123
 
  where is the mistake?
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your first post.
  To unsubscribe from 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: what is js/ in clojurescript?

2012-05-02 Thread Rob


On Thursday, May 3, 2012 12:17:03 AM UTC-4, Tamreen Khan (Scriptor) wrote:


 However, doing the form (MyClass/MyStaticMethod arg1 arg2 ...) *does* 
 exist in Clojure. It's a way of calling static Java methods or accessing 
 static fields. See  http://clojure.org/java_interop for more info.


Okay.  It seems like normal Clojure the thing after the slash can't have 
more '.' characters in it, so I'm wondering if that's the extend of the 
difference.  Maybe that difference is not on purpose.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Using dynamic variables in libraries [Re: ANN clojure.java.jdbc 0.2.0]

2012-05-02 Thread Sean Corfield
Sorry for the slow response - we've been wrapped up in a gigantic data
migration at work...

On Tue, May 1, 2012 at 4:26 AM, Wolodja Wentland babi...@gmail.com wrote:
 It certainly does, but I am none the wiser. I always had the 
 feeling/impression
 that dynamic variables are something to be avoided, but I see them frequently
 in Clojure code I read and therefore have the impression that they are the
 right thing to do™ in a couple of instances.

I think the problem is that good Clojure style is still evolving and
a lot of the libraries were started a while ago before the no dynamic
variables guideline really took hold. That's to be expected in a new
and evolving language.

I don't think clojure.java.jdbc is a very good example of idiomatic
Clojure now but I'm sure it was considered good practice when it was
originally built. I just looked at our codebase at work and the only
things we have that are dynamic are:
* global debug flags (set false, which can be rebound for specific
call trees as needed)
* global vars that defined external integration points (which can be
rebound to test against other integration points: dev / test / prod,
for example)

I could probably reduce those further but five variables out of 4kloc
production code doesn't seem bad (and a couple of those are primarily
for mocking end points for testing - where I could use with-redefs, to
be honest).

 How would you, for example, implement the logging example I quoted above? What
 about handling global configuration (config files, CLI options, ..) ?

Logging is probably a good example because you don't want to have to
pass flags thru your code (that's similar to what we do with our debug
flags). For command line options, I would explicitly pass the map thru
the code because I think that's cleaner in most cases. That said, for
environmental configuration at World Singles, we have a delayed map
for our environment settings and we require/refer that directly into
code that needs it, e.g.,

(let [s @env/my-settings]
  ... (:some-value s) ...)

Neither a dynamic variable nor something passed thru the code.
-- 
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


In clojurescript (extend-protocol undefined ...) should be error?

2012-05-02 Thread Rob
This should probably throw something, right?

 (extend-protocol undefined js/Text (foo [x] x))

I had mis-typed the name of the protocol and I didn't get an error until 
later.

( Is it helpful to post things like this here? I'm trying out Clojurescript 
and I can post possible bugs as I find them, or not ... whatever you 
developers prefer.  I don't know enough Clojure to be fixing them myself 
yet. )

Rob

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Leiningen-noobie question

2012-05-02 Thread Sean Corfield
On Wed, May 2, 2012 at 5:44 PM, Larry Travis tra...@cs.wisc.edu wrote:
 I now can't get the behavior to reproduce either.  I have no idea what kind
 of dumb mistake I was making in the first place, and I'm very sorry to have
 wasted your time. (For what it's worth, both dependency-vector versions work
 in my reproduction attempts -- but you probably already knew that they
 would!)

That makes me feel better because I couldn't understand why my
suggestion didn't work :)

Glad it's working for you now - welcome to the wonderful world of Leiningen!
-- 
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