Re: Clojure for Cocoa

2012-01-28 Thread Matthias Benkard
Hi,

On Jan 27, 4:20 am, Cedric Greevey  wrote:
> One thing that must help there is that the functional nature of
> Clojure makes it pretty rare for Clojure code to produce a true
> reference circularity.

That's probably true.  Reference counting is a good fit for tree-
shaped data.  Cycles formed through global or state-managing variables
are generally harmless, too.  Since Clojure encourages explicit state
management, those are probably the most common kind.

But note that depending on the implementation, a recursive closure can
be a cyclic data structure.  (Lambda lifting helps here, as does
special-casing direct recursive references.  Still, pathological cases
are usually easy to construct.  I have no idea wether or not the
impact of this issue might be of considerable scale.)

Matthias

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

2012-01-28 Thread Ulises
Here's a paper that might be interesting to folk discussing in this
thread: http://www.jstatsoft.org/v46/i03/paper

Cheers

U

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


Re: New Version of ClojureScript One

2012-01-28 Thread Brenton
Christofer,

This is a problem with the current version of Leiningen. There are a
couple of ways to work around the problem. Here is one:

Create a new Leiningen project.

lein new delete-me
cd delete-me

Open project.clj and change

:dependencies [[org.clojure/clojure "1.3.0"]]

to

:dependencies [[org.clojure/clojure "1.2.1"]]

Save this file and then run

lein deps

You can now delete this project. The whole point was to get
clojure-1.2.1 into your local maven repository. lein should now work
in ClojureScript One and with any other Clojure 1.3 projects.

This issue will be fixed in Leiningen soon.

Brenton

On Jan 27, 1:05 pm, Christofer Jennings  wrote:
> I get the error below when I run ClojureScript One's 'lein bootsrap'. Any 
> ideas?
>
> I'm pretty new to Clojure. This is my first time using Leiningen and first 
> attempt at using ClojureScript. ... pretty hopeless :-)
>
> Mac OSX 10.7.2
> Clojure 1.3.0
> java version "1.6.0_29"
> Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
> Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
>
> Exception in thread "main" java.lang.RuntimeException: 
> java.lang.NoSuchMethodError: 
> clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
>         at clojure.lang.Util.runtimeException(Util.java:165)
>         at clojure.lang.Compiler.eval(Compiler.java:6476)
>         at clojure.lang.Compiler.eval(Compiler.java:6431)
>         at clojure.core$eval.invoke(core.clj:2795)
>         at clojure.main$eval_opt.invoke(main.clj:296)
>         at clojure.main$initialize.invoke(main.clj:315)
>         at clojure.main$script_opt.invoke(main.clj:339)
>         at clojure.main$main.doInvoke(main.clj:426)
>         at clojure.lang.RestFn.invoke(RestFn.java:457)
>         at clojure.lang.Var.invoke(Var.java:413)
>         at clojure.lang.AFn.applyToHelper(AFn.java:172)
>         at clojure.lang.Var.applyTo(Var.java:518)
>         at clojure.main.main(main.java:37)
> Caused by: java.lang.NoSuchMethodError: 
> clojure.lang.KeywordLookupSite.(ILclojure/lang/Keyword;)V
>         at leiningen.util.paths$native_arch_path.(paths.clj:32)
>         at leiningen.util.paths__init.load(Unknown Source)
>         at leiningen.util.paths__init.(Unknown Source)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:247)
>         at clojure.lang.RT.loadClassForName(RT.java:2030)
>         at clojure.lang.RT.load(RT.java:417)
>         at clojure.lang.RT.load(RT.java:398)
>         at clojure.core$load$fn__4610.invoke(core.clj:5386)
>         at clojure.core$load.doInvoke(core.clj:5385)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at clojure.core$load_one.invoke(core.clj:5200)
>         at clojure.core$load_lib.doInvoke(core.clj:5237)
>         at clojure.lang.RestFn.applyTo(RestFn.java:142)
>         at clojure.core$apply.invoke(core.clj:602)
>         at clojure.core$load_libs.doInvoke(core.clj:5271)
>         at clojure.lang.RestFn.applyTo(RestFn.java:137)
>         at clojure.core$apply.invoke(core.clj:602)
>         at clojure.core$require.doInvoke(core.clj:5352)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at leiningen.core$loading__4414__auto__.invoke(core.clj:1)
>         at leiningen.core__init.load(Unknown Source)
>         at leiningen.core__init.(Unknown Source)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:247)
>         at clojure.lang.RT.loadClassForName(RT.java:2030)
>         at clojure.lang.RT.load(RT.java:417)
>         at clojure.lang.RT.load(RT.java:398)
>         at clojure.core$load$fn__4610.invoke(core.clj:5386)
>         at clojure.core$load.doInvoke(core.clj:5385)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at clojure.core$load_one.invoke(core.clj:5200)
>         at clojure.core$load_lib.doInvoke(core.clj:5237)
>         at clojure.lang.RestFn.applyTo(RestFn.java:142)
>         at clojure.core$apply.invoke(core.clj:602)
>         at clojure.core$load_libs.doInvoke(core.clj:5271)
>         at clojure.lang.RestFn.applyTo(RestFn.java:137)
>         at clojure.core$apply.invoke(core.clj:604)
>         at clojure.core$use.doInvoke(core.clj:5363)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at user$eval1.invoke(NO_SOURCE_FILE:1)
>         at clojure.lang.Compiler.eval(Compiler.java:6465)
>         ... 11 more
>
> Thanks for all the cool stuff!
> ,chris
>
> On Jan 26, 2012, at 3:34 AM, Sam Aaron wrote:
>
>
>
>
>
>
>
>
>
> > On 25 Jan 2012, at 22:27, Brenton wrote:
>
> >> ClojureScript will continue to change rapidly. We are already
> >> depending on a newer version than the one in Maven. Also, I don't
> >> think that Domina has a release yet.
>
> >> For times when we only need a source dependency and only at
> >> development time, I like this approach to dependencies. I plan to
> >> continue improving support for this in Leiningen and using it as much

Re: Literate programming in emacs - any experience?

2012-01-28 Thread Folcon
Hi Tim,

Personally if you have done or would be interested in doing a quick vid 
cast of how you progress through your workflow, I think that would be very 
interesting.

Regards,
Folcon

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

2012-01-28 Thread daly
On Sat, 2012-01-28 at 06:51 -0800, Folcon wrote:
> Hi Tim,
> 
> 
> Personally if you have done or would be interested in doing a quick
> vid cast of how you progress through your workflow, I think that would
> be very interesting.

Sort of "extreme pair programming with everybody"? :-)
There is no such thing as a simple job but I'll see what I can do.
A watchable video takes time to compose.

Tim Daly



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

2012-01-28 Thread Colin Yates
I know I would find it incredibly helpful, and would consider paying a
token sum of money (£5?)...

On 28 January 2012 15:04, daly  wrote:

> On Sat, 2012-01-28 at 06:51 -0800, Folcon wrote:
> > Hi Tim,
> >
> >
> > Personally if you have done or would be interested in doing a quick
> > vid cast of how you progress through your workflow, I think that would
> > be very interesting.
>
> Sort of "extreme pair programming with everybody"? :-)
> There is no such thing as a simple job but I'll see what I can do.
> A watchable video takes time to compose.
>
> Tim Daly
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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: Literate programming in emacs - any experience?

2012-01-28 Thread daly
On Sat, 2012-01-28 at 15:27 +, Colin Yates wrote:
> I know I would find it incredibly helpful, and would consider paying a
> token sum of money (£5?)...

An amusing thought but no thanks. 
Buy yourself a pint and swear you'll at least try to write
your next program in some form of literate programming.
At the next conj I'll buy you a pint.

> 
> On 28 January 2012 15:04, daly  wrote:
> On Sat, 2012-01-28 at 06:51 -0800, Folcon wrote:
> > Hi Tim,
> >
> >
> > Personally if you have done or would be interested in doing
> a quick
> > vid cast of how you progress through your workflow, I think
> that would
> > be very interesting.
> 
> 
> Sort of "extreme pair programming with everybody"? :-)
> There is no such thing as a simple job but I'll see what I can
> do.
> A watchable video takes time to compose.
> 
> Tim Daly
> 
> 
> 
> --
> You received this message because you are subscribed to the
> Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be
> patient with your first post.
> To unsubscribe from 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: Literate programming in emacs - any experience?

2012-01-28 Thread Colin Yates
Fair enough :) - deal.  Assuming I ever get to leave my pit of despair
(trying to get a well-known javascript charting library to render
properly...how hard can these things be!).

On 28 January 2012 15:41, daly  wrote:

> On Sat, 2012-01-28 at 15:27 +, Colin Yates wrote:
> > I know I would find it incredibly helpful, and would consider paying a
> > token sum of money (£5?)...
>
> An amusing thought but no thanks.
> Buy yourself a pint and swear you'll at least try to write
> your next program in some form of literate programming.
> At the next conj I'll buy you a pint.
>
> >
> > On 28 January 2012 15:04, daly  wrote:
> > On Sat, 2012-01-28 at 06:51 -0800, Folcon wrote:
> > > Hi Tim,
> > >
> > >
> > > Personally if you have done or would be interested in doing
> > a quick
> > > vid cast of how you progress through your workflow, I think
> > that would
> > > be very interesting.
> >
> >
> > Sort of "extreme pair programming with everybody"? :-)
> > There is no such thing as a simple job but I'll see what I can
> > do.
> > A watchable video takes time to compose.
> >
> > Tim Daly
> >
> >
> >
> > --
> > You received this message because you are subscribed to the
> > Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be
> > patient with your first post.
> > To unsubscribe from 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
>

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

2012-01-28 Thread Folcon
I think I could live with that :)...

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

2012-01-28 Thread raschedh
> Unlike in Common Lisp, Clojure resolves symbols at compile time.

Thank you, for stating this fact so precisely, thereby answering
my question.

I do have difficulties, though, to deduce this fact from the
reference manual.
But, well, there you go.

Heinz.

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


Looking for parser generator library

2012-01-28 Thread Roman Perepelitsa
I'm looking for a parser generator library. I stumbled upon fnparse, but
unfortunately it doesn't work with clojure 1.3.

Roman Perepelitsa.

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

Re: ClojureScript def, vars, and binding

2012-01-28 Thread Brandon Bloom
For anyone else stumbling across this thread, I found a lot more 
information about dynamic binding with respect to asynchronous code in the 
Clojure Confluence wiki:

http://dev.clojure.org/display/design/State%2C+Concurrency%2C+and+Parallelism

In particular, the "Asynchronous Events", "Blocking vs Nonblocking Reads", 
and "Improve Bindings" sub-pages discuss my misconception regarding the 
behavior bindings within callbacks, or otherwise lazy code.

The topics haven't been updated in a while, but I suspect that these issues 
are going to become higher priority as ClojureScript gains adoption. The 
async and non-blocking nature of JavaScript introduces some serious 
complexities which aren't as relevant on the JVM.

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

got trouble when combine use condition-map and doc-string

2012-01-28 Thread z huang
Hi all:

I got trouble when i combine use condition-map and doc-string in my 
function, the condition-map seems not work anymore:

user=> (defn f [x] 
 {:pre [(pos? x)]}
 x)
#'user/f
user=> (f -1)
AssertionError Assert failed: (pos? x)  user/f (NO_SOURCE_FILE:1)

user=> (defn another-f [x]
 "doc string here"
 {:pre [(pos? x)]}
 x)
#'user/another-f
user=> (another-f -1)
-1

Is this a bug or my code got errors? 

Thanks,
huangz.

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

Re: Help coding Eller's maze algorithm.

2012-01-28 Thread Gabriele Carrettoni
Never heard about it, It seems very interesting.
Thanks for the tip.

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

Re: New Version of ClojureScript One

2012-01-28 Thread Michael J. Forster
On Jan 27, 12:05 pm, Christofer Jennings  wrote:
> I get the error below when I run ClojureScript One's 'lein bootsrap'. Any 
> ideas?
>
> I'm pretty new to Clojure. This is my first time using Leiningen and first 
> attempt at using ClojureScript. ... pretty hopeless :-)

Hi Christofer,

No need to feel badly.  I ran into the same problem myself.  The short
answer is that you need to add the Leiningen standalone JAR to your
class path.  For example,

export CLASSPATH="$HOME/.lein/self-installs/leiningen-1.6.2-
standalone.jar"

See this as well:  http://stackoverflow.com/a/9020020


Cheers!

Mike



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

2012-01-28 Thread philip k
I'm not so sure about this, but is it possible to throw an exception
when dividing by zero for example? I don't know if exceptions are the
right way of dealing with this at all, but at least this would be
bringing things more in line with Clojure.

On Jan 27, 10:03 pm, David Nolen  wrote:
> In this 
> branchhttps://github.com/clojure/clojurescript/compare/master...checked-ari...,
> I've implemented one possible approach to checked arithmetic for
> ClojureScript. In Clojure this means checking for overflow. In JavaScript a
> much more common source of error is type coercion from the arithmetic
> operators as well as the introduction of Infinity and NaN.
>
> These changes would prevent the production of NaN and Infinity at least
> from within ClojureScript itself. Also operations like:
>
> (+ 1 2 "3")
>
> fail instead of producing
>
> "33"
>
> Of course such changes would impose a performance hit. You can currently
> toggle the behavior with the following macro:
>
> (set-unchecked-arithmetic! true)
>
> This is useful when writing performance sensitive code.
>
> Feedback, improvements appreciated.
>
> 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: ClojureScript def, vars, and binding

2012-01-28 Thread Brandon Bloom
D'oh! That's what I get for assuming I remembered the Java Thread API from 
several years ago

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: Avoiding reflection in vector-of

2012-01-28 Thread Bryce
Unfortunately with that change I still show ~90% of CPU time being
spent in Reflector.getMethods().

On Jan 27, 11:59 am, Michael Wood  wrote:
> On 25 January 2012 23:30, Bryce  wrote:
> [...]
>
> > ;All of these spend most of their time in reflection
> > (apply vector-of :int (range 1000))
> > (apply vector-of :int ^"[J>" (range 1000))
> > (apply vector-of :int ^"[J>" (long-array (range 1000)))
> > (apply vector-of :int ^{:tag 'longs} (long-array (range 1000)))
>
> Just a guess.  Have you tried the following?
>
> (apply vector-of :long ...)
>
> --
> Michael Wood 

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


Re: How to add a new type of collection?

2012-01-28 Thread Joachim De Beule
Well, I also do not want to re-invent the wheel. Some of these
libraries are really optimized for both memory and  speed (yes, I will
need both) and already provide a great deal of useful functionality
that I would otherwise have to implement myself. I just want to make
sure I am doing it right and avoid problems later...

On Jan 27, 11:11 pm, Ben Mabey  wrote:
> On 1/27/12 9:11 AM, Walter van der Laan wrote:> Are you somehow required to 
> use the Java library?
>
> > Otherwise you could also use a Clojure map as a sparse matrix.
> > This will be much easier to implement.
>
> Using a clojure map to store a sparse matrix is not a good solution if
> you plan on doing any serious computation on it.  Reason being is that
> clojure's collections don't yet support primitive types (with the
> exception of vector, but most operations on it will result in boxing).

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: got trouble when combine use condition-map and doc-string

2012-01-28 Thread Jonas
The docstring goes before the argument list:

(defn another-f 
   "doc string here" 
   [x] 
   {:pre [(pos? x)]} 
   x)

user=> (another-f -1)
java.lang.AssertionError: Assert failed: (pos? x) (NO_SOURCE_FILE:0)
user=> (doc another-f)
-
user/another-f
([x])
  doc string here
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: CLJS: Checked Arithmetic?

2012-01-28 Thread David Nolen
On Fri, Jan 27, 2012 at 5:38 PM, philip k  wrote:

> I'm not so sure about this, but is it possible to throw an exception
> when dividing by zero for example? I don't know if exceptions are the
> right way of dealing with this at all, but at least this would be
> bringing things more in line with Clojure.
>

divide by zero (introduces Infinity) and arithmetic on non-numbers
(introduces NaN) both throw in the checked-arithmetic branch. I personally
think exceptions are the way to deal with this as it pinpoints the source
of the error quickly without letting bad arithmetic continue on Infinity
and NaN. In my experience it's very tedious to debug.

Open to hearing why you think the JavaScript behavior is a good one!

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: Looking for parser generator library

2012-01-28 Thread Richard Lyman
Have you looked at amotoen?

https://github.com/richard-lyman/amotoen

I'm not sure what your needs are...

-Rich



On Sat, Jan 28, 2012 at 8:19 AM, Roman Perepelitsa
 wrote:
> I'm looking for a parser generator library. I stumbled upon fnparse, but
> unfortunately it doesn't work with clojure 1.3.
>
> Roman Perepelitsa.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from 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: CLJS: Checked Arithmetic?

2012-01-28 Thread Max Penet
Hello David,
This is interesting!
The JavaScript behavior is definitively not a good one, that said the
only thing that I think could do more harm than good is the fact these
checks are enabled by default. I am not sure the majority of cljs user
will want to take a performance hit (or have to set a flag to disable
it) on this given the fields where it will most likely be used (web
ui, web backends), and it might not be obvious to the newcomer.
I would rather have it disabled by default and have to (set-checked-
arithmetic! true) to enable it. But I could be wrong, and in the end
it is mostly a strategy decision, being convenient vs doing it right
(fixing JS).
Max

On Jan 27, 10:03 pm, David Nolen  wrote:
> In this 
> branchhttps://github.com/clojure/clojurescript/compare/master...checked-ari...,
> I've implemented one possible approach to checked arithmetic for
> ClojureScript. In Clojure this means checking for overflow. In JavaScript a
> much more common source of error is type coercion from the arithmetic
> operators as well as the introduction of Infinity and NaN.
>
> These changes would prevent the production of NaN and Infinity at least
> from within ClojureScript itself. Also operations like:
>
> (+ 1 2 "3")
>
> fail instead of producing
>
> "33"
>
> Of course such changes would impose a performance hit. You can currently
> toggle the behavior with the following macro:
>
> (set-unchecked-arithmetic! true)
>
> This is useful when writing performance sensitive code.
>
> Feedback, improvements appreciated.
>
> 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: CLJS: Checked Arithmetic?

2012-01-28 Thread Max Penet
Sorry about the horrible formatting, blame google groups interface.


Max

On Jan 28, 7:16 pm, Max Penet  wrote:
> Hello David,
> This is interesting!
> The JavaScript behavior is definitively not a good one, that said the
> only thing that I think could do more harm than good is the fact these
> checks are enabled by default. I am not sure the majority of cljs user
> will want to take a performance hit (or have to set a flag to disable
> it) on this given the fields where it will most likely be used (web
> ui, web backends), and it might not be obvious to the newcomer.
> I would rather have it disabled by default and have to (set-checked-
> arithmetic! true) to enable it. But I could be wrong, and in the end
> it is mostly a strategy decision, being convenient vs doing it right
> (fixing JS).
> Max
>
> On Jan 27, 10:03 pm, David Nolen  wrote:
>
>
>
>
>
>
>
> > In this 
> > branchhttps://github.com/clojure/clojurescript/compare/master...checked-ari...,
> > I've implemented one possible approach to checked arithmetic for
> > ClojureScript. In Clojure this means checking for overflow. In JavaScript a
> > much more common source of error is type coercion from the arithmetic
> > operators as well as the introduction of Infinity and NaN.
>
> > These changes would prevent the production of NaN and Infinity at least
> > from within ClojureScript itself. Also operations like:
>
> > (+ 1 2 "3")
>
> > fail instead of producing
>
> > "33"
>
> > Of course such changes would impose a performance hit. You can currently
> > toggle the behavior with the following macro:
>
> > (set-unchecked-arithmetic! true)
>
> > This is useful when writing performance sensitive code.
>
> > Feedback, improvements appreciated.
>
> > 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: CLJS: Checked Arithmetic?

2012-01-28 Thread David Nolen
On Sat, Jan 28, 2012 at 12:16 PM, Max Penet  wrote:

> Hello David,
> This is interesting!
> The JavaScript behavior is definitively not a good one, that said the
> only thing that I think could do more harm than good is the fact these
> checks are enabled by default. I am not sure the majority of cljs user
> will want to take a performance hit (or have to set a flag to disable
> it) on this given the fields where it will most likely be used (web
> ui, web backends), and it might not be obvious to the newcomer.
> I would rather have it disabled by default and have to (set-checked-
> arithmetic! true) to enable it. But I could be wrong, and in the end
> it is mostly a strategy decision, being convenient vs doing it right
> (fixing JS).
> Max


Clojure favors performance - but correctness comes first. ClojureScript is
already *considerably* slower than hand-written JavaScript - we're using
copy-on-write data structures, sane truth testing, protocol dispatch, etc.
Yet ClojureScript is pragmatic and provides performance escape hatches via
simple access to Object, Array, loop/recur statements that compile down to
equivalent JS iteration constructs, etc.

I think ClojureScript's gamble on client side development is a good one.
Let's write our software right first but make it easy to apply
optimizations later.

In my experience as a client side JS developer, I'd prefer some correctness
over performance for most applications. For performance sensitive code
(like high performance Canvas animation) ClojureScript should most
definitely provide the tools such that we can compete with the equivalent
JavaScript - ideally with less code.

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: Looking for parser generator library

2012-01-28 Thread Chris Perkins
Here is one I wrote a while ago.

https://github.com/grammati/imparsonate 

It's not "finished" (is open-source software ever really finished?), so I 
don't know whether it will do what need it to.

- Chris

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

Re: Looking for parser generator library

2012-01-28 Thread Jack Moffitt
> I'm looking for a parser generator library. I stumbled upon fnparse, but
> unfortunately it doesn't work with clojure 1.3.

I ended up just using ANTLR and it works pretty well from Clojure.
Most of my time was spent on the grammar and implementation, not the
ANTLR integration bits.

I started from this example:

http://briancarper.net/blog/554/antlr-via-clojure

jack.

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


Re: proxy with dynamic

2012-01-28 Thread Razvan Rotaru
Yes, it's more clear now. 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: Why don't these two functions produce equivalent results?

2012-01-28 Thread Andy Fingerhut
One way to think of it is that both assoc and assoc! create and return new
maps that are different than the originals they were given as input.

assoc never modifies the original map.  assoc! might, or it might not.  It
depends on implementation details.  A correct Clojure program will never
rely on whether the original map is modified in place or not.  It should
always use the return value of assoc!, and assume that the map given to
assoc! now has a non-specified value.

I agree that the documentation could be clearer on this point.  I was going
to point you at clojuredocs.org, but I see that the current example there
is even more misleading, making it appear that you *should* "bash it in
place".  I will probably fix that soon, but if someone beats me to it, all
the better.

Andy


On Fri, Jan 27, 2012 at 1:24 PM, Bill Robertson
wrote:

> Yes, I see that now. When I read "When applied to a transient map,
> adds mapping of key(s) to val(s)" in the doc string, I understood that
> to mean that it modified the existing map, and the (insufficient)
> poking around that I did in the repl supported that. (actually did it
> past 8 now - saw it fail in same way).
>
> I guess under the hood its a essentially the same sort of persistent
> data structure but with chunking (buffering) before it grows.
>
> If I wanted to submit alternate wording for the doc string, how would
> I do that? i.e. where is the process for contributing outlined?
>
> e.g. "When applied to a transient map, adds mapping of key(s) to
> val(s) in the resulting map."
>
> Thanks
> -Bill
>
> On Jan 27, 4:13 pm, David Nolen  wrote:
> > On Fri, Jan 27, 2012 at 3:08 PM, Bill Robertson
> > wrote:
> >
> > > I have read (doc transient), (doc assoc!) and (doc persistent!), and I
> > > don't see what I'm missing, which is why I came here for help.
> >
> > The documentation herehttp://clojure.org/transientssays:
> >
> > "Don't bash in place"
> >
> > Note that all the examples are done in a functional style - they actually
> > use the value produced by each operation.
> >
> > David
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

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

Last value from REPL

2012-01-28 Thread David Jacobs
Does the Clojure REPL provide a handle for getting the value returned by 
the last executed statement? In Ruby's REPL, the underscore gives you the 
last returned value. In Clojure, I'd love to do something like this:

(some-expensive-or-rate-limited-call "example.com")
(def cache-after-the-fact _)

I've wanted this for a while, but until today it's been to save keystrokes. 
However, I just made an API call that is rate limited to once every 5 
minutes and didn't store the result in a var. And now I'd love this 
functionality so I don't have to wait around for 5 minutes to make the call 
again.

Any thoughts on how to do this?

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

problems with meta

2012-01-28 Thread raschedh
Hi,

I've got two questions regarding meta information.

Question 1:

I can say
(def x1 (with-meta [] {:m 1}))
or
(def x2 ^{:m 1} [])
and will get my map back with either
(meta x1)
or
(meta x2).

But when I do
(def y1 (with-meta 'a {:m 1}))
(def y2 ^{:m 1} 'a)
only
(meta y1) spits the map back at me,
(meta y2) evaluates to nil.

What am I doing wrong ?
Maybe the meta info is attached to (quote a) and not to the symbol,
because
that is "the next form read" ?

Question 2:

The following is, of course, an extremely silly thing to do,
but I can't help myself:

When I say
(def z1 (with-meta [] {}))
and
(def z2 ^{} [])
again,
only
(meta z1) gives me my content-rich meta information back,
but
(meta z2) returns nil.

What am I missing ?

Thanks for your help,

Heinz.

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

2012-01-28 Thread Roman Perepelitsa
Thanks, I didn't look at amotoen yet. Will do!

A library based on parser combinators would be ideal, something like parsec
in haskell. Although if in clojure world people usually take a different
approach, I'm open to trying it.

2012/1/28 Richard Lyman 

> Have you looked at amotoen?
>
> https://github.com/richard-lyman/amotoen
>
> I'm not sure what your needs are...
>
> -Rich
>
>
>
> On Sat, Jan 28, 2012 at 8:19 AM, Roman Perepelitsa
>  wrote:
> > I'm looking for a parser generator library. I stumbled upon fnparse, but
> > unfortunately it doesn't work with clojure 1.3.
> >
> > Roman Perepelitsa.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> your
> > first post.
> > To unsubscribe from 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: Last value from REPL

2012-01-28 Thread Stuart Sierra
Yes, the REPL binds *1, *2, and *3 to the three most recent returned 
values. *e is the most recent Exception.

-S

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

[ANN] cljs-uuid 0.0.1 (micro cljs uuid lib)

2012-01-28 Thread Dave Sann
Tiny utility.

if you need to

1. generate v4 (random) uuid's on your client
2. read/print uuid strings
3. read/print uuid string literals

clojars -  [cljs-uuid "0.0.1"]
git - https://github.com/davesann/cljs-uuid

Cheers
D

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: C-c C-x keybindings for swank-cdt don't work

2012-01-28 Thread Gregg Williams
George, I don't know why it works (my init.el file doesn't seem to
mess with anything), but adding that code to the end of init.el makes
things work. You're doing great things for the Clojure community--many
thanks!

On Jan 27, 7:27 pm, George Jahad  wrote:
> Sorry, the elisp got scrambled in the post.
>
> Get it from here:http://georgejahad.com/clojure/swank-cdt-helper.el
>
> On Jan 27, 7:15 pm, George Jahad  wrote:
>
>
>
>
>
>
>
> > Not sure why that is happening.  Can't reproduce it.  What is supposed
> > to happen is that when swank-cdt is loaded, it should invoke the emacs
> > lisp to define those keystrokes.
>
> > Until I figure it out, try adding the following to your .emacs.  Let
> > me know if that fixes it.
>
> > g
>
> > (progn (defun sldb-line-bp (&optional _) "Set breakpoint on current
> > buffer line." (interactive) (slime-eval-async (list (quote swank:sldb-
> > line-bp) (buffer-file-name) (line-number-at-pos (defun slime-force-
> > continue (&optional _) "force swank server to continue" (interactive)
> > (slime-dispatch-event (quote (:emacs-interrupt :cdt (defun slime-
> > get-thing-at-point (&optional _) (interactive) (let ((thing (thing-at-
> > point (quote sexp (set-text-properties 0 (length thing) nil thing)
> > thing)) (defun slime-eval-last-frame (&optional _) "Eval thing at
> > point in the context of the last frame viewed" (interactive) (slime-
> > eval-with-transcript (list (quote swank:eval-last-frame) (slime-get-
> > thing-at-point (define-prefix-command (quote cdt-map)) (define-key
> > cdt-map (kbd "C-b") (quote sldb-line-bp)) (define-key cdt-map (kbd "C-
> > g") (quote slime-force-continue)) (define-key cdt-map (kbd "C-p")
> > (quote slime-eval-last-frame)) (eval-after-load (quote slime) (quote
> > (progn (define-key slime-mode-map (kbd "C-c C-x") (quote cdt-map))
> > (define-key sldb-mode-map (kbd "C-c C-x") (quote cdt-map) (eval-
> > after-load (quote slime-repl) (quote (define-key slime-repl-mode-map
> > (kbd "C-c C-x") (quote cdt-map (eval-after-load (quote cc-mode)
> > (quote (define-key java-mode-map (kbd "C-c C-x") (quote cdt-map)
>
> > On Jan 26, 10:06 pm,GreggWilliams wrote:
>
> > > Hi--After several attempts, I've gotten CDB working...sort of, and I'm
> > > stuck.
>
> > > Following the example onhttp://georgejahad.com/clojure/swank-cdt.html,
> > > I execute the following:
>
> > > (use 'clojure.set)
> > > (use 'swank.cdt)
> > > (set-bp clojure.set/difference)
>
> > > which execute OK. When I execute:
>
> > > user> (difference #{1 2} #{2 3})
> > > CDT location is clojure/set.clj:53:0:/Users/gw/tech/clojurestuff/
> > > cljprojects/infwb/lib/clojure-1.3.jar
>
> > > the *sldb clojure/3* buffer appears, as does the source code for the
> > > function `difference`, within the source file `set.clj`.
>
> > > Using the `e` command, I can print the value of `s1` in the Emacs
> > > minibuffer.
>
> > > Here's my problem: when I attempt to use any of the C-c C-x commands
> > > (e.g., C-c C-x C-p), the minibuffer complains that the command is not
> > > defined.
>
> > > Following George Jahad's suggestions 
> > > onhttp://groups.google.com/group/clojure/browse_thread/thread/2295f4550...,
> > > I find that `sldb-line-bp` is defined, but I can't find `cdt-map`.
>
> > > Also, his suggestion of executing (swank.core.cdt-utils/init-emacs-
> > > helper-functions) from the REPL doesn't make any difference--I still
> > > get the same behavior reported above.
>
> > > I'm using Emacs 24; could that be causing any problems?
>
> > > I'm using Leiningen 1.6.2, I have lein-midje-1.0.8 loaded in `~/.lein/
> > > plugins`, and my project.clj file is below.
>
> > > Thanks for any suggestions you might have.
>
> > > --- project.clj ---
>
> > > (defproject infwb "1.0.0-SNAPSHOT"
> > >   :description "an evolving, experimental workspace for manipulating
> > > infocards"
> > >   :main infwb.core
>
> > >   :dependencies [[org.clojure/clojure "1.3"]
> > >                  [org.clojure/clojure-contrib "[1.2.0,1.2.1]"]
> > >                  [seesaw "1.2.0"]
> > >                  [org.clojars.gw666/sxqj "beta2"]
> > >                  [org.clojars.gw666/piccolo2dcore "1.3"]
> > >                  [org.clojars.gw666/piccolo2dextras "1.3"]
> > >                  [com.miglayout/miglayout "3.7.4"]
> > >                  ]
> > >   :dev-dependencies [[midje "1.3.1"]
> > >                      [clojure-source "1.3.0"]
> > >                      [swank-clojure "1.4.0-SNAPSHOT"]]
> > >   :jvm-opts ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"])
>
> > > --- end ---

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

2012-01-28 Thread Lars Nilsson
On Sat, Jan 28, 2012 at 1:04 PM, Roman Perepelitsa
 wrote:
> A library based on parser combinators would be ideal, something like parsec
> in haskell. Although if in clojure world people usually take a different
> approach, I'm open to trying it.

Two projects attempting to bring Parsec-style parsing (to some extent
anyway) to Clojure are

https://github.com/youngnh/parsatron
https://github.com/mmikulicic/clarsec

I couldn't say whether they're close enough to what you're looking for
or anything though.

Lars Nilsson

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