ANN: cljs-info 1.0.0 Help and reflection facilities for ClojureScript

2012-10-18 Thread Frank Siebenlist
cljs-info is a collection of Clojure-functions to provide basic help and 
reflection facilities for ClojureScript.

Some of the functions provided are:

cljs-doc, cljs-doc*, cljs-find-doc, cljs-apropos, cljs-source

cljs-ns-map, cljs-ns-publics, cljs-ns-refers, cljs-ns-aliases, 
cljs-ns-privates, 
cljs-ns-interns, cljs-ns-resolve, cljs-all-ns, cljs-find-ns, cljs-the-ns

cljs-repl, js-repl

Note that all those fns run on the clojure side of the fence and are not 
cljs-functions!
I've tried to explain why in the README. In short, clojurescript development 
is a somewhat schizophrenic process dealing with the split-personality of your 
clojurescript's virtual-world(s)… ;-).

For details see: https://github.com/franks42/cljs-info;

The README has more info about install, usage, and the what, where and how.

Suggestions  comments are very welcome - This is version 1.0 and a work in 
progress.

Enjoy, FrankS.

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

2012-10-18 Thread Alex Ott
Hi Brian

Which books had you read? I found that Clojure Programming provides
many useful tips on how organize code, etc.

On Thu, Oct 18, 2012 at 5:51 AM, Brian Craft craft.br...@gmail.com wrote:
 I'm finding the books on clojure to be very focused on low-level language
 features. Are there any good references for how to design code in clojure
 (or perhaps in functional languages more generally)? For example, knowing
 when to use a data type or a protocol, knowing when and how to separate
 purely functional code from code with side effects, making use of monads,
 queues, and the other forms that one hears about in the forums, etc.

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



-- 
With best wishes,Alex Ott
http://alexott.net/
Twitter: alexott_en (English), alexott (Russian)
Skype: alex.ott

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

2012-10-18 Thread Stathis Sideris
One thing that you might be missing is the expressive power of the sequence 
handling functions (everything under sequences here: 
http://clojure.org/cheatsheet ). I found it very useful to follow a few 
other users in 4clojure [1] which allowed me to compare different styles in 
their solutions while I was solving the problems. In many cases I was 
humbled by discovering a half-line solution when I my solution was 5-6 
lines! So there is some poetry there I think.

Stathis

[1] http://www.4clojure.com/


On Wednesday, 17 October 2012 19:14:59 UTC+1, Curtis wrote:

 I do hope this is an appropriate topic. 

 I am very excited by the power and capability in clojure and amazed at the 
 rapid quality of tooling that exists so early in the projects life.

 I would like to admit that i am feeling like the simplicity and elegance 
 that I experienced writing in lisp seems to be bypassed in certain areas in 
 favor of extra syntax [] and what seems to be local variable declarations
 as well as 'many ways' to do something around looping and recursion.

 I am wondering how others feel about this and if there are any style 
 guides that i could be exposed to so that I can enjoy the poetry that I may 
 be missing. 

 Could some one help me with this please?

 Thank you!

 Curtis


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

2012-10-18 Thread Mauricio Aldazosa
Congrats!

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

UTF-8 behavior ClojureScript (vs. Clojure)

2012-10-18 Thread Henrik Mohr
Hi there!

I'm wondering why ClojureScript seems to handle international characters 
differently from Clojure.

Simple example in Clojure (= my preferred behaviour):
user= (str ø)
ø

The same example in ClojureScript:
ClojureScript:cljs.user   #_= (str 'ø')
\xF8'

Can anyone explain to me why ClojureScript behaves like that?

I need to send strings from ClojureScript to a remote service, so I need 
the output from ClojureScript to be straight UTF-8 encoded strings.

Because when the (Clojure based) remote service receives the string from 
ClojureScript it doesn't decode it correctly with read-string:
Exception: java.lang.RuntimeException: Unsupported escape character: \x

Anyone?

Thanks.

Best regards,
Henrik

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

2012-10-18 Thread Angel Java Lopez
Hi people!

I just cloned the current clojurescript repo, in a Windows 2008 server
machine, and follow the instructions:
https://github.com/clojure/clojurescript/wiki/Windows-Setup
https://github.com/clojure/clojurescript/wiki/Quick-Start

But when I run .\script\repl.bat and tried (require '[cljs.repl :as repl]),
a FileNotFoundException raised:

 this is the java VM with calculated CLASSPATH
C:\Git\clojurescriptjava -server -cp
c:\Git\clojurescript\src\clj;c:\Git\clojurescript\src\cljs;c:\Git\clojurescript\lib\clojure-1.3.0-beta1.jar;c:\Git\clojurescript\lib\compiler.jar;c:\Git\clojurescript\lib\goog.jar;c:\Git\clojurescript\lib\guava-13.0.1.jar;c:\Git\clojurescript\lib\js.jar
clojure.main
Clojure 1.3.0-beta1
user= (require '[cljs.repl :as repl])
FileNotFoundException Could not locate clojure/instant__init.class or
clojure/instant.clj on classpath:   clojure.lang.RT.load (RT.java:430)

My lib folder
10/18/2012  08:24 AM 3,398,424 clojure-1.3.0-beta1.jar
10/18/2012  08:28 AM 5,856,710 compiler.jar
10/18/2012  08:27 AM 3,711,975 goog.jar
10/18/2012  08:28 AM 1,891,110 guava-13.0.1.jar
10/18/2012  08:30 AM 1,122,370 js.jar

Any clues? Some month ago, I run the repl with success. But now, I'm trying
in this new machine, and something goes wrong.

Same exception is I run .\script\repljs.bat

TIA

Angel Java Lopez
@ajlopez

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

2012-10-18 Thread Andy Fingerhut
Hopefully someone else can answer why there is a difference in the output of 
the str function.  I suspect in ClojureScript's case, it is simply the default 
behavior to use \x and two hex digits to display a character in a string with a 
code point in the range 128 through 255, inherited from JavaScript, whereas in 
Clojure/JVM it uses the currently specified character set encoding of the 
underlying JVM.

As far as Clojure/JVM being able to read strings encoded in this way, there is 
an enhancement request ticket CLJ-1025 open, and there is recent discussion on 
the Clojure Dev group about whether this enhancement should be included in the 
yet-to-be-released Clojure 1.5:

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

Andy

On Oct 18, 2012, at 4:12 AM, Henrik Mohr wrote:

 Hi there!
 
 I'm wondering why ClojureScript seems to handle international characters 
 differently from Clojure.
 
 Simple example in Clojure (= my preferred behaviour):
 user= (str ø)
 ø
 
 The same example in ClojureScript:
 ClojureScript:cljs.user   #_= (str 'ø')
 \xF8'
 
 Can anyone explain to me why ClojureScript behaves like that?
 
 I need to send strings from ClojureScript to a remote service, so I need the 
 output from ClojureScript to be straight UTF-8 encoded strings.
 
 Because when the (Clojure based) remote service receives the string from 
 ClojureScript it doesn't decode it correctly with read-string:
 Exception: java.lang.RuntimeException: Unsupported escape character: \x
 
 Anyone?
 
 Thanks.
 
 Best regards,
 Henrik

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

2012-10-18 Thread Henrik Mohr
Thanks for your reply Andy!

BRgds,
Henrik

On Thursday, October 18, 2012 2:17:22 PM UTC+2, Andy Fingerhut wrote:

 Hopefully someone else can answer why there is a difference in the output 
 of the str function.  I suspect in ClojureScript's case, it is simply the 
 default behavior to use \x and two hex digits to display a character in a 
 string with a code point in the range 128 through 255, inherited from 
 JavaScript, whereas in Clojure/JVM it uses the currently specified 
 character set encoding of the underlying JVM.

 As far as Clojure/JVM being able to read strings encoded in this way, 
 there is an enhancement request ticket CLJ-1025 open, and there is recent 
 discussion on the Clojure Dev group about whether this enhancement should 
 be included in the yet-to-be-released Clojure 1.5:

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

 Andy

 On Oct 18, 2012, at 4:12 AM, Henrik Mohr wrote:

 Hi there!

 I'm wondering why ClojureScript seems to handle international characters 
 differently from Clojure.

 Simple example in Clojure (= my preferred behaviour):
 user= (str ø)
 ø

 The same example in ClojureScript:
 ClojureScript:cljs.user   #_= (str 'ø')
 \xF8'

 Can anyone explain to me why ClojureScript behaves like that?

 I need to send strings from ClojureScript to a remote service, so I need 
 the output from ClojureScript to be straight UTF-8 encoded strings.

 Because when the (Clojure based) remote service receives the string from 
 ClojureScript it doesn't decode it correctly with read-string:
 Exception: java.lang.RuntimeException: Unsupported escape character: \x

 Anyone?

 Thanks.

 Best regards,
 Henrik



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

why is get not giving me a default value?

2012-10-18 Thread larry google groups

I have some Javascript on a website that pings my Clojure app. My app adds 
in the user info like this:

(defn add-to-logged-in-registry [this-users-params]
  We assume some user is looking at a site such as wpquestions.com and the 
Javascript on that site is sending an Ajax request to this app, every 10 
seconds, with a map of information about the user, which we need to store 
in the registry.
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { updated right-now })]
(swap! registry (fn [map-of-user-maps]
  (assoc (assoc map-of-user-maps (get new-user-entry 
username anonymous) {}) (get new-user-entry username anonymous)  
new-user-entry)

I wanted to get a map inside of a map like this:

{:lawrence {:last_name Krubner, :image ziggy_stardust.jpg, :username 
lawrence, :first_name Lawrence, updated 1350568598742}}

instead I get:

{nil {:last_name Krubner, :image ziggy_stardust.jpg, :username 
lawrence, :first_name Lawrence, updated 1350568598742}}

How can I get the username as the top level key, instead of nil?


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

Re: ANN: LispIndent, jEdit plugin that indents lisp code

2012-10-18 Thread Jonathan Fischer Friberg
Presets have been implemented in the latest version.
It's selectable in the plugin options.

The clojure preset should make LispIndent more or less exactly emacs.
(I think, I still haven't tested emacs - will check out your guide soon
John :) )

Jonathan


On Thu, Oct 18, 2012 at 5:55 AM, John Gabriele jmg3...@gmail.com wrote:

 On Wednesday, October 17, 2012 7:39:26 PM UTC-4, Jonathan Fischer Friberg
 wrote:

 The plugin has been updated to support function argument indenting.
 It is configurable in the plugin options.


 Oooh, this is nice. :) I selected the indent to function arguments by
 default radio button, checked the box to indent if operator matches and
 filled in defn, and indenting works wonderfully so far. Will try this out
 some more.



 Next, I think I will implement presets. The idea is that
 each preset corresponds to one language. That way, LispIndent
 can still be language-independent. Users will also be spared of
 implementing their own regexes. :)

 What do you think about this?


 Oh, do you mean having that indent two spaces if operator matches text
 box pre-filled when selecting a given lisp-like language? That would be
 great, and would save users a lot of time having to figure out what should
 go in there while they're learning the language. :)

 Great stuff here. Particularly for those new to Clojure who'd like an easy
 GUI editor.

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


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: why is get not giving me a default value?

2012-10-18 Thread Tassilo Horn
larry google groups lawrencecloj...@gmail.com writes:

   (let [right-now (. (Date.) getTime)
 new-user-entry (conj this-users-params { updated right-now })]
 (swap! registry (fn [map-of-user-maps]
   (assoc (assoc map-of-user-maps (get new-user-entry 
 username anonymous) {}) (get new-user-entry username anonymous)  
 new-user-entry)

 I wanted to get a map inside of a map like this:

Probably, you want something like

(let [user (get new-user-entry username anonymous)]
  (swap! registry update-in [(keyword user)] assoc :username user)

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: why is get not giving me a default value?

2012-10-18 Thread Toby Crawley
Does new-user-entry include a username entry that points to nil? get only 
uses default value if the key is not present:

user= (get {:x nil} :x :not-found)
nil
user= (get {:x nil} :y :not-found)
:not-found
user= (or (get {:x nil} :x) :not-found)
:not-found
user= 

On Oct 18, 2012, at 10:11 AM, larry google groups lawrencecloj...@gmail.com 
wrote:

 
 I have some Javascript on a website that pings my Clojure app. My app adds in 
 the user info like this:
 
 (defn add-to-logged-in-registry [this-users-params]
   We assume some user is looking at a site such as wpquestions.com and the 
 Javascript on that site is sending an Ajax request to this app, every 10 
 seconds, with a map of information about the user, which we need to store in 
 the registry.
   (let [right-now (. (Date.) getTime)
 new-user-entry (conj this-users-params { updated right-now })]
 (swap! registry (fn [map-of-user-maps]
   (assoc (assoc map-of-user-maps (get new-user-entry 
 username anonymous) {}) (get new-user-entry username anonymous)  
 new-user-entry)
 
 I wanted to get a map inside of a map like this:
 
 {:lawrence {:last_name Krubner, :image ziggy_stardust.jpg, :username 
 lawrence, :first_name Lawrence, updated 1350568598742}}
 
 instead I get:
 
 {nil {:last_name Krubner, :image ziggy_stardust.jpg, :username 
 lawrence, :first_name Lawrence, updated 1350568598742}}
 
 How can I get the username as the top level key, instead of nil?
 
 
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

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

2012-10-18 Thread Sean Corfield
Which books on Clojure have you read so far?

On Wed, Oct 17, 2012 at 8:51 PM, Brian Craft craft.br...@gmail.com wrote:

 I'm finding the books on clojure to be very focused on low-level language
 features. Are there any good references for how to design code in clojure
 (or perhaps in functional languages more generally)? For example, knowing
 when to use a data type or a protocol, knowing when and how to separate
 purely functional code from code with side effects, making use of monads,
 queues, and the other forms that one hears about in the forums, etc.


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

2012-10-18 Thread Bronsa
I'm following clojure's LispReader implementation in blind, you should ask
that question to clojure devs
2012/10/14 AtKaaZ atk...@gmail.com

 Hi!
 What would you do about this ?

 https://github.com/quil/quil/commit/d0312f0f119db066a8d613dec8803571b92bea39
 Would you edit the file or change the reader?

 Thanks.


 On Sun, Oct 14, 2012 at 3:14 PM, Bronsa brobro...@gmail.com wrote:

 Neurotic is a library that implements a `deftrait` macro and support for
 implementing those traits in `deftype`/`defrecod`

 The purpose of this library is to provide a mechanism of code-reuse for
 those occasions when using a map and `extend` is not fast enough, or, in
 the case of java interfaces instead of clojure protcols, where  `extend`
 would simply be impossible to use.
 https://github.com/Bronsa/neurotic

 Blind is a complete implementation of the clojure reader written in
 clojure, based on `clojure.lang.LispReader` and `cljs.reader`

 https://github.com/Bronsa/blind

 More informations and the documentation are available on the READMEs of
 the repositories.

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

2012-10-18 Thread Bronsa
In these days I've released a new version of neurotic

To use it simply put on your project.clj
[bronsa/neurotic 0.3.3]

With the 0.3.3 release neurotic fully supports implementing deftrait from:
deftype, defrecor, extend and extend-type.
Error messages has also been improved.

A new version of blind has also been released today, fixing a few bugs in
syntax-quote implementation
[bronsa/blind 0.2.4]

Note that as of right now blind.reader is really slow, I'm pretty sure
there's a bottleneck somewhere but I'm not too good at profiling.
If somebody wants to give some help to speed things up, pull requests are
welcome (suggestions too).

2012/10/14 Bronsa brobro...@gmail.com

 Neurotic is a library that implements a `deftrait` macro and support for
 implementing those traits in `deftype`/`defrecod`

 The purpose of this library is to provide a mechanism of code-reuse for
 those occasions when using a map and `extend` is not fast enough, or, in
 the case of java interfaces instead of clojure protcols, where  `extend`
 would simply be impossible to use.
 https://github.com/Bronsa/neurotic

 Blind is a complete implementation of the clojure reader written in
 clojure, based on `clojure.lang.LispReader` and `cljs.reader`

 https://github.com/Bronsa/blind

 More informations and the documentation are available on the READMEs of
 the repositories.

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: why is get not giving me a default value?

2012-10-18 Thread larry google groups
Okay, this is very confusing to me. If I try this: 

  (defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { updated right-now })]
(swap! registry (fn [map-of-user-maps]
 (conj map-of-user-maps {:hi new-user-entry})

and then at the REPL I:

who-is-logged-in.core @registry
{nil {:last_name 777ch, :image in.jpg, :username ch, 
:first_name 7alle, updated 1350573104214}}

Here I am hard-coding a key called :hi and yet in the registry I still 
see the top level key as nil. What happened to the :hi? I was expecting:


{:hi {:last_name 777ch, :image in.jpg, :username ch, 
:first_name 7alle, updated 1350573104214}}


What am I not understanding? 




On Thursday, October 18, 2012 10:47:25 AM UTC-4, Toby Crawley wrote:

 Does new-user-entry include a username entry that points to nil? get 
 only uses default value if the key is not present: 

 user= (get {:x nil} :x :not-found) 
 nil 
 user= (get {:x nil} :y :not-found) 
 :not-found 
 user= (or (get {:x nil} :x) :not-found) 
 :not-found 
 user= 

 On Oct 18, 2012, at 10:11 AM, larry google groups 
 lawrenc...@gmail.comjavascript: 
 wrote: 

  
  I have some Javascript on a website that pings my Clojure app. My app 
 adds in the user info like this: 
  
  (defn add-to-logged-in-registry [this-users-params] 
We assume some user is looking at a site such as wpquestions.com and 
 the Javascript on that site is sending an Ajax request to this app, every 
 10 seconds, with a map of information about the user, which we need to 
 store in the registry. 
(let [right-now (. (Date.) getTime) 
  new-user-entry (conj this-users-params { updated right-now })] 
  (swap! registry (fn [map-of-user-maps] 
(assoc (assoc map-of-user-maps (get new-user-entry 
 username anonymous) {}) (get new-user-entry username anonymous) 
  new-user-entry) 
  
  I wanted to get a map inside of a map like this: 
  
  {:lawrence {:last_name Krubner, :image ziggy_stardust.jpg, :username 
 lawrence, :first_name Lawrence, updated 1350568598742}} 
  
  instead I get: 
  
  {nil {:last_name Krubner, :image ziggy_stardust.jpg, :username 
 lawrence, :first_name Lawrence, updated 1350568598742}} 
  
  How can I get the username as the top level key, instead of nil? 
  
  
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  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: why is get not giving me a default value?

2012-10-18 Thread Nate Young
On Thu, Oct 18, 2012 at 10:16 AM, larry google groups
lawrencecloj...@gmail.com wrote:
 Okay, this is very confusing to me. If I try this:

   (defn add-to-logged-in-registry [this-users-params]

   (let [right-now (. (Date.) getTime)
 new-user-entry (conj this-users-params { updated right-now })]
 (swap! registry (fn [map-of-user-maps]
  (conj map-of-user-maps {:hi new-user-entry})
I think you want to use assoc here instead of conj

(assoc map-of-user-maps :hi new-user-entry)

and conveniently, swap! will pass the map to assoc for you, so no need
for the anonymous function

(swap! registry assoc :hi new-user-entry)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: why is get not giving me a default value?

2012-10-18 Thread Sean Corfield
I tried your code and got the expected result:

user (def registry (atom {}))
#'user/registry
user (import 'java.util.Date)
java.util.Date
user   (defn add-to-logged-in-registry [this-users-params]
  (let [right-now (. (Date.) getTime)
new-user-entry (conj this-users-params { updated right-now })]
(swap! registry (fn [map-of-user-maps]
 (conj map-of-user-maps {:hi new-user-entry})
#'user/add-to-logged-in-registry
user (add-to-logged-in-registry {:a 1 :b 2})
{:hi {updated 1350573599595, :a 1, :b 2}}
user

On Thu, Oct 18, 2012 at 8:16 AM, larry google groups 
lawrencecloj...@gmail.com wrote:

 Okay, this is very confusing to me. If I try this:

   (defn add-to-logged-in-registry [this-users-params]

   (let [right-now (. (Date.) getTime)
 new-user-entry (conj this-users-params { updated right-now })]
 (swap! registry (fn [map-of-user-maps]
  (conj map-of-user-maps {:hi new-user-entry})

 and then at the REPL I:

 who-is-logged-in.core @registry
 {nil {:last_name 777ch, :image in.jpg, :username ch,
 :first_name 7alle, updated 1350573104214}}

 Here I am hard-coding a key called :hi and yet in the registry I still
 see the top level key as nil. What happened to the :hi? I was expecting:


 {:hi {:last_name 777ch, :image in.jpg, :username ch,
 :first_name 7alle, updated 1350573104214}}


 What am I not understanding?





-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: why is get not giving me a default value?

2012-10-18 Thread larry google groups
Interesting. I am using Clojure 1.3. And I'm using clojure-jack-in inside 
of emacs. What are you using?

On Thursday, October 18, 2012 11:22:26 AM UTC-4, Sean Corfield wrote:

 I tried your code and got the expected result:

 user (def registry (atom {}))
 #'user/registry
 user (import 'java.util.Date)
 java.util.Date
 user   (defn add-to-logged-in-registry [this-users-params]
   (let [right-now (. (Date.) getTime)
 new-user-entry (conj this-users-params { updated right-now })]
 (swap! registry (fn [map-of-user-maps]
  (conj map-of-user-maps {:hi new-user-entry})
 #'user/add-to-logged-in-registry
 user (add-to-logged-in-registry {:a 1 :b 2})
 {:hi {updated 1350573599595, :a 1, :b 2}}
 user 

 On Thu, Oct 18, 2012 at 8:16 AM, larry google groups 
 lawrenc...@gmail.comjavascript:
  wrote:

 Okay, this is very confusing to me. If I try this: 

   (defn add-to-logged-in-registry [this-users-params]

   (let [right-now (. (Date.) getTime)
 new-user-entry (conj this-users-params { updated right-now })]
 (swap! registry (fn [map-of-user-maps]
  (conj map-of-user-maps {:hi new-user-entry})

 and then at the REPL I:

 who-is-logged-in.core @registry
 {nil {:last_name 777ch, :image in.jpg, :username ch, 
 :first_name 7alle, updated 1350573104214}}

 Here I am hard-coding a key called :hi and yet in the registry I still 
 see the top level key as nil. What happened to the :hi? I was expecting:


 {:hi {:last_name 777ch, :image in.jpg, :username ch, 
 :first_name 7alle, updated 1350573104214}}


 What am I not understanding? 







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

class name clashes on importing classes of same name from different Java packages into the same clojure namespace...

2012-10-18 Thread Sunil S Nandihalli
Hi Everybody,
class name  clashes on importing same named classes from different
java-packages into same clojure namespace. Is this expected. I think that
it should be possible to import them and can be used by completely
qualifying the class name with the appropriate java-package name.
Thanks,
Sunil.

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

Re: class name clashes on importing classes of same name from different Java packages into the same clojure namespace...

2012-10-18 Thread Sunil S Nandihalli
Am I doing it wrong ? is there a way to get around this?.. I guess I
pressed the send button before I completed the email..

Thanks,
Sunil.
On Thu, Oct 18, 2012 at 8:57 PM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hi Everybody,
 class name  clashes on importing same named classes from different
 java-packages into same clojure namespace. Is this expected. I think that
 it should be possible to import them and can be used by completely
 qualifying the class name with the appropriate java-package name.
 Thanks,
 Sunil.


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

Re: class name clashes on importing classes of same name from different Java packages into the same clojure namespace...

2012-10-18 Thread Tassilo Horn
Sunil S Nandihalli sunil.nandiha...@gmail.com writes:

Hi!

 class name clashes on importing same named classes from different
 java-packages into same clojure namespace. Is this expected.

Yes, that's expected.  Import the one you are using more frequently and
access the other one qualified.

 it should be possible to import them and can be used by completely
 qualifying the class name with the appropriate java-package name.

Then why do you want to import them in the first place if you have to
qualify them?

Bye,
Tassilo

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: class name clashes on importing classes of same name from different Java packages into the same clojure namespace...

2012-10-18 Thread Jim foo.bar

On 18/10/12 16:27, Sunil S Nandihalli wrote:

Hi Everybody,
class name  clashes on importing same named classes from different 
java-packages into same clojure namespace. Is this expected. I think 
that it should be possible to import them and can be used by 
completely qualifying the class name with the appropriate java-package 
name.

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

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en 


simply don't import them...just use the fully-qualified name

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


Replacing nested let statements with assignments

2012-10-18 Thread JvJ
I'm not sure if anyone's already done this, but I recently got tired of 
writing code that looked like this:

(let [a 1]



(ns cljutils.core)

(defn- form-check
  Ensures the form represents an assignment.
Such as (:= a 1)
  [form]
  (and
   (= 3 (count form))
   (= := (first form))
   (symbol? (second form
   

(defn- iblk-fn
  Simulates imperative variable-assignments through nested
let statements.
  [ forms]
  (let [form (first forms)
rforms (rest forms)]
(if-not form
  nil
  ;; Else
  `(do
 ~@(if (form-check form)
 `((let [~(second form) ~(nth form 2)]
 ~(apply iblk-fn rforms)))
 (let [[f r] (split-with (comp not form-check) forms)]
(concat
 f
 (apply iblk-fn r

(defmacro -:
  [ forms]
  (apply iblk-fn forms))

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: class name clashes on importing classes of same name from different Java packages into the same clojure namespace...

2012-10-18 Thread Sunil S Nandihalli
thanks tassillo, that fixed it .. I didn't know that we can use the classes
with out importing them.
Sunil.

On Thu, Oct 18, 2012 at 9:07 PM, Tassilo Horn t...@gnu.org wrote:

 Sunil S Nandihalli sunil.nandiha...@gmail.com writes:

 Hi!

  class name clashes on importing same named classes from different
  java-packages into same clojure namespace. Is this expected.

 Yes, that's expected.  Import the one you are using more frequently and
 access the other one qualified.

  it should be possible to import them and can be used by completely
  qualifying the class name with the appropriate java-package name.

 Then why do you want to import them in the first place if you have to
 qualify them?

 Bye,
 Tassilo

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: class name clashes on importing classes of same name from different Java packages into the same clojure namespace...

2012-10-18 Thread Sunil S Nandihalli
Thanks Jim,
 That fixed the issue. I did not know that I can access the classes without
importing them..
Sunil.

On Thu, Oct 18, 2012 at 9:14 PM, Jim foo.bar jimpil1...@gmail.com wrote:

 On 18/10/12 16:27, Sunil S Nandihalli wrote:

 Hi Everybody,
 class name  clashes on importing same named classes from different
 java-packages into same clojure namespace. Is this expected. I think that
 it should be possible to import them and can be used by completely
 qualifying the class name with the appropriate java-package name.
 Thanks,
 Sunil.
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+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


 simply don't import them...just use the fully-qualified name

 Jim


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


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

2012-10-18 Thread Brian Craft
Clojure Programming, and The Joy of ... 

On Thursday, October 18, 2012 7:53:38 AM UTC-7, Sean Corfield wrote:

 Which books on Clojure have you read so far?

 On Wed, Oct 17, 2012 at 8:51 PM, Brian Craft craft...@gmail.comjavascript:
  wrote:

 I'm finding the books on clojure to be very focused on low-level language 
 features. Are there any good references for how to design code in clojure 
 (or perhaps in functional languages more generally)? For example, knowing 
 when to use a data type or a protocol, knowing when and how to separate 
 purely functional code from code with side effects, making use of monads, 
 queues, and the other forms that one hears about in the forums, etc.


  



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

Replacing nested let statements with assignments

2012-10-18 Thread JvJ
I'm not sure if anyone's done this before, but I'm fed up with writing code 
that looks like this:

(let [a 1]
   (println this is a:  a)
   (let [b 2]
   (println this is b:  b)
   (let [c 3]
(println this is c:  c)
(+ a b c

I'd rather do something more like this:
(-:
   (:= a 1) ;; Assign a to 1
   (println this is a:  a)
   (:= b 2)
   (println this is b:  b)
   (:= c 3)
   (println this is c:  c)
   (+ a b c))


I wrote a macro to do this, but I feel like it's such a simple thing that 
someone must have done it before, and it's probably better than mine.
Does anyone know of anything like that? 

Here's the code for it in case anyone wants to use it:

(ns cljutils.core)

(defn- form-check
  Ensures the form represents an assignment.
Such as (:= a 1)
  [form]
  (and
   (= 3 (count form))
   (= := (first form))
   (symbol? (second form
   

(defn- iblk-fn
  Simulates imperative variable-assignments through nested
let statements.
  [ forms]
  (let [form (first forms)
rforms (rest forms)]
(if-not form
  nil
  ;; Else
  `(do
 ~@(if (form-check form)
 `((let [~(second form) ~(nth form 2)]
 ~(apply iblk-fn rforms)))
 (let [[f r] (split-with (comp not form-check) forms)]
(concat
 f
 (apply iblk-fn r

(defmacro -:
  [ forms]
  (apply iblk-fn forms))

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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 12:01 PM, JvJ kfjwhee...@gmail.com wrote:

 I'm not sure if anyone's done this before, but I'm fed up with writing
 code that looks like this:


What problem does this solve given you can do the following?

(let [a 1
  _ (println a)
  b 2
  _ (println b)
  c 3
  _ (println c)]
   ...)

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

2012-10-18 Thread keeds
I'm confused. How does the following not work?

(let [a 1 b 2 c 3]
  (println a)
  (println b)
  (println c)
  (+ a b c))

On Thursday, October 18, 2012 5:01:33 PM UTC+1, JvJ wrote:

 I'm not sure if anyone's done this before, but I'm fed up with writing 
 code that looks like this:

 (let [a 1]
(println this is a:  a)
(let [b 2]
(println this is b:  b)
(let [c 3]
 (println this is c:  c)
 (+ a b c

 I'd rather do something more like this:
 (-:
(:= a 1) ;; Assign a to 1
(println this is a:  a)
(:= b 2)
(println this is b:  b)
(:= c 3)
(println this is c:  c)
(+ a b c))


 I wrote a macro to do this, but I feel like it's such a simple thing that 
 someone must have done it before, and it's probably better than mine.
 Does anyone know of anything like that? 

 Here's the code for it in case anyone wants to use it:

 (ns cljutils.core)

 (defn- form-check
   Ensures the form represents an assignment.
 Such as (:= a 1)
   [form]
   (and
(= 3 (count form))
(= := (first form))
(symbol? (second form


 (defn- iblk-fn
   Simulates imperative variable-assignments through nested
 let statements.
   [ forms]
   (let [form (first forms)
 rforms (rest forms)]
 (if-not form
   nil
   ;; Else
   `(do
  ~@(if (form-check form)
  `((let [~(second form) ~(nth form 2)]
  ~(apply iblk-fn rforms)))
  (let [[f r] (split-with (comp not form-check) forms)]
 (concat
  f
  (apply iblk-fn r

 (defmacro -:
   [ forms]
   (apply iblk-fn forms))


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

2012-10-18 Thread Ben Wolfson
On Thu, Oct 18, 2012 at 9:12 AM, keeds akee...@gmail.com wrote:
 I'm confused. How does the following not work?

 (let [a 1 b 2 c 3]
   (println a)
   (println b)
   (println c)
   (+ a b c))

It works, but all of the expressions on the RHS of the let
expression's binding vector have to be applied before you start
printing any of the values.

-- 
Ben Wolfson
Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure. [Larousse, Drink entry]

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

2012-10-18 Thread JvJ
I didn't realize you could bind to empty identifiers like that.  Alright, 
that makes more sense.  I figured I was missing something.

On Thursday, 18 October 2012 12:11:49 UTC-4, David Nolen wrote:

 On Thu, Oct 18, 2012 at 12:01 PM, JvJ kfjwh...@gmail.com javascript:wrote:

 I'm not sure if anyone's done this before, but I'm fed up with writing 
 code that looks like this:


 What problem does this solve given you can do the following?

 (let [a 1
   _ (println a)
   b 2
   _ (println b)
   c 3
   _ (println c)]
...) 


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

2012-10-18 Thread JvJ
Exactly.  A big part of the reason was that I needed to do things between 
when other variables were initialized.

On Thursday, 18 October 2012 12:17:17 UTC-4, Ben wrote:

 On Thu, Oct 18, 2012 at 9:12 AM, keeds ake...@gmail.com javascript: 
 wrote: 
  I'm confused. How does the following not work? 
  
  (let [a 1 b 2 c 3] 
(println a) 
(println b) 
(println c) 
(+ a b c)) 

 It works, but all of the expressions on the RHS of the let 
 expression's binding vector have to be applied before you start 
 printing any of the values. 

 -- 
 Ben Wolfson 
 Human kind has used its intelligence to vary the flavour of drinks, 
 which may be sweet, aromatic, fermented or spirit-based. ... Family 
 and social life also offer numerous other occasions to consume drinks 
 for pleasure. [Larousse, Drink entry] 


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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 12:23 PM, JvJ kfjwhee...@gmail.com wrote:

 I didn't realize you could bind to empty identifiers like that.  Alright,
 that makes more sense.  I figured I was missing something.


Just to be clear _ has not special meaning beyond convention. I could have
used x but that doesn't convey that we don't care about the return value.

David

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

Re: Replacing nested let statements with assignments

2012-10-18 Thread Ambrose Bonnaire-Sergeant
There's nothing special going on, no empty identifiers. It's just a
common convention to use _ when uninterested in the return value.

(let [_ 1]
  _)
;= 1

Pretty evil to actually use bindings called _ though :)

Thanks,
Ambrose

On Fri, Oct 19, 2012 at 12:23 AM, JvJ kfjwhee...@gmail.com wrote:

 I didn't realize you could bind to empty identifiers like that.  Alright,
 that makes more sense.  I figured I was missing something.

 On Thursday, 18 October 2012 12:11:49 UTC-4, David Nolen wrote:

 On Thu, Oct 18, 2012 at 12:01 PM, JvJ kfjwh...@gmail.com wrote:

 I'm not sure if anyone's done this before, but I'm fed up with writing
 code that looks like this:


 What problem does this solve given you can do the following?

 (let [a 1
   _ (println a)
   b 2
   _ (println b)
   c 3
   _ (println c)]
...)

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

2012-10-18 Thread Brian Craft
It's not just you. I'm also surprised at the amount of syntax and the 
number of ways of doing some things. I suspect that if you come from java 
or C++ it seems like a simple language, but it feels pretty cluttered 
compared to other languages. The '-' macro, for example. I've learned to 
read right-to-left in scheme, but with the - macro we now have to read 
both right-to-left and left-to-right in the same program. I'm not sure 
that's an improvement in readability.

And as we've learned with perl, you can't just pick the syntax you like 
best, because you have to be able to read other people's code: you have to 
know *every* syntax for doing every operation. I don't think clojure is at 
the perl level of confusion, and I'm very excited about it. I'm very happy 
with my first small clojure project: it expresses the problem well, and the 
performance is great.

On Wednesday, October 17, 2012 11:14:59 AM UTC-7, Curtis wrote:

 I do hope this is an appropriate topic. 

 I am very excited by the power and capability in clojure and amazed at the 
 rapid quality of tooling that exists so early in the projects life.

 I would like to admit that i am feeling like the simplicity and elegance 
 that I experienced writing in lisp seems to be bypassed in certain areas in 
 favor of extra syntax [] and what seems to be local variable declarations
 as well as 'many ways' to do something around looping and recursion.

 I am wondering how others feel about this and if there are any style 
 guides that i could be exposed to so that I can enjoy the poetry that I may 
 be missing. 

 Could some one help me with this please?

 Thank you!

 Curtis


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

2012-10-18 Thread John Gabriele
On Thursday, October 18, 2012 10:18:09 AM UTC-4, Jonathan Fischer Friberg 
wrote:

 Presets have been implemented in the latest version.
 It's selectable in the plugin options.


Works nicely. Thanks, Jonathan!

BTW, I created the beginnings of a CDS development tools guide 
https://github.com/clojuredocs/cds/blob/master/articles/ecosystem/development_tools.md
 
and added some notes in there re. jEdit + LispIndent.

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

Re: why is get not giving me a default value?

2012-10-18 Thread Sean Corfield
On Thu, Oct 18, 2012 at 8:26 AM, larry google groups 
lawrencecloj...@gmail.com wrote:

 Interesting. I am using Clojure 1.3. And I'm using clojure-jack-in inside
 of emacs. What are you using?


I was using Clojure 1.4 via jack-in from emacs. I just tried it again with
lein repl in a clean Clojure 1.3 project and it works fine there too:

nREPL server started on port 55907
REPL-y 0.1.0-beta10
Clojure 1.3.0
...
user=  (def registry (atom {}))
#'user/registry
user=  (import 'java.util.Date)
java.util.Date
user=  (defn add-to-logged-in-registry [this-users-params]
  #_=   (let [right-now (. (Date.) getTime)
  #_= new-user-entry (conj this-users-params { updated right-now
})]
  #_= (swap! registry (fn [map-of-user-maps]
  #_=  (conj map-of-user-maps {:hi new-user-entry})
#'user/add-to-logged-in-registry
user=  (add-to-logged-in-registry {:a 1 :b 2})
{:hi {updated 1350579386193, :a 1, :b 2}}
-- 
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

Re: Coming from Common Lisp to Clojure

2012-10-18 Thread Jim - FooBar();

On 18/10/12 17:37, Brian Craft wrote:
It's not just you. I'm also surprised at the amount of syntax and the 
number of ways of doing some things. I suspect that if you come from 
java or C++ it seems like a simple language, but it feels pretty 
cluttered compared to other languages. The '-' macro, for example. 
I've learned to read right-to-left in scheme, but with the - macro we 
now have to read both right-to-left and left-to-right in the same 
program. I'm not sure that's an improvement in readability.


If the threading macros are a source of confusion for you then you can 
always choose not to use them...tbh i get a bit annoyed as well when 
people sue -/- for not so nested expressions (e.g a single chaining). 
However, I've found that when you want to chain more than say 3-4 forms 
it greatly improves readability. You can literally read the thing as a 
sentence. The same with 'doto' regardless of the fact that it returns 
the object rather than the result of last form...


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: code design in clojure

2012-10-18 Thread Sean Corfield
On Thu, Oct 18, 2012 at 8:58 AM, Brian Craft craft.br...@gmail.com wrote:

 Clojure Programming, and The Joy of ...


Hmm, I was going to suggest Joy of but if you don't think that helps with
some of those design issues, I'm not sure what to suggest. Others suggested
Clojure Programming but, again, if that doesn't help...

At this point I'd certainly be interested in hearing suggestions from other
people beyond those two books...?
-- 
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

Re: code design in clojure

2012-10-18 Thread Paul deGrandis
Brian,

Those are two excellent books.  If you are looking at more general project 
organization and approaches, I'd suggest:
 - Just Enough Architecture (specifically its discussion on architectural 
evident coding)
 - watch the Halloway talks on evident code
 - thumb through Ring, Leiningen, and ClojureScript as prime examples of 
well written Clojure applications
 - watch the Google tech talk on designing good APIs 
(http://www.youtube.com/watch?v=aAb7hSCtvGw)
 - and you might find a book like Higher-Order Perl helpful (depending 
where you're coming from)

Hope one (or all) of these help!
Paul

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

2012-10-18 Thread Mimmo Cosenza
I came very recently to clojure, having crossed CL in the 80's, c/c++ in 
the 90's and java in the 00's. A long travel to find with clojure a kind of 
very comfortable destination very close to where I started from + seqs 
and laziness. 

thanks Rich, and all of you too to brought me back on joy of programming

Mimmo

On Wednesday, October 17, 2012 3:53:55 AM UTC+2, Rich Hickey wrote:

 I released Clojure 5 years ago today. It's been a terrific ride so far. 

 Thanks to everyone who contributes to making Clojure, and its community, 
 great. 

 Rich

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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 1:02 PM, Paul deGrandis paul.degran...@gmail.comwrote:

  - thumb through Ring, Leiningen, and ClojureScript as prime examples of
 well written Clojure applications


+1

I think it's informative to look at non-trivial yet small Clojure
libraries. ClojureScript doesn't quite fit the small requirement, but I
think there's a lot to learn from looking at ClojureScript's analyzer.clj
which is less than a thousand lines.

David

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

Re: Coming from Common Lisp to Clojure

2012-10-18 Thread Sean Corfield
On Thu, Oct 18, 2012 at 9:37 AM, Brian Craft craft.br...@gmail.com wrote:

 I suspect that if you come from java or C++ it seems like a simple
 language, but it feels pretty cluttered compared to other languages.


Interesting observation and probably true. Although I did Lisp back at
university (in the early/mid-80's), most of my career has been in C-family
languages so, yes, Clojure feels like a VERY simple language with almost no
syntax. Having recently read more Scheme / CL code, I can see how folks
coming from those languages think Clojure is cluttered. But it's SO much
simpler than the C-languages that it must surely be only a little more
cluttered than Scheme / CL? Do the differences really seem that big?
Genuine question, since I've been immersed in C-languages for so long...
-- 
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

Re: code design in clojure

2012-10-18 Thread Roberto Mannai
See Functional Programming for the Object-Oriented Programmer (
https://leanpub.com/fp-oo)
Il giorno 18/ott/2012 19:01, Sean Corfield seancorfi...@gmail.com ha
scritto:

 On Thu, Oct 18, 2012 at 8:58 AM, Brian Craft craft.br...@gmail.comwrote:

 Clojure Programming, and The Joy of ...


 Hmm, I was going to suggest Joy of but if you don't think that helps with
 some of those design issues, I'm not sure what to suggest. Others suggested
 Clojure Programming but, again, if that doesn't help...

 At this point I'd certainly be interested in hearing suggestions from
 other people beyond those two books...?
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

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

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

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

Re: Coming from Common Lisp to Clojure

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 12:07 PM, Sean Corfield seancorfi...@gmail.com wrote:
 Clojure feels like a VERY simple language with almost no
 syntax. Having recently read more Scheme / CL code, I can see how folks
 coming from those languages think Clojure is cluttered.

Why do they think it is cluttered? What does that mean?

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

2012-10-18 Thread AtKaaZ
It is; *data_readers.clj*

{db/id datomic.db/id-literal
 db/fn datomic.function/construct
 base64 datomic.codec/base-64-literal}



On Wed, Oct 17, 2012 at 5:54 PM, Robert Luo l...@basecity.com wrote:

 Is #db/id defined in datomic library?

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




-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

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

2012-10-18 Thread AtKaaZ
Thank you for this clarification!

On Thu, Oct 18, 2012 at 6:26 PM, David Nolen dnolen.li...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 12:23 PM, JvJ kfjwhee...@gmail.com wrote:

 I didn't realize you could bind to empty identifiers like that.  Alright,
 that makes more sense.  I figured I was missing something.


 Just to be clear _ has not special meaning beyond convention. I could have
 used x but that doesn't convey that we don't care about the return value.

 David

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




-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

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

2012-10-18 Thread AtKaaZ
(cons 1 nil)

On Wed, Oct 17, 2012 at 8:16 PM, Curtis cur...@ram9.cc wrote:

 Cons seems to be strange

 How do i use Cons with an atom to make a list?

 (cons 1 1)


 On Tuesday, October 16, 2012 5:08:26 PM UTC-7, Baishampayan Ghose wrote:

 `car` is called `first` here and `cdr` could mean either `rest` or
 `next` depending on what you mean/need.

 And oh, `cons` is not exactly the same one from Common Lisp, etc.

 Regards,
 BG

 On Tue, Oct 16, 2012 at 3:40 PM, Curtis cur...@ram9.cc wrote:
  Hello - I was familar with lisp years ago and am very new to clojure.
 
  I am having a hard time understanding how to find 'car' and 'cdr'.
 
  The nice thing about these functions is they always seem to be a part
 of
  lisp.
 
  I would like to use the little lisper to teach lisp to my co-workers so
 that
  we can adopt Clojure.
 
  How can i import cdr or car?
 
  I know i can write these manually  or alias them to 'first' and 'rest'
 - are
  they a part of the language?
 
  Cons appears to be around.
 
 
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clo...@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from this group, send email to
  clojure+u...@**googlegroups.com
  For more options, visit this group at
  http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en



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




-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

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

2012-10-18 Thread Evan Gamble
For the situation where the lets are nested because you're checking the 
values in some way after each binding, I wrote a macro called let?. I find 
it very useful and use it in nearly all my 
code. https://github.com/egamble/let-else

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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 11:11 AM, David Nolen dnolen.li...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 12:01 PM, JvJ kfjwhee...@gmail.com wrote:

 I'm not sure if anyone's done this before, but I'm fed up with writing
 code that looks like this:


 What problem does this solve given you can do the following?

 (let [a 1
   _ (println a)
   b 2
   _ (println b)
   c 3
   _ (println c)]
...)

-1 to using a binding form to do sequencing. That said, not sure what is better!

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

2012-10-18 Thread Alan Malloy
It's rare to get tired of this, because nobody does it: it's not
common because your interleaved statements are side-effecting only,
which is not encouraged in Clojure, and rarely needed. Certainly
sometimes it's the best way to do something, but not so often that I'd
become frustrated; if anything, having to write such irritating code
can serve as a good reminder that I shouldn't have so many
unrestrained side effects scattered through my logic.

On Oct 18, 9:01 am, JvJ kfjwhee...@gmail.com wrote:
 I'm not sure if anyone's done this before, but I'm fed up with writing code
 that looks like this:

 (let [a 1]
    (println this is a:  a)
    (let [b 2]
        (println this is b:  b)
        (let [c 3]
             (println this is c:  c)
             (+ a b c

 I'd rather do something more like this:
 (-:
    (:= a 1) ;; Assign a to 1
    (println this is a:  a)
    (:= b 2)
    (println this is b:  b)
    (:= c 3)
    (println this is c:  c)
    (+ a b c))

 I wrote a macro to do this, but I feel like it's such a simple thing that
 someone must have done it before, and it's probably better than mine.
 Does anyone know of anything like that?

 Here's the code for it in case anyone wants to use it:

 (ns cljutils.core)

 (defn- form-check
   Ensures the form represents an assignment.
 Such as (:= a 1)
   [form]
   (and
    (= 3 (count form))
    (= := (first form))
    (symbol? (second form

 (defn- iblk-fn
   Simulates imperative variable-assignments through nested
 let statements.
   [ forms]
   (let [form (first forms)
         rforms (rest forms)]
     (if-not form
       nil
       ;; Else
       `(do
          ~@(if (form-check form)
              `((let [~(second form) ~(nth form 2)]
                  ~(apply iblk-fn rforms)))
              (let [[f r] (split-with (comp not form-check) forms)]
                 (concat
                  f
                  (apply iblk-fn r

 (defmacro -:
   [ forms]
   (apply iblk-fn forms))

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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 1:55 PM, Alan Malloy a...@malloys.org wrote:
 It's rare to get tired of this, because nobody does it: it's not
 common because your interleaved statements are side-effecting only,
 which is not encouraged in Clojure, and rarely needed. Certainly
 sometimes it's the best way to do something, but not so often that I'd
 become frustrated; if anything, having to write such irritating code
 can serve as a good reminder that I shouldn't have so many
 unrestrained side effects scattered through my logic.

It isn't side effecting it is sequencing.

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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy a...@malloys.org wrote:

 It's rare to get tired of this, because nobody does it: it's not
 common because your interleaved statements are side-effecting only,
 which is not encouraged in Clojure, and rarely needed. Certainly
 sometimes it's the best way to do something, but not so often that I'd
 become frustrated; if anything, having to write such irritating code
 can serve as a good reminder that I shouldn't have so many
 unrestrained side effects scattered through my logic.


I think from the examples debugging via print statements was the main (and
reasonable) use case.

David

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

Re: Replacing nested let statements with assignments

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 1:32 PM, Grant Rettke gret...@acm.org wrote:
 On Thu, Oct 18, 2012 at 11:11 AM, David Nolen dnolen.li...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 12:01 PM, JvJ kfjwhee...@gmail.com wrote:

 I'm not sure if anyone's done this before, but I'm fed up with writing
 code that looks like this:


 What problem does this solve given you can do the following?

 (let [a 1
   _ (println a)
   b 2
   _ (println b)
   c 3
   _ (println c)]
...)

 -1 to using a binding form to do sequencing. That said, not sure what is 
 better!

David so as not to be a total loser here is an alternative that is
maybe the right way but also maybe the very wrong way!

(- ((fn []
  (let [a 1]
(println this is a:  a)
a)))
   ((fn [a]
  (let [b 2]
(println this is b:  b)
(list a b
   ((fn [[a b]]
  (let [c 3]
(println this is c:  c)
(println Sum:  (+ a b c))

JvJ what is your verdict?

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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 3:06 PM, Grant Rettke gret...@acm.org wrote:

 (- ((fn []
   (let [a 1]
 (println this is a:  a)
 a)))
((fn [a]
   (let [b 2]
 (println this is b:  b)
 (list a b
((fn [[a b]]
   (let [c 3]
 (println this is c:  c)
 (println Sum:  (+ a b c))


Why should you have to change the shape of your program to insert some
debugging statements?

David

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

Re: Replacing nested let statements with assignments

2012-10-18 Thread Ben Wolfson
On Thu, Oct 18, 2012 at 12:01 PM, Grant Rettke gret...@acm.org wrote:
 On Thu, Oct 18, 2012 at 1:55 PM, Alan Malloy a...@malloys.org wrote:
 It's rare to get tired of this, because nobody does it: it's not
 common because your interleaved statements are side-effecting only,
 which is not encouraged in Clojure, and rarely needed. Certainly
 sometimes it's the best way to do something, but not so often that I'd
 become frustrated; if anything, having to write such irritating code
 can serve as a good reminder that I shouldn't have so many
 unrestrained side effects scattered through my logic.

 It isn't side effecting it is sequencing.

Clojure's let is already sequential, like Scheme's let*: The bindings
are sequential, so each binding can see the prior bindings. R5RS
Scheme explicitly states that its let makes no guarantees about
sequences.

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



-- 
Ben Wolfson
Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure. [Larousse, Drink entry]

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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 2:07 PM, David Nolen dnolen.li...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 3:06 PM, Grant Rettke gret...@acm.org wrote:

 (- ((fn []
   (let [a 1]
 (println this is a:  a)
 a)))
((fn [a]
   (let [b 2]
 (println this is b:  b)
 (list a b
((fn [[a b]]
   (let [c 3]
 (println this is c:  c)
 (println Sum:  (+ a b c))


 Why should you have to change the shape of your program to insert some
 debugging statements?

Writing a macro like JvJ did or writing all of your code inside of a
let statement like you did is also changing the shape of your program
just to print debug statements isn't it?

Sorry the way I understood the use case that you need to do something,
anything, maybe some expensive, before doing the *next thing*, and
same goes before the *next thing*. I didn't read it as inserting debug
statements at all.

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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 2:09 PM, Ben Wolfson wolf...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 12:01 PM, Grant Rettke gret...@acm.org wrote:
 It isn't side effecting it is sequencing.

 Clojure's let is already sequential, like Scheme's let*: The bindings
 are sequential, so each binding can see the prior bindings. R5RS
 Scheme explicitly states that its let makes no guarantees about
 sequences.

Understood but you don't write entire function definitions inside of a
let block :).

Then again I guess I misunderstood the use case, which is to just
print debug information once in a while.

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

2012-10-18 Thread Alan Malloy
On Oct 18, 12:02 pm, David Nolen dnolen.li...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy a...@malloys.org wrote:
  It's rare to get tired of this, because nobody does it: it's not
  common because your interleaved statements are side-effecting only,
  which is not encouraged in Clojure, and rarely needed. Certainly
  sometimes it's the best way to do something, but not so often that I'd
  become frustrated; if anything, having to write such irritating code
  can serve as a good reminder that I shouldn't have so many
  unrestrained side effects scattered through my logic.

 I think from the examples debugging via print statements was the main (and
 reasonable) use case.

Indeed, but it's easy to add those in any number of ways other than
the code the OP was originally unhappy with. For example, by adding _
bindings for side effects, or by introducing a macro like:

(defmacro ? [form]
  `(let [x# ~form]
 (printf %s is %s '~form x#)
 x#))

(let [a (? 1)
  b (? (+ 3 a))]
  ...)

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

2012-10-18 Thread Mark Engelberg
When I want to add print commands for debugging, I usually either do it the
way David Nolen described, i.e., binding _ to a printf statement, or I use
a little utility macro like this (picked up from stackoverflow):

(defmacro dbg[x] `(let [x# ~x] (println dbg: '~x = x#) x#))


I agree with Evan Gamble that I frequently end up with code that is a
mixture of conditional branching and binding.  This results in highly
indented and less readable code and I think Clojure would really benefit
from some additions to ameliorate this.

Evan's solution (https://github.com/egamble/let-else) allows you to put
conditions in your let.
Cgrand's solution (https://github.com/cgrand/utils) allows you to put lets
in your cond.

Either way works well.  I think Evan's way results in somewhat more compact
code for the common case, whereas Cgrand's way feels a little more
versatile (and his flatter cond is what I use).  I strongly urge you to
pick one of these two techniques and include it in your project.  Once you
try it and see how much cleaner the code is, you'll be hooked.

--Mark

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

Re: Clojure turns 5

2012-10-18 Thread Brian Kirkbride
Congratulations Rich. Many thanks to you and the many people that have 
contributed to making Clojure what it is today. 

Learning and using Clojure has truly brought the joy back to creating 
software and I needed that!

Best,
Brian

On Tuesday, October 16, 2012 8:53:55 PM UTC-5, Rich Hickey wrote:

 I released Clojure 5 years ago today. It's been a terrific ride so far. 

 Thanks to everyone who contributes to making Clojure, and its community, 
 great. 

 Rich

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

2012-10-18 Thread Gary Johnson
Alright, Eli. You've piqued my interest. I'll have to take a closer look 
sometime soon.

  ~Gary

On Wednesday, October 17, 2012 10:22:54 AM UTC-4, Eli Barzilay wrote:

 Gary Johnson gwjohnso at uvm.edu writes: 
  
  I see. After taking a closer look, I can see that you could do LP in 
  Scribble 

 (Yeah, but again -- that's really not its main goal.) 


  as well as also outputting some different kinds of documentation 
  formats, such as Javadocs or standalone documents. The downside I'm 
  seeing is that this all has to be programmed in Scheme 

 Um, it is very intentionally a documentation system that is built on a 
 proper langugae -- like latex and N other such language, only using a 
 general langugae instead of the usual half-baked things...  (I know 
 that some people would consider that a disadvantage, and in that case 
 you should definitely go with some non-language tool like markdown, 
 (raw) markup, or some WYSIWYG thing.) 


  and that you may have to do some IMO less than attractive 
  backquoting to get at the underlying LaTeX if you want PDF outputs 
  which use some of the existing LaTeX packages (math libs come to 
  mind). 

 That's almost never needed -- and when it is, it's generally an 
 indication that some rendering feature should be added.  At the 
 scribble syntax level, the syntax is very lightweight, so that there's 
 no issues of bad backquoting.  I describe all of that in 
 http://barzilay.org/misc/scribble-reader.pdf, and it's applicable to 
 other languages -- not even sexpr-ish ones.  My hope is that this can 
 easily provide a proper language syntax for having lots of text. 
 Markdown is another approach, but IME it suffers greatly when you get 
 to unexpected corner cases (eg, non-trivial and non-uniform rules when 
 you want to write some texts), and in other cases it starts simple and 
 end up being horribly complicated (as in wikipedia source files, which 
 started as a simple markdown thing, and now have a ton of conventions 
 as well as a templating systems that require a wikipedia black belt if 
 you get close to it.) 


  I suggested Org-mode on this thread for these reasons: [...] 

 That's all valid -- I'm just pointing out that there is a way to have 
 a real language instead of relying on a generic tool that inevitably 
 gets complicated when people discover that they want more out of it. 
 But of course YMMV -- I'm just trying to convey the huge benefits we 
 got by using such an in-language tool. 

 -- 
   ((lambda (x) (x x)) (lambda (x) (x x)))  Eli Barzilay: 
 http://barzilay.org/   Maze is Life! 




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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 2:50 PM, Mark Engelberg
mark.engelb...@gmail.com wrote:
 Either way works well.  I think Evan's way results in somewhat more compact
 code for the common case, whereas Cgrand's way feels a little more versatile
 (and his flatter cond is what I use).  I strongly urge you to pick one of
 these two techniques and include it in your project.  Once you try it and
 see how much cleaner the code is, you'll be hooked.

Is it poor form to do something like this inside a defn?

 (def a 1)
  (println this is a:  a)
  (def b 2)
  (println this is b:  b)
  (def c 3)
  (println this is c:  c)
  (println Sum:  (+ a b c))

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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 4:15 PM, Grant Rettke gret...@acm.org wrote:

 On Thu, Oct 18, 2012 at 2:50 PM, Mark Engelberg
 mark.engelb...@gmail.com wrote:
  Either way works well.  I think Evan's way results in somewhat more
 compact
  code for the common case, whereas Cgrand's way feels a little more
 versatile
  (and his flatter cond is what I use).  I strongly urge you to pick one
 of
  these two techniques and include it in your project.  Once you try it and
  see how much cleaner the code is, you'll be hooked.

 Is it poor form to do something like this inside a defn?

  (def a 1)
   (println this is a:  a)
   (def b 2)
   (println this is b:  b)
   (def c 3)
   (println this is c:  c)
   (println Sum:  (+ a b c))


very poor form. def is always top level.

David

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

Re: Replacing nested let statements with assignments

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 3:17 PM, David Nolen dnolen.li...@gmail.com wrote:

 On Thu, Oct 18, 2012 at 4:15 PM, Grant Rettke gret...@acm.org wrote:

 On Thu, Oct 18, 2012 at 2:50 PM, Mark Engelberg
 mark.engelb...@gmail.com wrote:
  Either way works well.  I think Evan's way results in somewhat more
  compact
  code for the common case, whereas Cgrand's way feels a little more
  versatile
  (and his flatter cond is what I use).  I strongly urge you to pick one
  of
  these two techniques and include it in your project.  Once you try it
  and
  see how much cleaner the code is, you'll be hooked.

 Is it poor form to do something like this inside a defn?

  (def a 1)
   (println this is a:  a)
   (def b 2)
   (println this is b:  b)
   (def c 3)
   (println this is c:  c)
   (println Sum:  (+ a b c))


 very poor form. def is always top level.

It is poor form in that it will break things in confusing and horrible
ways or poor form from a style perspective?

When you use def inside a defn is it equivalent to a let binding like this?

(defn foo []
  (def a 1)
  (println a))

(defn foo []
  ((fn [a]
 (println a)) 1))

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

2012-10-18 Thread Denis Labaye
bravo!

On Thu, Oct 18, 2012 at 9:29 PM, Brian Kirkbride 
br...@otherpeoplespixels.com wrote:

 Congratulations Rich. Many thanks to you and the many people that have
 contributed to making Clojure what it is today.

 Learning and using Clojure has truly brought the joy back to creating
 software and I needed that!

 Best,
 Brian

 On Tuesday, October 16, 2012 8:53:55 PM UTC-5, Rich Hickey wrote:

 I released Clojure 5 years ago today. It's been a terrific ride so far.

 Thanks to everyone who contributes to making Clojure, and its community,
 great.

 Rich

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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 4:22 PM, Grant Rettke gret...@acm.org wrote:


 When you use def inside a defn is it equivalent to a let binding like this?

 (defn foo []
   (def a 1)
   (println a))

 (defn foo []
   ((fn [a]
  (println a)) 1))


Not equivalent.

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

2012-10-18 Thread abp
You probably want to watch this:
vimeo.com/46163090

Also, try to think of your programs in terms of pipelines as much as 
possible.
You get input, you produce output.
That probably applies to every program ever written, but when you get how 
that works in Clojure, it's like an enlightment, at least it was for me.
You can then structure all the processes in your program like that, and 
wire those up until you're done.

On Thursday, October 18, 2012 5:51:23 AM UTC+2, Brian Craft wrote:

 I'm finding the books on clojure to be very focused on low-level language 
 features. Are there any good references for how to design code in clojure 
 (or perhaps in functional languages more generally)? For example, knowing 
 when to use a data type or a protocol, knowing when and how to separate 
 purely functional code from code with side effects, making use of monads, 
 queues, and the other forms that one hears about in the forums, etc.

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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 3:32 PM, David Nolen dnolen.li...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 4:22 PM, Grant Rettke gret...@acm.org wrote:


 When you use def inside a defn is it equivalent to a let binding like
 this?

 (defn foo []
   (def a 1)
   (println a))

 (defn foo []
   ((fn [a]
  (println a)) 1))


 Not equivalent.

I see. To what is it equivalent?

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

2012-10-18 Thread Mark Engelberg
A def, even inside defn, creates and binds a global variable.

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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 3:42 PM, Mark Engelberg
mark.engelb...@gmail.com wrote:
 A def, even inside defn, creates and binds a global variable.

Woa, I see, 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: Replacing nested let statements with assignments

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 3:45 PM, Grant Rettke gret...@acm.org wrote:
 On Thu, Oct 18, 2012 at 3:42 PM, Mark Engelberg
 mark.engelb...@gmail.com wrote:
 A def, even inside defn, creates and binds a global variable.

 Woa, I see, thanks!

Anyone voted for internal define lately?

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

2012-10-18 Thread Brian Marick

On Oct 17, 2012, at 2:35 PM, Andreas Liljeqvist wrote:
 Just to clear something up: Are you maintaining midje-mode?
 I thought it was Dmitri?
 That's where I left my pull request anyway.

I'm a committer for `midje-mode`.

-
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
Writing /Functional Programming for the Object-Oriented Programmer/: 
https://leanpub.com/fp-oo


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

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 4:45 PM, Grant Rettke gret...@acm.org wrote:

 On Thu, Oct 18, 2012 at 3:45 PM, Grant Rettke gret...@acm.org wrote:
  On Thu, Oct 18, 2012 at 3:42 PM, Mark Engelberg
  mark.engelb...@gmail.com wrote:
  A def, even inside defn, creates and binds a global variable.
 
  Woa, I see, thanks!

 Anyone voted for internal define lately?


At this point I think it's highly unlikely to change - the behavior is
pretty well documented:

user= (doc def)
-
def
  (def symbol doc-string? init?)
Special Form
  Creates and interns a global var with the name
  of symbol in the current namespace (*ns*) or locates such a var if
  it already exists.  If init is supplied, it is evaluated, and the
  root binding of the var is set to the resulting value.  If init is
  not supplied, the root binding of the var is unaffected.

  Please see http://clojure.org/special_forms#def

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

2012-10-18 Thread JvJ
Exactly.  Not only debugging, but java interop that involved calling 
methods with side effects.

On Thursday, 18 October 2012 15:02:47 UTC-4, David Nolen wrote:

 On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy al...@malloys.orgjavascript:
  wrote:

 It's rare to get tired of this, because nobody does it: it's not
 common because your interleaved statements are side-effecting only,
 which is not encouraged in Clojure, and rarely needed. Certainly
 sometimes it's the best way to do something, but not so often that I'd
 become frustrated; if anything, having to write such irritating code
 can serve as a good reminder that I shouldn't have so many
 unrestrained side effects scattered through my logic.


 I think from the examples debugging via print statements was the main (and 
 reasonable) use case.

 David 
  

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

Re: Replacing nested let statements with assignments

2012-10-18 Thread Grant Rettke
I figured you would use doto for that.

On Thu, Oct 18, 2012 at 4:09 PM, JvJ kfjwhee...@gmail.com wrote:
 Exactly.  Not only debugging, but java interop that involved calling methods
 with side effects.

 On Thursday, 18 October 2012 15:02:47 UTC-4, David Nolen wrote:

 On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy al...@malloys.org wrote:

 It's rare to get tired of this, because nobody does it: it's not
 common because your interleaved statements are side-effecting only,
 which is not encouraged in Clojure, and rarely needed. Certainly
 sometimes it's the best way to do something, but not so often that I'd
 become frustrated; if anything, having to write such irritating code
 can serve as a good reminder that I shouldn't have so many
 unrestrained side effects scattered through my logic.


 I think from the examples debugging via print statements was the main (and
 reasonable) use case.

 David

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



-- 
Grant Rettke | ACM, AMA, COG, IEEE
gret...@acm.org | http://www.wisdomandwonder.com/
Wisdom begins in wonder.
((λ (x) (x x)) (λ (x) (x x)))

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

2012-10-18 Thread Grant Rettke
On Thu, Oct 18, 2012 at 4:05 PM, David Nolen dnolen.li...@gmail.com wrote:
 On Thu, Oct 18, 2012 at 4:45 PM, Grant Rettke gret...@acm.org wrote:
 Anyone voted for internal define lately?
 At this point I think it's highly unlikely to change - the behavior is
 pretty well documented:

I see. Just a thought that an internal define not necessarily 'def'
might be a nice idea for a lot of these cases, but then again hey it
is lisp we can tweak it to our liking.

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

2012-10-18 Thread JvJ
On a side note, I was partially inspired by Haskell's do notation, which is 
imperative-looking syntactic sugar for monadic binds.

On Thursday, 18 October 2012 12:01:33 UTC-4, JvJ wrote:

 I'm not sure if anyone's done this before, but I'm fed up with writing 
 code that looks like this:

 (let [a 1]
(println this is a:  a)
(let [b 2]
(println this is b:  b)
(let [c 3]
 (println this is c:  c)
 (+ a b c

 I'd rather do something more like this:
 (-:
(:= a 1) ;; Assign a to 1
(println this is a:  a)
(:= b 2)
(println this is b:  b)
(:= c 3)
(println this is c:  c)
(+ a b c))


 I wrote a macro to do this, but I feel like it's such a simple thing that 
 someone must have done it before, and it's probably better than mine.
 Does anyone know of anything like that? 

 Here's the code for it in case anyone wants to use it:

 (ns cljutils.core)

 (defn- form-check
   Ensures the form represents an assignment.
 Such as (:= a 1)
   [form]
   (and
(= 3 (count form))
(= := (first form))
(symbol? (second form


 (defn- iblk-fn
   Simulates imperative variable-assignments through nested
 let statements.
   [ forms]
   (let [form (first forms)
 rforms (rest forms)]
 (if-not form
   nil
   ;; Else
   `(do
  ~@(if (form-check form)
  `((let [~(second form) ~(nth form 2)]
  ~(apply iblk-fn rforms)))
  (let [[f r] (split-with (comp not form-check) forms)]
 (concat
  f
  (apply iblk-fn r

 (defmacro -:
   [ forms]
   (apply iblk-fn forms))


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

2012-10-18 Thread JvJ

On a side note, I was partially inspired by Haskell's do notation, which is 
imperative-looking syntactic sugar for monadic bind operators.

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

2012-10-18 Thread JvJ
Most of what could be accomplished by an internal define could be done with 
a let statement.  But if you don't want to add the brackets, you can create 
your own function definition macro that converts defs to lets.

On Thursday, 18 October 2012 17:12:04 UTC-4, Grant Rettke wrote:

 On Thu, Oct 18, 2012 at 4:05 PM, David Nolen 
 dnolen...@gmail.comjavascript: 
 wrote: 
  On Thu, Oct 18, 2012 at 4:45 PM, Grant Rettke gre...@acm.orgjavascript: 
 wrote: 
  Anyone voted for internal define lately? 
  At this point I think it's highly unlikely to change - the behavior is 
  pretty well documented: 

 I see. Just a thought that an internal define not necessarily 'def' 
 might be a nice idea for a lot of these cases, but then again hey it 
 is lisp we can tweak it to our liking. 


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

2012-10-18 Thread JvJ
The doto form is great, but as far as I know, it only lets you thread a 
single object.  I'm looking at creating several objects consecutively.

On Thursday, 18 October 2012 17:11:08 UTC-4, Grant Rettke wrote:

 I figured you would use doto for that. 

 On Thu, Oct 18, 2012 at 4:09 PM, JvJ kfjwh...@gmail.com javascript: 
 wrote: 
  Exactly.  Not only debugging, but java interop that involved calling 
 methods 
  with side effects. 
  
  On Thursday, 18 October 2012 15:02:47 UTC-4, David Nolen wrote: 
  
  On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy al...@malloys.org 
 wrote: 
  
  It's rare to get tired of this, because nobody does it: it's not 
  common because your interleaved statements are side-effecting only, 
  which is not encouraged in Clojure, and rarely needed. Certainly 
  sometimes it's the best way to do something, but not so often that I'd 
  become frustrated; if anything, having to write such irritating code 
  can serve as a good reminder that I shouldn't have so many 
  unrestrained side effects scattered through my logic. 
  
  
  I think from the examples debugging via print statements was the main 
 (and 
  reasonable) use case. 
  
  David 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 



 -- 
 Grant Rettke | ACM, AMA, COG, IEEE 
 gre...@acm.org javascript: | http://www.wisdomandwonder.com/ 
 Wisdom begins in wonder. 
 ((λ (x) (x x)) (λ (x) (x x))) 


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

2012-10-18 Thread Mark Engelberg
On Thu, Oct 18, 2012 at 1:45 PM, Grant Rettke gret...@acm.org wrote:


 Anyone voted for internal define lately?


On the one hand, internal define would be nice because it would help
alleviate the nested let problem and possibly be more intuitive for
newcomers.

On the other hand, sometimes (rarely) you actually want to have a function
create global variables.  If def didn't work the way it did, it would be
extremely difficult to achieve that effect.

Since there are other ways to create local variables (albeit with the
unfortunate consequence of increasing the indenting level) but no other
convenient way to create global variables, the decision to have def always
affect the top-level environment seems to me like it creates the most
semantically expressive power.  So overall, I like it the way it is.

That said, in my own code I find it essential to work with one of the
macros that provide a way to intermingle locals and conditionals without
indenting the code halfway across the screen.  I'd like to see some
standard way to do this eventually work its way into Clojure core.

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

2012-10-18 Thread AtKaaZ
deja-vu :)

On Thu, Oct 18, 2012 at 11:16 PM, JvJ kfjwhee...@gmail.com wrote:


 On a side note, I was partially inspired by Haskell's do notation, which
 is imperative-looking syntactic sugar for monadic bind operators.

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




-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

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

2012-10-18 Thread abp
Now I remember the more important video:
www.infoq.com/presentations/Thinking-in-Data

Also (haven't watched):
www.infoq.com/presentations/Programming-with-Values-in-Clojure

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

2012-10-18 Thread Stuart Sierra
It's slightly different, but libraries such as Flow or Prismatic's Graph 
can be used to achieve a similar effect.

Flow: https://github.com/stuartsierra/flow
Graph: 
http://blog.getprismatic.com/blog/2012/10/1/prismatics-graph-at-strange-loop.html

Example using Flow:

(def the-flow
  (flow b ([a] (println This is a: a) 2)
c ([b] (println This is b: b) 3)
out ([a b c]
   (println This is c: c)
   (+ a b c

(def the-fn (flow-fn the-flow [a] out))

(the-fn 1)
;; This is a: 1
;; This is b: 2
;; This is c: 3
;;= 6

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

Redubicle NIO

2012-10-18 Thread Bruno França dos Reis
Hello!

I've recently started playing with Clojure, and a couple of days ago I've 
been pointed to Reducers in Clojure 1.5 after a discussion on #clojure at 
Freenode.

I've read Rich's posts announcing the Reducers library, and he says that 
there's a ***lack of reducible IO sources***. I'm working on a project that 
in which I analyze lots of data (from huge files on disk), and I'm 
frequently doing reduce operations on it. I began by writing a custom 
sequence, that after I transformed in a custom reducible collection. But 
I've just noticed that I could encapsulate it on a kind of reducible IO 
source.

I'm writing this message to share the code I wrote relating to reducible IO 
sources, if anybody sees any use for it. The idea is to make the ***NIO 
Buffers reducible***, so that you can open huge files as **memory mapped 
files**, which are instances of `ByteBuffer`. You can then obtain instances 
of other buffers, say, `LongBuffer` (which is what I'm using on my current 
project), which are also reducible:

(defmacro buffer-reduce [b f val]
  `(let [b# (.duplicate ~b)]
 (loop [remaining# (.remaining b#)
result# ~val]
   (if (zero? remaining#)
 result#
 (recur (dec remaining#) (~f result# (.get ~b)))

(extend-protocol clojure.core.protocols/CollReduce
  java.nio.ByteBuffer
  (coll-reduce [b f] (coll-reduce b f (f)))
  (coll-reduce [b f val] (buffer-reduce b f val))

  java.nio.LongBuffer
  (coll-reduce [b f] (coll-reduce b f (f)))
  (coll-reduce [b f val] (buffer-reduce b f val))

  ; ... other kinds of buffer ...
)


Hope this might be useful for someone.

Bruno

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

2012-10-18 Thread Bruno França dos Reis
Damn, just noticed a small mistake in the macro: I use the original buffer, 
not the duplicated one. Here's the correct version:

(defmacro buffer-reduce [b f val]
  `(let [b# (.duplicate ~b)]
 (loop [remaining# (.remaining b#)
result# ~val]
   (if (zero? remaining#)
 result#
 (recur (dec remaining#) (~f result# (.get b#)))

(extend-protocol clojure.core.protocols/CollReduce
  java.nio.ByteBuffer
  (coll-reduce [b f] (coll-reduce b f (f)))
  (coll-reduce [b f val] (buffer-reduce b f val))

  java.nio.LongBuffer
  (coll-reduce [b f] (coll-reduce b f (f)))
  (coll-reduce [b f val] (buffer-reduce b f val))

  ; ... other kinds of buffer ...
)

Sorry for that.

On Thursday, October 18, 2012 6:50:07 PM UTC-3, Bruno França dos Reis wrote:

 Hello!

 I've recently started playing with Clojure, and a couple of days ago I've 
 been pointed to Reducers in Clojure 1.5 after a discussion on #clojure at 
 Freenode.

 I've read Rich's posts announcing the Reducers library, and he says that 
 there's a ***lack of reducible IO sources***. I'm working on a project 
 that in which I analyze lots of data (from huge files on disk), and I'm 
 frequently doing reduce operations on it. I began by writing a custom 
 sequence, that after I transformed in a custom reducible collection. But 
 I've just noticed that I could encapsulate it on a kind of reducible IO 
 source.

 I'm writing this message to share the code I wrote relating to reducible 
 IO sources, if anybody sees any use for it. The idea is to make the ***NIO 
 Buffers reducible***, so that you can open huge files as **memory mapped 
 files**, which are instances of `ByteBuffer`. You can then obtain 
 instances of other buffers, say, `LongBuffer` (which is what I'm using on 
 my current project), which are also reducible:

 (defmacro buffer-reduce [b f val]
   `(let [b# (.duplicate ~b)]
  (loop [remaining# (.remaining b#)
 result# ~val]
(if (zero? remaining#)
  result#
  (recur (dec remaining#) (~f result# (.get ~b)))

 (extend-protocol clojure.core.protocols/CollReduce
   java.nio.ByteBuffer
   (coll-reduce [b f] (coll-reduce b f (f)))
   (coll-reduce [b f val] (buffer-reduce b f val))

   java.nio.LongBuffer
   (coll-reduce [b f] (coll-reduce b f (f)))
   (coll-reduce [b f val] (buffer-reduce b f val))

   ; ... other kinds of buffer ...
 )


 Hope this might be useful for someone.

 Bruno


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

2012-10-18 Thread Maurits
Bit of a late reaction, but there is nothing special about a tag with a 
namespace prefixed. For example I have been using:

(zf/xml- zipper :ListRecords :record :metadata :oai_dc:dc :dc:language 
zf/text)

which works perfectly well.

Maurits

Op zondag 22 juli 2012 22:02:59 UTC+2 schreef Marcel Möhring het volgende:

 Hi, 

 I am trying to parse an xpdl file. The problem for me is, that every tag 
 is prefixed with xpdl namespace. The lookup from clojure.data.zip.xml 
 always returns nil. 
 (the same code works for non-prefixed XMLs) 

 zipper: 
 [{:tag :xpdl:Package, 
:attrs 
{:xmlns:xpdl http://www.wfmc.org/2008/XPDL2.1;, 
 :xmlns http://www.wfmc.org/2008/XPDL2.1;, 
 :xmlns:xsi http://www.w3.org/2001/XMLSchema-instance;, 
 :Id testPackage, 
 :Name Test-Package, 
 :xsi:schemaLocation 
 http://www.wfmc.org/2008/XPDL2.1 
 http://www.wfmc.org/standards/docs/bpmnxpdl_31.xsd}, 
 ... 

 code: 
 (ns test.core 
(:require [clojure.zip :as zip] 
  [clojure.xml :as xml] 
  [clojure.data.zip.xml :as cdzip])) 

 (def zipper (zip/xml-zip (xml/parse res/testPackage.xpdl))) 

 (cdzip/xml- zipper :xpdl:Package) 
 returns nil 

 (cdzip/xml- zipper (keyword xpdl:Package)) 
 also returns nil 

 Does anybody know how to handle lookups in such XMLs? 



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

2012-10-18 Thread Alan Malloy
As a general-macro aside, you are multiply-evaluating the `f`
argument, by expanding it in-place inside the recursive clause. This
is almost certainly not what you want, and you could avoid it by
starting with (let [f# ~f] ...). Better still, ask why this is a macro
at all. This should really just be a function, because you don't
introduce any new syntax, and you don't delay evaluation of anything.

On Oct 18, 2:56 pm, Bruno França dos Reis bfr...@gmail.com wrote:
 Damn, just noticed a small mistake in the macro: I use the original buffer,
 not the duplicated one. Here's the correct version:

 (defmacro buffer-reduce [b f val]
   `(let [b# (.duplicate ~b)]
      (loop [remaining# (.remaining b#)
             result# ~val]
        (if (zero? remaining#)
          result#
          (recur (dec remaining#) (~f result# (.get b#)))

 (extend-protocol clojure.core.protocols/CollReduce
   java.nio.ByteBuffer
   (coll-reduce [b f] (coll-reduce b f (f)))
   (coll-reduce [b f val] (buffer-reduce b f val))

   java.nio.LongBuffer
   (coll-reduce [b f] (coll-reduce b f (f)))
   (coll-reduce [b f val] (buffer-reduce b f val))

   ; ... other kinds of buffer ...
 )

 Sorry for that.

 On Thursday, October 18, 2012 6:50:07 PM UTC-3, Bruno França dos Reis wrote:









  Hello!

  I've recently started playing with Clojure, and a couple of days ago I've
  been pointed to Reducers in Clojure 1.5 after a discussion on #clojure at
  Freenode.

  I've read Rich's posts announcing the Reducers library, and he says that
  there's a ***lack of reducible IO sources***. I'm working on a project
  that in which I analyze lots of data (from huge files on disk), and I'm
  frequently doing reduce operations on it. I began by writing a custom
  sequence, that after I transformed in a custom reducible collection. But
  I've just noticed that I could encapsulate it on a kind of reducible IO
  source.

  I'm writing this message to share the code I wrote relating to reducible
  IO sources, if anybody sees any use for it. The idea is to make the ***NIO
  Buffers reducible***, so that you can open huge files as **memory mapped
  files**, which are instances of `ByteBuffer`. You can then obtain
  instances of other buffers, say, `LongBuffer` (which is what I'm using on
  my current project), which are also reducible:

  (defmacro buffer-reduce [b f val]
    `(let [b# (.duplicate ~b)]
       (loop [remaining# (.remaining b#)
              result# ~val]
         (if (zero? remaining#)
           result#
           (recur (dec remaining#) (~f result# (.get ~b)))

  (extend-protocol clojure.core.protocols/CollReduce
    java.nio.ByteBuffer
    (coll-reduce [b f] (coll-reduce b f (f)))
    (coll-reduce [b f val] (buffer-reduce b f val))

    java.nio.LongBuffer
    (coll-reduce [b f] (coll-reduce b f (f)))
    (coll-reduce [b f val] (buffer-reduce b f val))

    ; ... other kinds of buffer ...
  )

  Hope this might be useful for someone.

  Bruno

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


profiling question: ReadAheadInputStream.fill

2012-10-18 Thread Brian Craft
Another java newbie question, I expect. I tried using jvisualvm to profile 
my clojure app. It's spending all its time in 
jdbc.util.ReadAheadInputStream.fill(). The call tree points to 
clojure-agent-send-off-pool-n. I'm not sure what this is telling me.

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

Re: code design in clojure

2012-10-18 Thread Brian Craft
Thanks to everyone for the suggestions!

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

2012-10-18 Thread Bruno França dos Reis
Thanks for the input. Didn't know that I was multiply-evaluating f.

The reason why I wrote a macro instead of a function is because 'get' and
'duplicate' are not declared in any common superclass of the different
buffers, so I was getting lots of reflection!

Are there alternatives to the macro that avoid reflection?

Thanks
On Oct 18, 2012 7:33 PM, Alan Malloy a...@malloys.org wrote:

 As a general-macro aside, you are multiply-evaluating the `f`
 argument, by expanding it in-place inside the recursive clause. This
 is almost certainly not what you want, and you could avoid it by
 starting with (let [f# ~f] ...). Better still, ask why this is a macro
 at all. This should really just be a function, because you don't
 introduce any new syntax, and you don't delay evaluation of anything.

 On Oct 18, 2:56 pm, Bruno França dos Reis bfr...@gmail.com wrote:
  Damn, just noticed a small mistake in the macro: I use the original
 buffer,
  not the duplicated one. Here's the correct version:
 
  (defmacro buffer-reduce [b f val]
`(let [b# (.duplicate ~b)]
   (loop [remaining# (.remaining b#)
  result# ~val]
 (if (zero? remaining#)
   result#
   (recur (dec remaining#) (~f result# (.get b#)))
 
  (extend-protocol clojure.core.protocols/CollReduce
java.nio.ByteBuffer
(coll-reduce [b f] (coll-reduce b f (f)))
(coll-reduce [b f val] (buffer-reduce b f val))
 
java.nio.LongBuffer
(coll-reduce [b f] (coll-reduce b f (f)))
(coll-reduce [b f val] (buffer-reduce b f val))
 
; ... other kinds of buffer ...
  )
 
  Sorry for that.
 
  On Thursday, October 18, 2012 6:50:07 PM UTC-3, Bruno França dos Reis
 wrote:
 
 
 
 
 
 
 
 
 
   Hello!
 
   I've recently started playing with Clojure, and a couple of days ago
 I've
   been pointed to Reducers in Clojure 1.5 after a discussion on #clojure
 at
   Freenode.
 
   I've read Rich's posts announcing the Reducers library, and he says
 that
   there's a ***lack of reducible IO sources***. I'm working on a project
   that in which I analyze lots of data (from huge files on disk), and I'm
   frequently doing reduce operations on it. I began by writing a custom
   sequence, that after I transformed in a custom reducible collection.
 But
   I've just noticed that I could encapsulate it on a kind of reducible IO
   source.
 
   I'm writing this message to share the code I wrote relating to
 reducible
   IO sources, if anybody sees any use for it. The idea is to make the
 ***NIO
   Buffers reducible***, so that you can open huge files as **memory
 mapped
   files**, which are instances of `ByteBuffer`. You can then obtain
   instances of other buffers, say, `LongBuffer` (which is what I'm using
 on
   my current project), which are also reducible:
 
   (defmacro buffer-reduce [b f val]
 `(let [b# (.duplicate ~b)]
(loop [remaining# (.remaining b#)
   result# ~val]
  (if (zero? remaining#)
result#
(recur (dec remaining#) (~f result# (.get ~b)))
 
   (extend-protocol clojure.core.protocols/CollReduce
 java.nio.ByteBuffer
 (coll-reduce [b f] (coll-reduce b f (f)))
 (coll-reduce [b f val] (buffer-reduce b f val))
 
 java.nio.LongBuffer
 (coll-reduce [b f] (coll-reduce b f (f)))
 (coll-reduce [b f val] (buffer-reduce b f val))
 
 ; ... other kinds of buffer ...
   )
 
   Hope this might be useful for someone.
 
   Bruno

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

2012-10-18 Thread Herwig Hochleitner
2012/10/18 Mark Engelberg mark.engelb...@gmail.com

 When I want to add print commands for debugging, I usually either do it
 the way David Nolen described, i.e., binding _ to a printf statement, or I
 use a little utility macro like this (picked up from stackoverflow):

 (defmacro dbg[x] `(let [x# ~x] (println dbg: '~x = x#) x#))


FWIW, when just wanting to print out debug values, I use a custom reader
tag similar to the above macro:

(let [x #log/spy (+ a b)]
  (usage-of x))

Even though it's probably an abuse of the idea of reader tags, it has the
advantage that its quickly added and removed, even without paredit.
Of course, that doesn't solve the mixed-let-cond problem.

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

2012-10-18 Thread Herwig Hochleitner
2012/10/19 Bruno França dos Reis bfr...@gmail.com

 The reason why I wrote a macro instead of a function is because 'get' and
 'duplicate' are not declared in any common superclass of the different
 buffers, so I was getting lots of reflection!

 Are there alternatives to the macro that avoid reflection?

 You could use a protocol for that, though it might not be quite as fast as
the directly type hinted version, but certainly faster than reflection.

kind regards

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

2012-10-18 Thread Brian Craft
C is a C-language, and it seems a lot simpler than clojure to me. KR is 
about 200 pages. I expect you mean C++, Java, etc. Not meaning to start a 
language war, but my own experiences with C++ and Java have mostly 
convinced me that the added complexity in those languages don't lead to 
better code: quite the opposite. I tend to agree with Torvald's amusing 
rants on this subject. So, yeah, coming from C, javascript, scheme, and 
what-not, clojure seems like it has a large number of different ideas baked 
into it. Maybe it's the right number of ideas. I'm only a couple weeks into 
it. So far it's all been good, except for when I have to muck with java 
stuff. ;)

On Thursday, October 18, 2012 10:08:14 AM UTC-7, Sean Corfield wrote:

 On Thu, Oct 18, 2012 at 9:37 AM, Brian Craft craft...@gmail.comjavascript:
  wrote:

 I suspect that if you come from java or C++ it seems like a simple 
 language, but it feels pretty cluttered compared to other languages.


 Interesting observation and probably true. Although I did Lisp back at 
 university (in the early/mid-80's), most of my career has been in C-family 
 languages so, yes, Clojure feels like a VERY simple language with almost no 
 syntax. Having recently read more Scheme / CL code, I can see how folks 
 coming from those languages think Clojure is cluttered. But it's SO much 
 simpler than the C-languages that it must surely be only a little more 
 cluttered than Scheme / CL? Do the differences really seem that big? 
 Genuine question, since I've been immersed in C-languages for so long...
 -- 
 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

Re: Redubicle NIO

2012-10-18 Thread David Nolen
On Thu, Oct 18, 2012 at 7:15 PM, Herwig Hochleitner
hhochleit...@gmail.comwrote:

 2012/10/19 Bruno França dos Reis bfr...@gmail.com

 The reason why I wrote a macro instead of a function is because 'get' and
 'duplicate' are not declared in any common superclass of the different
 buffers, so I was getting lots of reflection!

 Are there alternatives to the macro that avoid reflection?

  You could use a protocol for that, though it might not be quite as fast
 as the directly type hinted version, but certainly faster than reflection.

 kind regards


Or write a macro that can take a type and create a type specialized version
of buffer-reduce - long-buffer-reduce, byte-buffer-reduce etc.

David

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

Re: Replacing nested let statements with assignments

2012-10-18 Thread Mark Engelberg
On Thu, Oct 18, 2012 at 4:11 PM, Herwig Hochleitner
hhochleit...@gmail.comwrote:


 FWIW, when just wanting to print out debug values, I use a custom reader
 tag similar to the above macro:

 (let [x #log/spy (+ a b)]
   (usage-of x))



That's nice!  I haven't done anything with reader macros.  Can you post the
implementation?

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

2012-10-18 Thread Mark Engelberg
OK, just looked it up and realized that it's just how # works, and not a
special kind of macro.

On Thu, Oct 18, 2012 at 5:25 PM, Mark Engelberg mark.engelb...@gmail.comwrote:

 On Thu, Oct 18, 2012 at 4:11 PM, Herwig Hochleitner 
 hhochleit...@gmail.com wrote:


 FWIW, when just wanting to print out debug values, I use a custom reader
 tag similar to the above macro:

 (let [x #log/spy (+ a b)]
   (usage-of x))



 That's nice!  I haven't done anything with reader macros.  Can you post
 the implementation?


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

2012-10-18 Thread Bruno França dos Reis
So, the current version, after the suggestion by Alan Malloy, is the 
following:

(defmacro buffer-reduce [b f val]
  `(let [b# (.duplicate ~b)
 f# ~f]
 (loop [remaining# (.remaining b#)
result# ~val]
   (if (zero? remaining#)
 result#
 (recur (dec remaining#) (f# result# (.get b#)))

(extend-protocol clojure.core.protocols/CollReduce
  java.nio.ByteBuffer
  (coll-reduce [b f] (coll-reduce b f (f)))
  (coll-reduce [b f val] (buffer-reduce b f val))

  java.nio.LongBuffer
  (coll-reduce [b f] (coll-reduce b f (f)))
  (coll-reduce [b f val] (buffer-reduce b f val))

  ; ... other kinds of buffer ...
)


About the other suggestions:

 - Herwig Holchleitner: how would that solution with protocols be? I write 
a protocol that defines methods like `get` and `duplicate` and extend it 
for each buffer, delegating the methods to their specific implementations? 
ie, (defprotocol UnifiedBuffers (get [buff] get data from buf) (duplicate 
[buff] duplicates buff)), (extend-protocol UnifiedBuffers ByteBuffer 
(get [buff] (.get buff)) LongBuffer (get [buff] (.get buff)))?

 - David: about the solution you propose, is it somehow considered 
cleaner or faster or more idiomatic or, in any way, better than the 
solution I'm proposing? The advantages might be way more subtle than my 
small knowledge of Clojure allow me to understand -- I'm new in the Clojure 
community, I might be missing some common idioms. I'd be glad if you could 
expand on that!


Thanks!


On Thursday, October 18, 2012 8:44:41 PM UTC-3, David Nolen wrote:

 On Thu, Oct 18, 2012 at 7:15 PM, Herwig Hochleitner 
 hhochl...@gmail.comjavascript:
  wrote:

 2012/10/19 Bruno França dos Reis bfr...@gmail.com javascript:

 The reason why I wrote a macro instead of a function is because 'get' 
 and 'duplicate' are not declared in any common superclass of the different 
 buffers, so I was getting lots of reflection!

 Are there alternatives to the macro that avoid reflection?

  You could use a protocol for that, though it might not be quite as fast 
 as the directly type hinted version, but certainly faster than reflection.

 kind regards


 Or write a macro that can take a type and create a type specialized 
 version of buffer-reduce - long-buffer-reduce, byte-buffer-reduce etc.

 David 


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

  1   2   >