Re: Clojure lib for blocking io ?

2014-04-27 Thread makkalot

Hi,

Yeah, what I mean is non-blocking io or async io.

Thanks.

On 04/28/2014 09:07 AM, Atamert Ölçgen wrote:




On Mon, Apr 28, 2014 at 1:50 PM, makkalot > wrote:


Hi,

What would be recommended way of handling lots of blocking io
concurrent connections ? Apparently, core.async is not very good
match for this job, because of its limited thread pool and thread
(thread  macro) per connection design. Which library would be a
good fit for that ? aleph, pulsar (very interesting but not sure
how mature it is), netty ?


I think you mean non-blocking IO.

IO blocks without any special library or effort.


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

Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com

Note that posts from new members are moderated - please be patient
with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com

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




--
Kind Regards,
Atamert Ölçgen

-+-
--+
+++

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

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

For more options, visit https://groups.google.com/d/optout.


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

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure lib for blocking io ?

2014-04-27 Thread Atamert Ölçgen
On Mon, Apr 28, 2014 at 1:50 PM, makkalot  wrote:

>  Hi,
>
> What would be recommended way of handling lots of blocking io concurrent
> connections ? Apparently, core.async is not very good match for this job,
> because of its limited thread pool and thread (thread  macro) per
> connection design. Which library would be a good fit for that ? aleph,
> pulsar (very interesting but not sure how mature it is), netty ?
>

I think you mean non-blocking IO.

IO blocks without any special library or effort.



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



-- 
Kind Regards,
Atamert Ölçgen

-+-
--+
+++

www.muhuk.com

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


New Functional Programming Job Opportunities

2014-04-27 Thread Functional Jobs
Here are some functional programming job opportunities that were posted

recently:



functional software developer at OpinionLab

http://functionaljobs.com/jobs/8706-functional-software-developer-at-opinionlab



Cheers,

Sean Murphy

FunctionalJobs.com


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


Clojure lib for blocking io ?

2014-04-27 Thread makkalot

Hi,

What would be recommended way of handling lots of blocking io concurrent 
connections ? Apparently, core.async is not very good match for this 
job, because of its limited thread pool and thread (thread  macro) per 
connection design. Which library would be a good fit for that ? aleph, 
pulsar (very interesting but not sure how mature it is), netty ?


Thanks.

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

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Marc Limotte
I don't know the details of your particular use, but for a general solution
to the resource management problem, maybe Stuart Sierra's
componentsystem would work
for you.

marc


On Sun, Apr 27, 2014 at 10:30 AM, Peter B. West wrote:

>
> On 27 Apr 2014, at 7:40 pm, Carlo Zancanaro 
> wrote:
>
> > I'm struggling to understand the problem that you're actually trying to
> > solve. The solution that you are proposing doesn't seem like an elegant
> > solution to any problem, so could you elaborate on what you're trying to
> > do?
> >
>
> http://dev.clojure.org/display/design/Resource+Scopes
>
> It doesn't take long to run into this problem.
>
> From http://stuartsierra.com/2013/03/29/perils-of-dynamic-scope
>
> "Resource management is one concurrency bugaboo that Clojure developers
> have not managed to crack. Various attempts have been made: you can see the
> artifacts in wiki and mailing list discussions of Resource Scopes. So far,
> no solution has been found that doesn’t just shift the problem somewhere
> else."
>
> I have no ambitions to solve the general problem; just to find a workable
> solution for my own use.
>
> > On Fri, Apr 25, 2014 at 08:58:42AM -0700, Peter West wrote:
> >> One interesting thing about intern is that it will create *or find* a
> var,
> >> setting its root binding.  That means that var circumvents the
> immutability
> >> of a var, doesn't it? I thought vars were supposed to be immutable.
> >
> > Vars are not immutable. Clojure has four datatypes which are used for
> > mutability: Agents, Atoms, Refs and Vars. As I said originally, your
> > function is mutating the global scope, whether by using `intern` or by
> > using `def`, and this is generally not a good idea. There is (almost), a
> > better solution than mutating the global state.
>
> I mistook the intention of binding as being the only way to modify a var.
>  I was influenced by the XSLT notion of "variable."  Thanks for clearing up
> that misconception.
>

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


{{ANN} clj-xmemcached release 0.2.4

2014-04-27 Thread dennis zhuang
An opensource memcached client for clojure,it wraps xmemcached.

0.2.4 releases, main highlights:

   - Upgrade xmemcached to
2.0.0,
   10% performance improved for text protocol and fixed some issues.
   - Added nippy-transcoder to support
nippyserialization.
   - Added expiration time parameters for incr/decr functions.
   - Added :session-locator option for memcached function to use special
   
MemcachedSessionLocator
   .

Manual and home:  https://github.com/killme2008/clj-xmemcached

Thanks.

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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


Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Carlo Zancanaro
On Mon, Apr 28, 2014 at 12:30:00AM +1000, Peter B. West wrote:
> I have no ambitions to solve the general problem; just to find a
> workable solution for my own use.

What is your own use? Your current solution involves using a shared
global variable to communicate between two functions, and tying up a
thread to wait to close a file handle. Both of these issues I consider
to be "unworkable".

There are other ways to manage resource scope, though. For instance, you
could have your "lazy-lines" function return a lazy-sequence which will
close the file on completely reading the stream:

  (defn lazy-lines [resource]
(let [r ^java.io.Reader (vcf-res-reader resource)
  close #(.close r)]
  (concat (line-seq r)
  (lazy-seq (close)

Or one which provides you a function to close the stream when you want
to:

  (defn lazy-lines [resource]
(let [r ^java.io.Reader (vcf-res-reader resource)
  close #(.close r)]
  (with-meta (line-seq r)
{:close close})))

Or one which does both:

  (defn lazy-lines [resource]
(let [r ^java.io.Reader (vcf-res-reader resource)
  close #(.close r)]
  (with-meta (concat (line-seq r)
 (lazy-seq (close))) ;; close if we're done
{:close close}))) ;; also provide the close function externally

None of these options mutate any global, shared memory. They all return
a sequence directly to the caller, and none of them require any sort of
coordination with other threads.


signature.asc
Description: Digital signature


Re: Strange dot behaviour

2014-04-27 Thread Andy Fingerhut
I believe you are hitting this issue, which was fixed in Clojure 1.6.0

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

Andy


On Sun, Apr 27, 2014 at 2:20 PM, Simon Doherty wrote:

> We're encountering some strange behaviour with the instance? function. The
> first two examples are expected behaviour:
>
> (instance? Double 42.0)
>> => true
>> (instance? 99 42.0)
>> ClassCastException java.lang.Long cannot be cast to java.lang.Class
>
>
> but the next is not:
>
> (let [Double 99] (instance? Double 42.0))
>> => true
>
>
> We expected that when the symbol Double is bound to a value, then that
> symbol would be evaluated to its value before being passed to a function.
> In this case it seems that the call to instance? is being inlined.
>
> Am I missing something? Is this a bug?
>
> We are using Clojure 1.5.1.
>
> Thanks in advance.
>
> Simon
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Strange dot behaviour

2014-04-27 Thread Simon Doherty
We're encountering some strange behaviour with the instance? function. The 
first two examples are expected behaviour:

(instance? Double 42.0)
> => true
> (instance? 99 42.0)
> ClassCastException java.lang.Long cannot be cast to java.lang.Class


but the next is not:

(let [Double 99] (instance? Double 42.0))
> => true


We expected that when the symbol Double is bound to a value, then that 
symbol would be evaluated to its value before being passed to a function. 
In this case it seems that the call to instance? is being inlined.

Am I missing something? Is this a bug?

We are using Clojure 1.5.1.

Thanks in advance.

Simon

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


Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Peter B. West

On 27 Apr 2014, at 7:40 pm, Carlo Zancanaro  wrote:

> I'm struggling to understand the problem that you're actually trying to
> solve. The solution that you are proposing doesn't seem like an elegant
> solution to any problem, so could you elaborate on what you're trying to
> do?
> 

http://dev.clojure.org/display/design/Resource+Scopes

It doesn't take long to run into this problem.

From http://stuartsierra.com/2013/03/29/perils-of-dynamic-scope

"Resource management is one concurrency bugaboo that Clojure developers have 
not managed to crack. Various attempts have been made: you can see the 
artifacts in wiki and mailing list discussions of Resource Scopes. So far, no 
solution has been found that doesn’t just shift the problem somewhere else."

I have no ambitions to solve the general problem; just to find a workable 
solution for my own use.

> On Fri, Apr 25, 2014 at 08:58:42AM -0700, Peter West wrote:
>> One interesting thing about intern is that it will create *or find* a var, 
>> setting its root binding.  That means that var circumvents the immutability 
>> of a var, doesn't it? I thought vars were supposed to be immutable.
> 
> Vars are not immutable. Clojure has four datatypes which are used for
> mutability: Agents, Atoms, Refs and Vars. As I said originally, your
> function is mutating the global scope, whether by using `intern` or by
> using `def`, and this is generally not a good idea. There is (almost), a
> better solution than mutating the global state.

I mistook the intention of binding as being the only way to modify a var.  I 
was influenced by the XSLT notion of "variable."  Thanks for clearing up that 
misconception.


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Unity 3d and Clojure

2014-04-27 Thread Max Kreminski
It looks like it's still in the "mostly functional hack" phase, and there's 
not yet any documentation on how to set it up or what exactly can be done 
with it, but there's a public GitHub 
repoyou can look at if you're feeling 
adventurous.

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


Re: Unity 3d and Clojure

2014-04-27 Thread Max Kreminski
It looks like it's still in the "mostly functional hack" phase, and there's 
not yet any documentation on how to set it up or what exactly can be done 
with it, but there's a public GitHub 
repothat you can look at if you're 
feeling adventurous.

On Saturday, April 26, 2014 6:11:15 PM UTC-7, Jacob Goodson wrote:
>
> Hey guys I have seen this... 
> http://f.cl.ly/items/2T2d340o0k0W2d44212G/clj2.gif
>
> Now, I want to know... has anything developed since?  Is it available to 
> 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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Ring + Compojure new route recognition

2014-04-27 Thread Brian Craft
I haven't used "lein ring server", but my understanding is that it reloads 
when you write to disk. If you're just using the Eval feature of Fireplace, 
it's not going to write anything to disk, so lein won't know it should 
reload.

I've been using fireplace with the "manual" ring process described here:

https://github.com/mmcgrana/ring/wiki/Interactive-Development

which seems a lot more flexible and convenient. It doesn't require writing 
to disk, so you can, for example, make temporary changes in a library, 
evaluate the form with fireplace, and the server is updated live.

I've been leaving a comment like 

; (defonce server (run-jetty #'handler {:port 8080 :join? false}))

which can be evaluated in fireplace with cp% to start the server. New 
routes are picked up when evaluated in the same fashion.


On Sunday, April 27, 2014 10:22:01 AM UTC-7, Jarrod Swart wrote:
>
> I've noticed that when using Ring + Compojure w/ LightTable the following 
> process will get me access to any newly added routes.
>
> 1. Add a route
> 2. Eval the route NS
> 3. Eval the handler NS
> 4. Check route in browser
> 5. Success
>
> Recently I've begun using Vim + Fireplace.
>
> I cd to my project dir and start a 'lein repl'.  I then startup a 'lein 
> ring server'.
>
> With this setup I can only access newly added routes when I completely 
> restart the server.
>
> What am I doing wrong?
>

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


Proposing a new Clojure documentation system (in Clojure)

2014-04-27 Thread Daniel
I'm all for getting behind Marginalia and improving it to meet whatever needs 
are wanted by the community while staying true to it's docco roots.

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


Ring + Compojure new route recognition

2014-04-27 Thread Jarrod Swart
I've noticed that when using Ring + Compojure w/ LightTable the following 
process will get me access to any newly added routes.

1. Add a route
2. Eval the route NS
3. Eval the handler NS
4. Check route in browser
5. Success

Recently I've begun using Vim + Fireplace.

I cd to my project dir and start a 'lein repl'.  I then startup a 'lein 
ring server'.

With this setup I can only access newly added routes when I completely 
restart the server.

What am I doing wrong?

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


Starting work on a new dialect on top of the JVM

2014-04-27 Thread Divyansh Prakash
Hey!
I have some ideas that I will be talking about here.
Here's a little introduction.

http://pizzaforthought.blogspot.in/2014/04/lisp-teleology.html

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


Re: ANN Major breaking public API changes coming to several ClojureWerkz projects

2014-04-27 Thread Michael Klishin
2014-04-27 18:12 GMT+04:00 dgrnbrg :

> Is this slated for Welle too? I didn't see it mentioned.


Yes.
-- 
MK

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

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


ANN Major breaking public API changes coming to several ClojureWerkz projects

2014-04-27 Thread dgrnbrg
Is this slated for Welle too? I didn't see it mentioned. 

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


Re: Clojure cons vs. conj

2014-04-27 Thread Joshua Ballanco
I think you’ve actually answered your own question without realizing it. At 
least, the way I was taught is that “conj” is always constant time w.r.t. the 
collection being appended to. Since different collections have different 
internal storage mechanisms, that means that “conj” will do different things 
for different collections. Specifically, since a “list” is implemented as a 
linked-list, appending to the front is constant time. However vectors, which 
are backed by Java arrays, can only do a constant-time append by adding to the 
end.  


On Thursday, April 24, 2014 at 18:46, Jiacai Liu wrote:

> Well,I understand you.
> list only support front insert since it only takes O(1).
> If insert in the back,it would require O(n) time.
> Maybe clojure has its own reasons for having both cons and conj.  
> Thank again for telling me their differences.
>  
> On Thursday, April 24, 2014 11:36:13 PM UTC+8, Gary Trakhman wrote:
> > Well, maybe I shouldn't bash MIT-scheme unintentionally :-). I bet some 
> > people use it for serious stuff, and I have no bad experiences with it.
> >  
> >  
> > On Thu, Apr 24, 2014 at 11:33 AM, Gary Trakhman  > (javascript:)> wrote:
> > > MIT-lisp is more for teaching than industrial use..
> > >  
> > > We also have hash-maps, vectors, sets, queues, conj works with all of 
> > > them, leaving the details up to the collection.
> > >  
> > > Cons always adds to the front. Conj only adds to the back for certain 
> > > collections (vector, queue).
> > >  
> > > You could work around it by reversing, consing, then reversing again, or 
> > > just use vectors and conj if you're always working on the tail.  
> > >  
> > >  
> > > On Thu, Apr 24, 2014 at 11:27 AM, Jiacai Liu  > > (javascript:)> wrote:
> > > > Oh,Thank you for answer.
> > > > But if I just want to insert a element to list,and meantime want to 
> > > > insert in the back.How should I do?
> > > > Another question: why clojure need both cons and conj? In mit-lisp cons 
> > > > just do all things.
> > > >  
> > > >  
> > > > On Thursday, April 24, 2014 11:12:49 PM UTC+8, Gary Trakhman wrote:
> > > > > Conj is polymorphic on its first argument. If you pass it a vector, 
> > > > > it'll add to the back, if a list, the front. The collection is 
> > > > > responsible for deciding the most efficient way to add an element.
> > > > >  
> > > > > Cons always adds to the front, creating a linked-list node pointing 
> > > > > to the rest. Also, cons takes the sequence as the second argument.
> > > > >  
> > > > >  
> > > > > On Thu, Apr 24, 2014 at 11:10 AM, Jiacai Liu  
> > > > > wrote:
> > > > > > hi everyone:
> > > > > > I use Clojure to solve SICP 2.22 
> > > > > > (http://www.billthelizard.com/2011/01/sicp-221-223-mapping-over-lists.html).
> > > > > > The problem is to rewrite a map fn in a iterative way,here it want 
> > > > > > to get the square of each element in a list
> > > > > > Method 1:
> > > > > > (defn square-list [items]
> > > > > > (defn iter [things answer]
> > > > > > (if (empty? things)
> > > > > > answer
> > > > > > (iter  
> > > > > > (rest things)
> > > > > > (cons (square (first things)) answer  
> > > > > > (iter items nil))  
> > > > > >  
> > > > > > This method just return opposite result.
> > > > > > (square-list (range 1 10))  
> > > > > > ;===>(81 64 49 36 25 16 9 4 1)
> > > > > >  
> > > > > > I think all I need is to swap the position of (square (first 
> > > > > > things)) and answer,then I can get the right order  
> > > > > > I write fn below:
> > > > > > Method 2
> > > > > > (defn square-list [items]
> > > > > > (defn iter [things answer]
> > > > > > (if (empty? things)
> > > > > > answer
> > > > > > (iter  
> > > > > > (rest things)
> > > > > > (conj answer (square (first things))  
> > > > > > (iter items nil))  
> > > > > >  
> > > > > > However, it still return opposite order.
> > > > > > Did I misuse cons and conj or I ignore something?
> > > > > >  
> > > > > >  
> > > > > > --  
> > > > > > 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=en
> > > > > > ---  
> > > > > > You received this message because you are subscribed to the Google 
> > > > > > Groups "Clojure" group.
> > > > > > To unsubscribe from this group and stop receiving emails from it, 
> > > > > > send an email to clojure+u...@googlegroups.com.
> > > > > >  
> > > > > > For more options, visit https://groups.google.com/d/optout.
> > > > --  
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Clojure" group.
> > > > To

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Carlo Zancanaro
I'm struggling to understand the problem that you're actually trying to
solve. The solution that you are proposing doesn't seem like an elegant
solution to any problem, so could you elaborate on what you're trying to
do?

On Fri, Apr 25, 2014 at 08:58:42AM -0700, Peter West wrote:
> One interesting thing about intern is that it will create *or find* a var, 
> setting its root binding.  That means that var circumvents the immutability 
> of a var, doesn't it? I thought vars were supposed to be immutable.

Vars are not immutable. Clojure has four datatypes which are used for
mutability: Agents, Atoms, Refs and Vars. As I said originally, your
function is mutating the global scope, whether by using `intern` or by
using `def`, and this is generally not a good idea. There is (almost), a
better solution than mutating the global state.


signature.asc
Description: Digital signature


Re: Proposing a new Clojure documentation system (in Clojure)

2014-04-27 Thread Fergal Byrne
Hi Valentin,

Thanks for starting such an excellent discussion, and your initial posting
is very well put. I think you should talk to Chris Zheng who has developed
a tool called lein-midje-doc [1] which it seems answers much of your
questions. I've been using it for months now and it is the centrepiece of
my development workflow.

lein-midje-doc combines the Midje test framework with a literate
programming model. Essentially you write documentation (as you describe) in
Clojure, with your text in Markdown, structured using Clojure data
structures, and sample code which shows the reader how to use the code. The
sample code can be either just that (ie it produces a code block but is
merely pretty-ptinted text) by putting the sample code in a (comment ...)
form, or else executable doumentation/test code of the form:

(+ 1 2 3) => 6

by putting the sample code in a Midje (fact ...) form.

Here's an example doc [2] I produced recently which compares two encoders
for my Clortex project. As you can see, it's a mini-paper which goes
through the shortcomings of an existing encoder, then argues for, explains
and demonstrates a new design. The doc has an include directive which pulls
in the source code for the new encoder in the middle.

In addition to this, docstrings are still hugely useful and should form
part of the workflow for accessing quick summary and usage information on
functions. I use Marginalia [3] to convert docstrings into a side-by-side
doc-and-code presentation.

Finally, I'm using the wonderful hoplon-reveal-js [4] to produce beautiful
presentations about the work and the software. It's all done in
ClojureScript and is a huge step in the direction you're talking about.

I would also point you to Gorilla REPL [5] and Session [6] for another take
on doing literate programming and mixing markup with code in Clojure.
Hopefully there's some way these guys can combine their projects, the
combination would be scary!

Regards

Fergal

[1] https://github.com/zcaudate/lein-midje-doc
[2] http://fergalbyrne.github.io/rdse.html
[3] https://github.com/gdeer81/marginalia
[4] https://github.com/oubiwann/hoplon-reveal-js
[5] https://github.com/JonyEpsilon/gorilla-repl
[6] https://github.com/kovasb/session




On Sun, Apr 27, 2014 at 5:21 AM, Mars0i  wrote:

> Some thoughts:
>
> Having concise documentation in the same place as the code minimizes a
> certain kind of work:  I want my functions to be commented in the source
> file so that someone reading it later (maybe me) will quickly understand
> what they're supposed to do.  If Clojure didn't have docstrings, I'd put
> similar information, although maybe more terse, in comments.  As it is, I
> just write the docstring, and I've accomplished two things in one.  If all
> of the documentation was in another file, I'd have to do at least 1.5 times
> more work just to produce the kind of docstrings I produce now.
>
> Some docstrings (e.g. for xy-plot in Incanter) are too long for convenient
> use at a repl.  So I appreciate the idea of providing different levels of
> documentation.  What's displayed by default at a prompt should be short.
>
> I like the general idea of the Valentin's proposal, but I don't understand
> every bit of it.  It sounds complicated.  Personally, I'd rather see
> something that's relatively simple, and good enough, than something that's
> perfect but unwieldy.  If it's too difficult, people won't use it, or
> they'll waste time, or feel that the Clojure community expects them to
> spend too much time on something that detracts from what's important.  I am
> someone who I think has put more time into documentation more than most of
> the programmers I've worked with.  I'm in favor of encouraging more
> documentation of code.  But documentation tools should not make the process
> much harder than it is.  Ideally, they should make it easier, but some
> extra cost is worthwhile for extra payoff later.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Fergal Byrne, Brenter IT

Author, Real Machine Intelligence with Clortex and NuPIC
https://leanpub.com/realsmartmachines

Speaking on Clortex and HTM/CLA at euroClojure Krakow, June 2014:
http://euroclojure.com/2014/

http://inbits.com - Better Living through
Thoughtful Technology
http://ie.linkedin.com/in/fe