Re: Ok, so code is data...

2021-11-30 Thread Brent Millare
Do you want to create an html visualization in html? The main thing to 
check is other code walkers for reference 
like https://github.com/ztellman/riddley but I strongly recommend trying 
this out yourself without using other libraries as you will learn a lot in 
the process.

You don't need to "convert" clojure to nested lists. It already is a nested 
list. Wrapping a clojure exp in a macro provides the macro with the 
unevaluated nested data. Alternatively, when viewing files, then you simply 
want to call read/read-string on raw clj file data.

On Monday, November 29, 2021 at 3:16:23 PM UTC-5 kovas@gmail.com wrote:

> Just stumbled across this thread 10 years later!  I'm actually interested 
> in doing the same thing: taking some clojure logic that I write and 
> converting it to a call-graph in html. Is there any prior art here I should 
> know about?  Or can this be done with basic clojure to e.g. convert the 
> code of a function into nested lists for me to then convert to html?
>
>  - Kovas
>
> On Tuesday, May 10, 2011 at 8:18:03 PM UTC-7 Bill Robertson wrote:
>
>> Thanks for the feedback and pointers. 
>>
>>
>>
>> On May 10, 11:37 am, Timothy Baldridge  wrote: 
>> > On Tue, May 10, 2011 at 10:26 AM, Jonathan Fischer Friberg < 
>> > 
>> > odysso...@gmail.com> wrote: 
>> > > "How do I actually just load code w/o evaluating it?" 
>> > > mostly when you want something like this, you want a macro. 
>> Manipulating 
>> > > code is also done within macros. 
>> > 
>> > Yeah, I would consider the whole code-is-data thing to refer more to 
>> using 
>> > macros than eval. For something fun to read up on this check out this 
>> > tutorial: 
>> > 
>> > http://www.learningclojure.com/2010/09/clojure-faster-than-machine-co... 
>>
>> > 
>> > Here the author goes and takes a tree data structure, and on-the-fly 
>> > generates function that represents that structure. The result is some 
>> > insanely fast code. 
>> > 
>> > Timothy
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/826a9a4d-5b83-4f40-9eaf-2d6f77c3fa93n%40googlegroups.com.


Re: Rationale of behavior when invoking composite data type as 0-arity function

2021-11-25 Thread Brent Millare
Ok so I think taking a step back, I think their is some complecting going 
on here. I don't see how you see "that invoking a map without arguments 
evaluates it" as a generalization. I believe Rich's intention behind map's, 
set's, and vector's being callable is that they naturally behave as 
primitive (mathematically) functions, which map a key space to an output 
space. So first, there aren't any natural meanings for calling a map with 
zero arguments. (If anything, I think it should return nil. Because 
sometimes we would call functions using apply like (apply f [a b c]), and 
sometimes that list is empty, like (apply {} []). This is just like how (+) 
evaluates to 0. But I digress...).

What you are generally talking about is controlling code evaluation. You 
are specifically storing code within the values (and potentially keys) of 
the map. Really, this code is just lists, aka data. It is really important 
to keep the phases of evaluation separate, otherwise this makes macro 
writing very confusing (and coding in general). What you are suggesting 
complects calling a map (keys to values), with evaling a map (recursively 
eval any non quoted lists). These are separate actions/ideas. When we do 
want to operate in different phases, then we really do want to call eval 
explicitly as this is a "dramatic" action. Eval takes literal data and 
pipes them through unless they are lists, where it treats the first arg as 
a function/special-form, and the output can be very different from the 
input. In contrast, often transformations on maps result in other maps. My 
take here is, again, this should be explicit. In your intended behavior 
example (({}) :b), it is calling eval behind the scenes. This is very 
hidden and leads to very different performance implications. My take is you 
are suggesting reducing code size but not actually addressing duplication, 
and in the process making special behaviors less intuitive. (One other 
thing is what you suggest doesn't blend nicely with -> as you'd still have 
to call .invoke at the end instead of just calling eval.)

-

To support your cause, however, I think there are many tools to help you 
with code manipulation and code analysis during runtime.

If you want your code to work as is but have code analysis phases, you can 
use macros to insert code analyzing phases without impacting the evaluation 
and runtime implications of the code itself.

For example:
(def code-size (atom 0))
(defmacro count-code [some-code]
  (reset! code-size (count (str some-code)))
  some-code)

(count-code {:a :b}) ;; => {:a :b}
@code-size ;; => 7

>From there, you can write code analysis walkers as functions (not macros) 
and use them at runtime with explicit quoted forms at the repl, or insert 
them into your macros for analyzing "production" code.
On Wednesday, November 24, 2021 at 2:52:43 PM UTC-5 dieter.v...@gmail.com 
wrote:

> Hello Brent,
>
> The use case I had in mind was to keep a map readable during development. 
> Take a simple map: {:type QTDIR :path (hash "a string")}. It's easier to 
> play with this data if evaluation of certain symbols and functions is 
> delayed.
>
> Thanks you both for your answer,
> kind regards,
> Dieter
>
>
>
>
> On Mon, Nov 22, 2021 at 3:39 AM Brent Millare  wrote:
>
>> I'm curious why you are saving hashmaps that have clojure code within it 
>> with the intention of evaluating this code as embedded in the hashmap? What 
>> is the use case? Are you trying to delay evaluation? Regardless, eval 
>> always incurs a cost and should generally be avoided if you can use 
>> "runtime" techniques instead. Is the embedded code trusted?
>>
>> Best,
>> Brent
>>
>> On Sunday, November 21, 2021 at 9:22:47 AM UTC-5 dieter.v...@gmail.com 
>> wrote:
>>
>>> Hello,
>>>
>>> It seems to be a design decision that 0-arity invoke of a composite data 
>>> type gives an ArityException: the composite data type does not implement 
>>> the IFn when no arguments are given.
>>> Is there a certain design decision behind this behavior? (or a certain 
>>> use-case)
>>>
>>>
>>> repl> ;composite data type evaluates to itself
>>> repl> {:a 1 :b (hash "word")} 
>>> {:a 1 :b -304538205}
>>> repl> '{:a 1 :b (hash "word")}
>>> {:a 1 :b (hash "word")}
>>> repl> (def mydata '{:a 1 :b (hash "word")})
>>> repl> mydata
>>> {:a 1 :b (hash "word")}
>>> repl> ;composite data type implements IFn for its keys
>>> repl> (mydata :b)
>>> (hash "word")
>>> repl> ; there is no '0-arity' implementation of IFn for composite data 
>>>

Re: Rationale of behavior when invoking composite data type as 0-arity function

2021-11-21 Thread Brent Millare
I'm curious why you are saving hashmaps that have clojure code within it 
with the intention of evaluating this code as embedded in the hashmap? What 
is the use case? Are you trying to delay evaluation? Regardless, eval 
always incurs a cost and should generally be avoided if you can use 
"runtime" techniques instead. Is the embedded code trusted?

Best,
Brent

On Sunday, November 21, 2021 at 9:22:47 AM UTC-5 dieter.v...@gmail.com 
wrote:

> Hello,
>
> It seems to be a design decision that 0-arity invoke of a composite data 
> type gives an ArityException: the composite data type does not implement 
> the IFn when no arguments are given.
> Is there a certain design decision behind this behavior? (or a certain 
> use-case)
>
>
> repl> ;composite data type evaluates to itself
> repl> {:a 1 :b (hash "word")} 
> {:a 1 :b -304538205}
> repl> '{:a 1 :b (hash "word")}
> {:a 1 :b (hash "word")}
> repl> (def mydata '{:a 1 :b (hash "word")})
> repl> mydata
> {:a 1 :b (hash "word")}
> repl> ;composite data type implements IFn for its keys
> repl> (mydata :b)
> (hash "word")
> repl> ; there is no '0-arity' implementation of IFn for composite data type
> repl> ({})
> ... (ArityException)...
> repl> (mydata)
> ... (ArityException)...
> repl> ; instead i have to type eval
> repl> ((eval mymap) :b)
>  -304538205
>
> I know its only 4 letters and a space extra, but software composition is 
> supposed to avoid code duplication and perhaps the idea makes sense that 
> invoking a map without arguments evaluates it... Hence the question about 
> the choice made for the current behavior.
>
> A possible small workaround  
> (defrecord qid [qid]
>  clojure.lang.IFn  
>  (invoke [this] (eval qid))
> But expect this to throw alot of bugs: this record is not the same simple 
> map.
> (issues with other protocols, reducers, transducers and much more I don't 
> know of.)
>
> I hope this is the right google group to ask this question.
> kind regards,
> Dieter
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/ff296de8-ce0f-4798-a1cc-cd3e4b38c631n%40googlegroups.com.


Re: Tour of our 250k line Clojure codebase

2021-06-04 Thread Brent Millare
Haven't read the article yet but thanks for the work, will definitely give 
it a read asap. After hearing (already a while ago) that Storm moved to 
Java, I'm happy to hear Clojure is still actively used (and even 
instrumental) in your current work.

On Thursday, June 3, 2021 at 11:42:36 PM UTC-4 natha...@gmail.com wrote:

> Probably not in the near future. Once we're close to being ready for 
> production usage, we'll be releasing a preview post demonstrating how our 
> product works through an example of using it to replicate a widely-used 
> service in a comparatively minuscule amount of code. Though we're already 
> able to build and run arbitrary applications at scale, we still have a lot 
> of work to do on operational features to enable the fault-tolerance 
> necessary for production usage.  
>
> On Thursday, June 3, 2021 at 5:24:00 PM UTC-10 Robert P. Levy wrote:
>
>> Great post on the technical choices made in developing this platform.  Do 
>> you plan on writing a post that describes in detail the system architecture 
>> that is the bread and butter of the product/platform itself?
>>
>> The website intriguingly states, "Red Planet Labs is pioneering a 
>> radically new kind of software tool. It's not just for the initial 
>> construction of an application, but also encapsulates deployment, 
>> monitoring, and maintenance. It implements the first truly cohesive model 
>> for building software applications – a set of abstractions that can build 
>> any application at any scale with greatly reduced engineering cost."
>>
>> It seems like a full article expanding on the infrastructure-level 
>> design, and the approach to generalizing and abstracting infrastructure, 
>> would be very interesting.
>>
>>
>> On Thu, Jun 3, 2021 at 7:12 PM Nathan Marz  wrote:
>>
>>> Derek – we have a bunch of open-source on our Github 
>>> . I'd like to release our new 
>>> language one day, but that won't be for a long time. When I release it I 
>>> want to do it the right way – extensive documentation, academic papers, and 
>>> a commitment to supporting the language in broader usage. At our early 
>>> stage we just don't have the bandwidth for that as we're working hard to 
>>> get our first product out the door. Plus at the moment out language is our 
>>> "secret weapon" :)
>>>
>>> Leandro – I started working on this codebase well before spec was 
>>> released. Had spec existed when I started I would have explored it more 
>>> thoroughly, but Schema has met our needs very gracefully. As for 
>>> deterministic simulation, it's orthogonal to techniques like test.check. I 
>>> suggest you check our our earlier blog post 
>>> 
>>>  
>>> on the subject. 
>>>
>>> On Thursday, June 3, 2021 at 3:09:28 PM UTC-10 ldoc...@gmail.com wrote:
>>>


 On Thu, 3 Jun 2021, 15:06 natha...@gmail.com,  
 wrote:

 Please give the post a read, and I'm happy to answer any questions.
>

 Nice article, Nathan. Definitely, it would be nice to see the code :-)

 Just curious...

 1) You mention using Schema for data definition and validation. Did you 
 consider using other options for this, such as clojure.spec? What's your 
 experience with it/them?

 2) You mention using "deterministic simulation". Did you consider using 
 other options for this, such as test.check? What's your experience with 
 it/them?

 Best,
 Leandro

> -- 
>>> 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.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/clojure/70353370-6dd2-4ddc-af82-2fce32ee6bden%40googlegroups.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 

Re: How get function name in body?

2021-05-04 Thread Brent Millare
That's a useful tip! Thanks

On Monday, May 3, 2021 at 11:21:18 AM UTC-4 noise...@gmail.com wrote:

> there's a handy trick for pulling in the standard repl aliases / refers:
>
> (cmd)user=> clojure.main/repl-requires
> [[clojure.repl :refer (source apropos dir pst doc find-doc)] 
> [clojure.java.javadoc :refer (javadoc)] [clojure.pprint :refer (pp pprint)]]
> (ins)user=> (ns foo.bar)
> nil
> (ins)foo.bar=> (doc fn)
> Syntax error compiling at (REPL:1:1).
> Unable to resolve symbol: doc in this context
> (ins)foo.bar=> (apply require clojure.main/repl-requires)
> nil
> (cmd)foo.bar=> (doc fn)
> -
> clojure.core/fn
>   (fn name? [params*] exprs*)
>   (fn name? ([params*] exprs*) +)
> ([& sigs])
> Special Form
> ...
>
> On Thu, Apr 29, 2021 at 10:41 PM Sean Corfield  wrote:
>
>> Sorry, it's clojure.repl/demunge so it depends on how you run your REPL 
>> and evaluate code -- in my case, clojure.repl symbols were all referred in. 
>> In your case, you'll need to require clojure.repl and refer it in:
>>
>> (require '[clojure.repl :refer [demunge])
>>
>> or make that part of your ns form as:
>>
>>   (:require [clojure.repl :refer [demunge]])
>>
>> -- 
>> Sean A Corfield -- (904) 302-SEAN
>> An Architect's View -- https://corfield.org/
>> World Singles Networks, LLC. -- https://worldsinglesnetworks.com/
>>
>> "Perfection is the enemy of the good."
>> -- Gustave Flaubert, French realist novelist (1821-1880)
>>
>> On Thu, Apr 29, 2021 at 10:27 PM damon kwok  wrote:
>>
>>>
>>> Clojure 1.10.1
>>>(defn haha []
>>>(println (demunge (.getName (.getCallerClass 
>>> (java.lang.StackWalker/getInstance 
>>> java.lang.StackWalker$Option/RETAIN_CLASS_REFERENCE))
>>> Syntax error compiling at (REPL:1:23).
>>> Unable to resolve symbol: demunge in this context
>>> 在2021年4月30日星期五 UTC+8 上午4:35:45 写道:
>>>
 That's definitely nicer:

 dev=> (*defn* *add* [a b]

  #_=>   (*println* (demunge (*.getName* (*.getCallerClass* (
 *java.lang.StackWalker*/getInstance *java.lang.StackWalker$Option*
 /RETAIN_CLASS_REFERENCE)

  #_=>   (*+* a b))

 #'dev/add

 dev=> (add 1 2)

 dev/add

 3

 dev=> 

 Thanks, Rémi!

 On Thu, Apr 29, 2021 at 12:08 PM Remi Forax  wrote:

>
>
> --
>
> *De: *"Sean Corfield" 
> *À: *"clojure" 
> *Envoyé: *Jeudi 29 Avril 2021 01:26:34
> *Objet: *Re: How get function name in body?
>
> Consider that:
>
> (defn add [a b] (+ a b))
>
> is expanded to (something like):
>
> (def add (fn [a b] (+ a b)))
>
> So the actual code that runs is an anonymous function, which is bound 
> to the (global) var #'add -- the function itself has no name.
>
> dev=> (*macroexpand* '(*defn**add* [a b] (*+* a b)))
>
> (def add (clojure.core/fn ([a b] (+ a b
>
> dev=> (*defn**add* [a b] (*+* a b))
>
> #'dev/add
>
> dev=> add
>
> #object[dev$add 0x72f91c91 "dev$add@72f91c91"]
>
> So the value of add is an object, with type dev$add, a class that 
> implements a bunch of things including clojure.lang.IFn and 
> java.lang.Runnable and java.util.concurrent.Callable etc.
>
> The "name" of function is hard to get to, inside a function because of 
> that.
>
> One way to figure that out at runtime is to dig into the stack, which 
> you can get at by creating an exception and inspecting it: be aware that 
> this is an expensive operation!
>
> dev=> (*defn**add* [a b]
>
> #_=> (*let* [frame (*first* (*:trace* (*Throwable->map* (*ex-info**""* 
> {}]
>
> #_=> (*println* (demunge (*name* (*first* frame
>
> #_=> (*+* a b)))
>
> #'dev/add
>
> dev=> (add 1 2)
>
> dev/add
>
> 3
>
> dev=>
>
> demunge is what turns Clojure's generated classnames back into 
> readable source names.
>
>
> Instead of using the stacktrace of java.lang.Throwable, you can use 
> StackWalker.getCallerClass() if you are using a jdk 9+
>
>
> The more important question is: why do you want the function's name 
> inside the body?
> -- 
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- https://corfield.org/
> World Singles Networks, LLC. -- https://worldsinglesnetworks.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
>
> Rémi
>
> [1] 
> https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/lang/StackWalker.html#getCallerClass()
>
> -- 
> 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 

Re: [ANN] 6x new major lib updates incl. HTTP-Kit, Sente, Timbre, Carmine

2020-09-22 Thread Brent Millare
Thanks for this!

On Tuesday, September 22, 2020 at 4:33:25 AM UTC-4 ptaou...@gmail.com wrote:

> Hi everyone,
>
> I managed to get an opportunity recently to spend some non-trivial time on 
> open-source for a few days! Have cut new releases of several libraries 
> below. 
>
> In all cases a big thanks to contributors!
>
> As usual, please check the CHANGELOGs carefully and please do report any 
> issues.
>
> Have a great week everyone, enjoy!
>
> Cheers :-)
>
>
> *- HTTP-Kit v2.5.0*
>
> HTTP-Kit is a simple high-performance event-driven HTTP client+server with 
> WebSocket support for Clojure.
>
> v2.5.0 includes GraalVM Native Image compatibility, misc improvements for 
> modern JDKs, and a couple new features.
>
> https://github.com/http-kit/http-kit/releases/tag/v2.5.0
>
>
> *- Sente v1.16.0*
>
> Sente is a library for Clojure + ClojureScript to help build reliable, 
> high-performance realtime web applications over WebSockets and Ajax.
>
> v1.16.0 includes Jetty 9 + Undertow adapters, Clojure client support, and 
> more.
>
> https://github.com/ptaoussanis/sente/releases/tag/v1.16.0
>
>
> *- Timbre v5.0.0*
>
> Timbre is a pure Clojure + ClojureScript logging library that's easily 
> configured with plain Clojure data and fns.
>
> v5.0.0 includes per-namespace minimum log levels to match Tufte, new 
> Syslog + UDP appenders, improved documentation, and much more.
>
> https://github.com/ptaoussanis/timbre/releases/tag/v5.0.0
>
>
> *- Carmine v3.0.0*
>
> Carmine is a pure Clojure client for Redis. It includes a basic message 
> queue.
>
> v3.0.0 includes an important security fix (via Nippy update), and 
> significant reliability improvements to Pub/Sub.
>
> https://github.com/ptaoussanis/carmine/releases/tag/v3.0.0
>
>
> *- Nippy v3.0.0*
>
> Nippy is the fastest schema-less serialization library for Clojure, and 
> can be used as a drop-in replacement for Clojure's reader.
>
> v3.0.0 includes easier upgrading from <= v2.14, options to exclude 
> metadata on freeze/thaw, and more.
>
> https://github.com/ptaoussanis/nippy/releases/tag/v3.0.0
>
>
> *- Tufte v2.2.0*
>
> Tufte is a s simple Clojure + ClojureScript performance profiling + 
> monitoring library. Can be used to monitor application performance in 
> dev/staging/production/etc.
>
> v2.2.0 includes  optional per-namespace minimum levels to match Timbre.
>
> https://github.com/ptaoussanis/tufte/releases/tag/v2.2.0
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/602dc571-de8e-40ff-84c2-f59916911369n%40googlegroups.com.


Re: Cognitect joins Nubank!

2020-07-23 Thread Brent Millare
Great news! Thanks for your continuing dedication to this passion project! 
Looking forward to what's to come.

On Thursday, July 23, 2020 at 8:04:49 AM UTC-4, Rich Hickey wrote:
>
> We are excited to announce that Cognitect is joining the Nubank family of 
> companies: 
>
> https://cognitect.com/blog/2020/07/23/Cognitect-Joins-Nubank 
>
> Clojure remains independent, and development and stewardship will continue 
> as it has, with more resources and a much larger sponsoring organization in 
> Nubank. Rich, Stu, Alex et al are all on board. We are dedicated to growing 
> the Clojure community, and helping companies adopt and succeed with 
> Clojure. 
>
> 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/2913020f-cbb2-4c50-a90f-1957b53cf567o%40googlegroups.com.


Re: [ANN] proxy-plus: Faster and more usable replacement for "proxy"

2020-01-14 Thread Brent Millare
Thanks this is wonderful! Nice work

On Tuesday, January 14, 2020 at 11:58:17 AM UTC-5, Nathan Marz wrote:
>
> The speedup comes from proxy+ directly overriding methods with the 
> provided implementation, while Clojure's proxy has additional indirection. 
> For example, if you do (proxy [Object] [] (toString [] "hello")), the 
> bytecode for toString is:
>
>   public java.lang.String toString();
>
>  0  aload_0 [this]
>
>  1  getfield user.proxy$java.lang.Object$ff19274a.__clojureFnMap : 
> clojure.lang.IPersistentMap [16]
>
>  4  ldc  [52]
>
>  6  invokestatic clojure.lang.RT.get(java.lang.Object, 
> java.lang.Object) : java.lang.Object [36]
>
>  9  dup
>
> 10  ifnull 28
>
> 13  checkcast clojure.lang.IFn [38]
>
> 16  aload_0 [this]
>
> 17  invokeinterface clojure.lang.IFn.invoke(java.lang.Object) : 
> java.lang.Object [55] [nargs: 2]
>
> 22  checkcast java.lang.String [57]
>
> 25  goto 33
>
> 28  pop
>
> 29  aload_0 [this]
>
> 30  invokespecial java.lang.Object.toString() : java.lang.String [59]
>
> 33  areturn
>
> Clojure keeps the implementations in a map, and for every dispatch it does 
> a map lookup by the method name. This is also why it can't handle 
> overriding the same method name with different arities.
>
> For (proxy+ [] Object (toString [this] "hello")), the bytecode is:
>
>   public java.lang.String toString();
>
>  0  aload_0 [this]
>
>  1  getfield user.proxy_plus5358.toString5357 : clojure.lang.IFn [19]
>
>  4  aload_0 [this]
>
>  5  invokeinterface clojure.lang.IFn.invoke(java.lang.Object) : 
> java.lang.Object [30] [nargs: 2]
>
> 10  checkcast java.lang.String [32]
>
> 13  areturn
>
> The implementation function is stored as a field, so the cost of dispatch 
> is a field get rather than a map lookup.
>
> Clojure's proxy also overrides *every* available method in all 
> superclasses/interfaces, while proxy+ only overrides what you specify. So 
> proxy+ generates much smaller classes than proxy.
>
>
> On Tuesday, January 14, 2020 at 10:30:32 AM UTC-5, Brent Millare wrote:
>>
>> I skimmed the code, I don't really understand how it makes it faster over 
>> proxy. Is it the generated ASM is better? What's the in-a-nutshell 
>> description of how it works?
>>
>> On Monday, January 13, 2020 at 1:28:46 PM UTC-5, Nathan Marz wrote:
>>>
>>> No differences in behavior except for API being like reify. It 
>>> integrates with AOT and can be consumed just like any other class. No idea 
>>> how it interacts with Graal.
>>>
>>> On Monday, January 13, 2020 at 12:29:35 PM UTC-5, John Newman wrote:
>>>>
>>>> Bravo 
>>>>
>>>> Are there any differences in behavior to be aware of? AOT, Graal, 
>>>> consuming proxy+ classes from vanilla clojure classes?
>>>>
>>>> On Mon, Jan 13, 2020, 11:47 AM Nathan Marz  wrote:
>>>>
>>>>> proxy+ is a replacement for Clojure's proxy that's faster and more 
>>>>> usable. proxy has a strange implementation where it overrides every 
>>>>> possible method and uses a mutable field to store a map of string -> 
>>>>> function for dispatching the methods. This causes it to be unable to 
>>>>> handle 
>>>>> methods with the same name but different arities.
>>>>>
>>>>> proxy+ fixes these issues with proxy. Usage is like reify, and it's up 
>>>>> to 10x faster.
>>>>>
>>>>> *Repository: *https://github.com/redplanetlabs/proxy-plus
>>>>>
>>>>> -- 
>>>>> 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
>>>>> clo...@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 clo...@googlegroups.com.
>>>>> To view this discuss

Re: [ANN] proxy-plus: Faster and more usable replacement for "proxy"

2020-01-14 Thread Brent Millare
I skimmed the code, I don't really understand how it makes it faster over 
proxy. Is it the generated ASM is better? What's the in-a-nutshell 
description of how it works?

On Monday, January 13, 2020 at 1:28:46 PM UTC-5, Nathan Marz wrote:
>
> No differences in behavior except for API being like reify. It integrates 
> with AOT and can be consumed just like any other class. No idea how it 
> interacts with Graal.
>
> On Monday, January 13, 2020 at 12:29:35 PM UTC-5, John Newman wrote:
>>
>> Bravo 
>>
>> Are there any differences in behavior to be aware of? AOT, Graal, 
>> consuming proxy+ classes from vanilla clojure classes?
>>
>> On Mon, Jan 13, 2020, 11:47 AM Nathan Marz  wrote:
>>
>>> proxy+ is a replacement for Clojure's proxy that's faster and more 
>>> usable. proxy has a strange implementation where it overrides every 
>>> possible method and uses a mutable field to store a map of string -> 
>>> function for dispatching the methods. This causes it to be unable to handle 
>>> methods with the same name but different arities.
>>>
>>> proxy+ fixes these issues with proxy. Usage is like reify, and it's up 
>>> to 10x faster.
>>>
>>> *Repository: *https://github.com/redplanetlabs/proxy-plus
>>>
>>> -- 
>>> 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
>>> clo...@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 clo...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/clojure/6d9bf48a-c5b5-417a-9f66-aa494cc38346%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/1fdbb59a-73b5-4a79-94b1-6769578fe019%40googlegroups.com.


Re: Protocols considered harmful?

2018-05-23 Thread Brent Millare
The strongest case for using protocols is for working with existing types. 
This usually means other people's code, java types etc. This is unique 
functionality to clojure and is probably its most important motivation. 
This also means that reloading doesn't usually cause issues, since the 
types aren't changing.

Still, Protocols, and even multimethods have limitations. Which means, for 
any given problem, make sure you start from first principles and not just 
immediately turn one or the other. You have full functional programming to 
work for you.

For example, I defined my own version of local multimethods, which are 
immutable. This means you can extend to different dispatch values 
differently in different contexts very easily. Multimethods are basically 
global variables and also have reloading problems. Since local-multi-fns 
are defined by functions in hash-maps, you can merge, add, remove as you 
please, and reloading is managed by you. You can use atoms for example, and 
atoms can help with recursive local-multi-fns (still just one way to do it).

Details of the idea is
https://github.com/bmillare/dj.plurality

A simplified definition is like the following:
(defn very-simple-multi-fn [implementations dispatch-fn]
  (with-meta (fn [& args] (apply (implementations (dispatch-fn args)) 
args)) {::very-simple-multi-fn {:implementations implementations}}))

(let [x (very-simple-multi-fn {\a (fn [& args] ...) \b (fn [& args] ...)} 
(fn [args] ...))]
   (x ...)
   (let [y (very-simple-multi-fn (-> x meta ::very-simple-mulfi-fn 
:implementations (merge {\c ... \a ...})) new-dispatch-fn)]
  (y ...)))

I recommend just writing your own version of this and decide how much 
flexibility you need.

On Tuesday, May 22, 2018 at 1:49:35 AM UTC-4, Sam Bartolucci wrote:
>
> Hi,
>
> I've been an enthusiastic Clojure tinkerer for a few years now--it's a 
> great language!--but only recently began using it professionally, where 
> I've stumbled into a strong disagreement over the use of protocols vs. 
> multimethods for single dispatch polymorphism. I had always assumed that 
> protocols were a normal part of Clojure when polymorphism was called for, 
> but a few of my coworkers (often, it seems, those who have experience with 
> Lisp prior to Clojure) swear up and down that protocols are only to be used 
> as a last resort because they "break the REPL". Apparently they're frowned 
> upon because, due to the JVM interop, they don't reload as well as other 
> constructs. It has even been suggested a few times that all uses of 
> protocols should be refactored to use a multimethod with a "type" as the 
> dispatch function. Protocols, in other words, should be considered harmful. 
> This seems strange to me considering how many successful and mainstream 
> Clojure projects use protocols, but maybe I am missing something, so I 
> thought I would ask the list. So what is it? Is there any consensus around 
> the assertion that "good, idiomatic Clojure will use multimethods rather 
> than protocols for single-dispatch polymorphism"?
>
> Thanks,
> Sam
>

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

2017-12-13 Thread Brent Millare
If you are interested in this functionality, I would collaborate with you 
to develop a new project that uses pomegranate and the code in tools.deps 
to dynamically load deps.edn files without restarting the REPL.

For now, if I want to add a new artifact, I just call pomegranate directly. 
Just make sure to set clojure's base classloader to the currentThread.

(-> (Thread/currentThread)
(.setContextClassLoader (clojure.lang.RT/baseLoader)))

(cemerick.pomegranate/add-dependencies
 :coordinates '[[refactor-nrepl "2.3.1"]
[cider/cider-nrepl "0.16.0-SNAPSHOT"]]
 :repositories (merge a/maven-central
  {"clojars" "https://clojars.org/repo"}))


On Tuesday, December 12, 2017 at 7:39:35 PM UTC-5, Asim Jalis wrote:
>
> Is it possible to load deps.edn dynamically without restarting the REPL in 
> Clojure 1.9?
>

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

2017-09-13 Thread Brent Millare
Yeah, that's what I thought. I guess I'm using it in a way that's not 
standard practice. Luckily it's not a bottleneck in my case.

Has there been discussion about a "shortable" version of s/keys which just 
checks for key existence and doesn't recursively validate the corresponding 
values?

I suppose if performance were an issue assuming the same requirements, I'm 
guessing some minimal work key-checking algorithm exists that I could 
write. For now, clojure.spec is convenient.

On Wednesday, September 13, 2017 at 4:55:44 PM UTC-4, Alex Miller wrote:
>
> Seems pretty slow to dispatch on a linear series of spec validations, but 
> I don't see any reason it wouldn't work.
>
> On Wednesday, September 13, 2017 at 3:47:40 PM UTC-5, Brent Millare wrote:
>>
>> The example for multi-spec provided in the spec guide assumes a key that 
>> denotes a "type". (This key is used as the dispatch fn). In my situation, 
>> I'm assuming I don't have control over what maps are generated. In other 
>> words, I explicitly do not want to have to encode types into the input map. 
>> Instead, I want to rely on the "shape" (key set), since that is the most 
>> flexible. While I could create a dispatch function that analyzes the input 
>> and produces a "type", that offers no advantages over what I presented 
>> earlier. Adding more cases is not extensible since it requires redefining 
>> the dispatch fn. In other words, I'd be just copying pasting my presented 
>> function as the dispatch fn.
>>
>> Alex, did I address your point? Is the approach you are suggesting 
>> different?
>>
>> Alternatively, my previous example might have been misleading since I 
>> used keys to represent useful work. Perhaps it would have been better 
>> written as:
>>
>> (fn [m]
>>   (condp clojure.spec.alpha/valid? m
>>   ::foo-map-spec ... do foo stuff ...
>>   ::bar-map-spec ... do bar stuff ...))
>>
>> On Wednesday, September 13, 2017 at 3:46:43 PM UTC-4, Alex Miller wrote:
>>
>>> You might want to look at s/multi-spec which lets you create a variable 
>>> open spec based on a multimethod, which would in this case be based on key 
>>> availability.
>>>
>>>
>>> On Wednesday, September 13, 2017 at 11:54:31 AM UTC-5, Brent Millare 
>>> wrote:
>>>>
>>>> I have several maps with different combinations of keys for each map. I 
>>>> want to process each map but do different work depending on the set of 
>>>> keys 
>>>> available, basically dispatch on key availability. I thought clojure.spec 
>>>> might be a good fit for doing the classification step. So for each key, I 
>>>> could define a spec. Next, I would use clojure.spec.alpha/keys to define a 
>>>> spec for each set of keys I'd like to match. Finally, I would dispatch 
>>>> like 
>>>> so:
>>>>
>>>> (fn [m]
>>>>   (condp clojure.spec.alpha/valid? m
>>>>   ::foo-map-spec :do-foo-stuff
>>>>   ::bar-map-spec :do-bar-stuff))
>>>>
>>>> Does this seem reasonable?
>>>>
>>>> The advantage in my mind is its thorough, explicit, and easy to read. 
>>>> Possible downsides is performance if it mattered.
>>>>
>>>> What are the advantages/disadvantages to this approach compared to 
>>>> other methods?
>>>>
>>>

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

2017-09-13 Thread Brent Millare
The example for multi-spec provided in the spec guide assumes a key that 
denotes a "type". (This key is used as the dispatch fn). In my situation, 
I'm assuming I don't have control over what maps are generated. In other 
words, I explicitly do not want to have to encode types into the input map. 
Instead, I want to rely on the "shape" (key set), since that is the most 
flexible. While I could create a dispatch function that analyzes the input 
and produces a "type", that offers no advantages over what I presented 
earlier. Adding more cases is not extensible since it requires redefining 
the dispatch fn. In other words, I'd be just copying pasting my presented 
function as the dispatch fn.

Alex, did I address your point? Is the approach you are suggesting 
different?

Alternatively, my previous example might have been misleading since I used 
keys to represent useful work. Perhaps it would have been better written as:

(fn [m]
  (condp clojure.spec.alpha/valid? m
  ::foo-map-spec ... do foo stuff ...
  ::bar-map-spec ... do bar stuff ...))

On Wednesday, September 13, 2017 at 3:46:43 PM UTC-4, Alex Miller wrote:

> You might want to look at s/multi-spec which lets you create a variable 
> open spec based on a multimethod, which would in this case be based on key 
> availability.
>
>
> On Wednesday, September 13, 2017 at 11:54:31 AM UTC-5, Brent Millare wrote:
>>
>> I have several maps with different combinations of keys for each map. I 
>> want to process each map but do different work depending on the set of keys 
>> available, basically dispatch on key availability. I thought clojure.spec 
>> might be a good fit for doing the classification step. So for each key, I 
>> could define a spec. Next, I would use clojure.spec.alpha/keys to define a 
>> spec for each set of keys I'd like to match. Finally, I would dispatch like 
>> so:
>>
>> (fn [m]
>>   (condp clojure.spec.alpha/valid? m
>>   ::foo-map-spec :do-foo-stuff
>>   ::bar-map-spec :do-bar-stuff))
>>
>> Does this seem reasonable?
>>
>> The advantage in my mind is its thorough, explicit, and easy to read. 
>> Possible downsides is performance if it mattered.
>>
>> What are the advantages/disadvantages to this approach compared to other 
>> methods?
>>
>

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


using clojure spec for dispatching on different map structures

2017-09-13 Thread Brent Millare
I have several maps with different combinations of keys for each map. I 
want to process each map but do different work depending on the set of keys 
available, basically dispatch on key availability. I thought clojure.spec 
might be a good fit for doing the classification step. So for each key, I 
could define a spec. Next, I would use clojure.spec.alpha/keys to define a 
spec for each set of keys I'd like to match. Finally, I would dispatch like 
so:

(fn [m]
  (condp clojure.spec.alpha/valid? m
  ::foo-map-spec :do-foo-stuff
  ::bar-map-spec :do-bar-stuff))

Does this seem reasonable?

The advantage in my mind is its thorough, explicit, and easy to read. 
Possible downsides is performance if it mattered.

What are the advantages/disadvantages to this approach compared to other 
methods?

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


clj-duckling

2017-06-08 Thread Brent Millare
What are the typical uses cases of this library. Does it only parse temporal 
information?

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

2017-06-06 Thread Brent Millare
Ah this brings me back... the first edition was my first Clojure book. Nice 
work.

On Tuesday, June 6, 2017 at 4:45:28 AM UTC-4, Alex Miller wrote:
>
> https://pragprog.com/book/shcloj3/programming-clojure
>
>
> I've been working on this for the last year or so - this is a newly 
> updated version of the first Clojure book, Programming Clojure (the book 
> that I used when I was learning Clojure!). The 1st edition was written by 
> Stuart Halloway around the time of Clojure 1.0. The 2nd edition was updated 
> by Aaron Bedra around Clojure 1.3.
>
>
> This latest edition targets Clojure 1.9 and includes a revised version of 
> all of the existing text and examples, a new brief intro to transducers and 
> eager transformation in ch 4 (longer intro in Clojure Applied), a new 
> chapter all about spec (ch 5), and soon a new closing chapter that puts 
> things together in an app.
>
>
> This book is in beta, but is missing only two chapters which should be 
> coming along in the next month or two. If you have questions, it's best to 
> ask on the forum or file an errata rather than discuss here:
>
>
> - https://forums.pragprog.com/forums/439
>
> - https://pragprog.com/titles/shcloj3/errata (page coming soon)
>
>
> Alex
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] dj.solo: a minimal standalone kit for distributing clojure apps that can grow

2017-06-06 Thread Brent Millare
I wrote a guide available at https://github.com/bmillare/dj.solo on how to 
build fully isolated minimal Clojure "deployments" for friends. This is NOT 
intended to be an industrial grade solution. Instead I am documenting the 
surprisingly 
simple process of loading a basic Clojure application.

Imagine that you want to show off your new Clojure app to your friend but 
it turns out she uses Windows. She doesn't like you installing weird stuff 
on her computer so she said you are only allowed to run everything from a 
usb stick. To top it off, she doesn't even have Java installed. dj.solo solves 
this problem of "deploying" your app to your friend under her constraints. 
It does so by creating a standalone Clojure app/distribution that bundles 
everything you need to run the application, including the dependent jars, 
app source code, and the desired JVM. Nothing technically novel is 
presented. Instead a simple approach is documented that is easy to 
customize to your needs.


The advantages to this approach are:

   - isolated installation
   - barebones, minimal software
  - you know what's being installed and being depended on
  - startup to repl is much faster than leiningen or boot
 - you can always add them later if you need their functionality
  
The limitations to this approach are:

   - the OS will not suggest updates to Java
  - although, theoretically, you could have the app detect a new Java 
  version, download it, and set the correct new paths
   - You might have extra copies of Java, the system installation and the 
   app provided one
  - potentially, if you put multiple apps, you will have a lot of 
  copies of the JVM
  - this could be considered a feature if you want to run specific 
  versions
  - still trivial to manage your self with symlinks
   
Feedback welcome.

Best,
Brent

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

2016-06-27 Thread Brent Millare
Thanks for the predicates.

What does the integer numbers within
In: [[2015 6 31] 1 :chinups 1 0]
after the keywords and also the integers within
at: [1 1 :duration]
correspond to? It appears, you designate an index/id to each key of a map 
for "In:" but I have no idea how to line up "At:".

On Monday, June 27, 2016 at 9:26:26 PM UTC-4, Alex Miller wrote:
>
> There have been a lot of changes in map-of and coll-of for the next alpha, 
> in particular map-of and coll-of now conform all elements, which changes 
> what has been surprising behavior to many people both during conforming and 
> explain due to sampling (which has moved to the new every and every-kv). 
>
> The current error message in master that you'll see for this example is:
>
> In: [[2015 6 31] 1 :chinups 1 0] val: #user.rep_scheme{:weight 0, 
> :repetitions 13} fails spec: :user/workout at: [1 1 :duration] predicate: 
> [(contains? % :hours) (contains? % :minutes) (contains? % :seconds)]
> In: [[2015 6 31] 1 :chinups 1 1] val: #user.rep_scheme{:weight :x, 
> :repetitions 13} fails spec: :user/workout at: [1 1 :duration] predicate: 
> [(contains? % :hours) (contains? % :minutes) (contains? % :seconds)]
> In: [[2015 6 31] 1 :chinups 1 1 :weight] val: :x fails spec: :user/weight 
> at: [1 1 :rep_scheme :weight] predicate: number?
>
> Also, I made a few notes on better predicates you could use below inline.
>
>

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

2016-06-27 Thread Brent Millare
I'm playing with clojure.spec (alpha7) to validate a data structure storing 
information about workout history using the following code:

(ns v.scratch.lift-tracker
  (:require [clojure.spec :as s]))

(defrecord duration [hours minutes seconds])
(defrecord rep_scheme [weight repetitions])

(s/def ::day (s/and int? pos? #(< % 32)))
(s/def ::month (s/and int? pos? #(< % 13)))
(s/def ::year (s/and int? pos?))
(s/def ::date (s/tuple ::year ::month ::day))
(s/def ::hours int?)
(s/def ::minutes int?)
(s/def ::seconds int?)
(s/def ::weight number?)
(s/def ::repetitions (s/and int? pos?))
(s/def ::exercise-id keyword?)
(s/def ::workout (s/map-of ::exercise-id (s/or :duration (s/coll-of
  (s/keys :req-un 
[::hours ::minutes ::seconds])
  [])
   :rep_scheme (s/coll-of
(s/keys :req-un 
[::weight ::repetitions])
[]
(s/def ::history (s/map-of ::date ::workout))

The problem is that when using s/explain on an invalid input where the 
error is near the leaves, the error message points at the root of the data 
structure, which is not as useful.

(s/explain
 ::history
 {[2015 6 31] {:chinups [(->rep_scheme 0 13)
 (->rep_scheme :x 13)]
   :l-sit [(->duration 0 0 10)]}
  [2016 6 31] {:chinups [(->rep_scheme 0 13)
 (->rep_scheme 0 14)]
   :l-sit [(->duration 0 0 10)]}})

val: {[2015 6 31] {:chinups [#v.scratch.lift_tracker.rep_scheme{:weight 0, 
:repetitions 13} #v.scratch.lift_tracker.rep_scheme{:weight :x, 
:repetitions 13}], :l-sit [#v.scratch.lift_tracker.duration{:hours 0, 
:minutes 0, :seconds 10}]}, [2016 6 31] {:chinups 
[#v.scratch.lift_tracker.rep_scheme{:weight 0, :repetitions 13} 
#v.scratch.lift_tracker.rep_scheme{:weight 0, :repetitions 14}], :l-sit 
[#v.scratch.lift_tracker.duration{:hours 0, :minutes 0, :seconds 10}]}} 
fails spec: :v.scratch.lift-tracker/history predicate: (coll-checker (tuple 
:v.scratch.lift-tracker/date :v.scratch.lift-tracker/workout))

Is there a built in way to automatically recurse the sub-components to 
identify the problematic scope?

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

2016-06-10 Thread Brent Millare
You can run it like python, ruby, etc.

https://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips

Basically, at the top of a clj file, put:

":";exec /path/to/java -cp "/path/to/clojure.jar" clojure.main $0 "$@"

(ns command-line-args)

(defn command-line? []   
  (.isAbsolute (java.io.File. *file*)))

(defn main [] (println *command-line-args*))

(if (command-line?) (main))


If you need more dependencies, you can make an uberjar or use some code 
that dynamically pulls in dependencies like boot, lein, or pomegranate. I 
used this strategy when I needed my code to work on other people's systems 
with minimal installation requirements.

On Thursday, June 9, 2016 at 12:08:39 PM UTC-4, Jiacai Liu wrote:
>
> I  started learning clojure recently, and I am annoyed at the way to run 
> it (aka. lein run). why clojure script can't be run like python,ruby or 
> scala, like python .py
>

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

2016-05-25 Thread Brent Millare
Thanks Alex, perfect explanatory example

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

2016-05-25 Thread Brent Millare
What's the difference between clojure.spec/or and clojure.spec/alt? They 
seem to accept the same inputs, multiple keyword-predicate pairs, and 
output tagged values when used with clojure.spec/conform. Is 
clojure.spec/or usable within a regular expression?

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

2016-01-17 Thread Brent Millare
I think another useful way to look at the issue that Alan brings up is to 
view it as a top down vs bottom up approach to learning the language. The 
site favors a top down approach, leading with the rationale and concepts 
rather than examples that can act like hooks that encourage the reader to 
investigate further even without complete understanding. While I'm more of 
a default top down thinker myself, I know and respect many bottom up 
thinkers. I believe enhancing the website to address both learning 
approaches will increase its usability not to just beginners but also to 
experienced programmers.

On Friday, January 15, 2016 at 7:16:08 PM UTC-5, Alan Moore wrote:
>
> Great job everyone! I really like the layout and the color scheme, very 
> pleasing to the eye and professional looking.
>
> My *only* constructive comment is that a total newbie landing on 
> clojure.org is faced with a lot of reading when maybe they should be 
> presented with super basic code examples, just to give them a general feel 
> of what Clojure code looks like. Much of this does exist on the site but is 
> maybe less accessible and not as up-front as it could be. I'll submit some 
> suggestions via the public repo and do my part to help out :-)
>
> All in all this is looking great and I appreciate the hard work in getting 
> it to this point. Thanks Alex for organizing the effort!
>
> Alan
>
> On Thursday, January 14, 2016 at 7:45:06 AM UTC-8, Alex Miller wrote:
>>
>> The new http://clojure.org is alive!
>>
>> Most of the content on the site is the same content as before (but in a 
>> new shinier package). However, the site is now sourced from the public repo 
>> at https://github.com/clojure/clojure-site and is open for contribution. 
>> Contributions (via pull request) require a signed Clojure Contributor 
>> Agreement, just as with Clojure itself - if you've already signed it, then 
>> you don't need to do anything additional.
>>
>> We have been working on several new guides for the new Guides section and 
>> you can see things in process at 
>> https://github.com/clojure/clojure-site/issues - feel free to discuss on 
>> issues there or threads here with a [DOC] indicator. Or on the #docs 
>> channel on Slack.
>>
>> Big thanks to Tom Hickey on the design for the new site! As always, he 
>> was a pleasure to work with.
>>
>> Alex
>>
>

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


volatile vs java.util.concurrent.atomic.* vs atom

2015-03-12 Thread Brent Millare
Doing some simple microbenchmarks, I found something unexpected:

(time
 (let [v (volatile! 1)]
   (dotimes [x 1]
 (vreset! v @v
Elapsed time: 1016.992146 msecs

(time
 (let [v (java.util.concurrent.atomic.AtomicLong. 1)]
   (dotimes [x 1]
 (.set v (.get v)
Elapsed time: 672.869727 msecs

(time
 (let [v (java.util.concurrent.atomic.AtomicReference. {})]
   (dotimes [x 1]
 (.set v (.get v)
Elapsed time: 678.143133 msecs

(time
 (let [v (atom 1)]
   (dotimes [x 1]
 (reset! v @v
Elapsed time: 1100.689493 msecs

I expected volatile's to be faster. Maybe I'm not understanding the correct 
use case for volatiles but java.util.concurrent.atomic.Atomic* seems to be 
clearly the most performant. Given the downsides of using volatiles, is 
their existence justified when safer and faster alternatives exist?

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

2015-03-12 Thread Brent Millare
Good catch. With criterium, I can detect the small performance improvement.

volatile: Evaluation count : 7550019420 in 60 samples of 125833657 calls.
 Execution time mean : 6.345042 ns
Execution time std-deviation : 0.126086 ns
   Execution time lower quantile : 6.223058 ns ( 2.5%)
   Execution time upper quantile : 6.525868 ns (97.5%)
   Overhead used : 1.651549 ns
AtomicLong: Evaluation count : 6925392540 in 60 samples of 115423209 calls.
 Execution time mean : 7.156855 ns
Execution time std-deviation : 0.136142 ns
   Execution time lower quantile : 7.010743 ns ( 2.5%)
   Execution time upper quantile : 7.362120 ns (97.5%)
   Overhead used : 1.651549 ns
AtomicReference: Evaluation count : 6014401080 in 60 samples of 100240018 
calls.
 Execution time mean : 8.342217 ns
Execution time std-deviation : 0.126856 ns
   Execution time lower quantile : 8.129171 ns ( 2.5%)
   Execution time upper quantile : 8.511877 ns (97.5%)
   Overhead used : 1.651549 ns


On Wednesday, March 11, 2015 at 1:50:37 PM UTC-4, tbc++ wrote:

 Actaully I think it comes down to the use of the rather generic Deref. I 
 fired up a repl and ran the following 

 (let [v (clojure.lang.Volatile. {})]
   (dotimes [x ...]
 (.reset v (.deref v

 I'm seeing very similar times to the one for the AtomicReference.

 Timothy

 On Wed, Mar 11, 2015 at 11:08 AM, Brent Millare brent@gmail.com 
 javascript: wrote:

 I find it hard to believe GC would be a factor since there is very little 
 being generated here. Also, while the outside loop is only 10 iterations of 
 timings, in the inside loops the code is called for 100 million iterations. 
 Anyways, running it with criterium didn't change the ranking.

 Here is the output:
 volatile: WARNING: Final GC required 1.149417308725186 % of runtime
 Evaluation count : 4156079100 in 60 samples of 69267985 calls.
  Execution time mean : 12.975339 ns
 Execution time std-deviation : 0.188921 ns
Execution time lower quantile : 12.823222 ns ( 2.5%)
Execution time upper quantile : 13.272950 ns (97.5%)
Overhead used : 1.613416 ns
 AtomicLong: Evaluation count : 6921767160 in 60 samples of 115362786 
 calls.
  Execution time mean : 7.155989 ns
 Execution time std-deviation : 0.124147 ns
Execution time lower quantile : 7.048738 ns ( 2.5%)
Execution time upper quantile : 7.330448 ns (97.5%)
Overhead used : 1.613416 ns
 AtomicReference: Evaluation count : 5814704460 in 60 samples of 96911741 
 calls.
  Execution time mean : 8.791224 ns
 Execution time std-deviation : 0.185229 ns
Execution time lower quantile : 8.564921 ns ( 2.5%)
Execution time upper quantile : 9.340265 ns (97.5%)
Overhead used : 1.613416 ns

 Found 4 outliers in 60 samples (6.6667 %)
 low-severe 2 (3. %)
 low-mild 2 (3. %)
  Variance from outliers : 9.4134 % Variance is slightly inflated by 
 outliers
 atom: Evaluation count : 4038207840 in 60 samples of 67303464 calls.
  Execution time mean : 13.007604 ns
 Execution time std-deviation : 0.202285 ns
Execution time lower quantile : 12.819268 ns ( 2.5%)
Execution time upper quantile : 13.275983 ns (97.5%)
Overhead used : 1.613416 ns

 Note: I bench the get/set expression, not the creation of the 
 volatile/atomic*/atom

 eg.
 (let [v (volatile! 1)]
   (c/bench (vreset! v @v)))

 On Wednesday, March 11, 2015 at 12:30:06 PM UTC-4, tbc++ wrote:

 There's many other factors involved here though, GC, JIT warmup, etc. 
 That's kindof what criterium helps out with, removing all the variables and 
 running something until the JIT has warmed up enough (10 iterations 
 probably isn't enough). 

 Timothy


   -- 
 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 
 javascript:
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 “One of the main causes of the fall of the Roman Empire was that–lacking 
 zero–they had no way to indicate successful termination of their C 
 programs.”
 (Robert Firth) 
  

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

Re: volatile vs java.util.concurrent.atomic.* vs atom

2015-03-11 Thread Brent Millare
I find it hard to believe GC would be a factor since there is very little 
being generated here. Also, while the outside loop is only 10 iterations of 
timings, in the inside loops the code is called for 100 million iterations. 
Anyways, running it with criterium didn't change the ranking.

Here is the output:
volatile: WARNING: Final GC required 1.149417308725186 % of runtime
Evaluation count : 4156079100 in 60 samples of 69267985 calls.
 Execution time mean : 12.975339 ns
Execution time std-deviation : 0.188921 ns
   Execution time lower quantile : 12.823222 ns ( 2.5%)
   Execution time upper quantile : 13.272950 ns (97.5%)
   Overhead used : 1.613416 ns
AtomicLong: Evaluation count : 6921767160 in 60 samples of 115362786 calls.
 Execution time mean : 7.155989 ns
Execution time std-deviation : 0.124147 ns
   Execution time lower quantile : 7.048738 ns ( 2.5%)
   Execution time upper quantile : 7.330448 ns (97.5%)
   Overhead used : 1.613416 ns
AtomicReference: Evaluation count : 5814704460 in 60 samples of 96911741 
calls.
 Execution time mean : 8.791224 ns
Execution time std-deviation : 0.185229 ns
   Execution time lower quantile : 8.564921 ns ( 2.5%)
   Execution time upper quantile : 9.340265 ns (97.5%)
   Overhead used : 1.613416 ns

Found 4 outliers in 60 samples (6.6667 %)
low-severe 2 (3. %)
low-mild 2 (3. %)
 Variance from outliers : 9.4134 % Variance is slightly inflated by outliers
atom: Evaluation count : 4038207840 in 60 samples of 67303464 calls.
 Execution time mean : 13.007604 ns
Execution time std-deviation : 0.202285 ns
   Execution time lower quantile : 12.819268 ns ( 2.5%)
   Execution time upper quantile : 13.275983 ns (97.5%)
   Overhead used : 1.613416 ns

Note: I bench the get/set expression, not the creation of the 
volatile/atomic*/atom

eg.
(let [v (volatile! 1)]
  (c/bench (vreset! v @v)))

On Wednesday, March 11, 2015 at 12:30:06 PM UTC-4, tbc++ wrote:

 There's many other factors involved here though, GC, JIT warmup, etc. 
 That's kindof what criterium helps out with, removing all the variables and 
 running something until the JIT has warmed up enough (10 iterations 
 probably isn't enough). 

 Timothy


  

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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: volatile vs java.util.concurrent.atomic.* vs atom

2015-03-11 Thread Brent Millare
Well not exactly what you said cause I'm lazy, but a little bit more 
controlled:

timereference.clj:
(println Java: (System/getProperty java.version))
(println (clojure-version))

(dotimes [y 10]
  (print volatile: )
  (time
   (let [v (volatile! 1)]
 (dotimes [x 1]
   (vreset! v @v

  (print AtomicLong: )
  (time
   (let [v (java.util.concurrent.atomic.AtomicLong. 1)]
 (dotimes [x 1]
   (.set v (.get v)

  (print AtomicReference: )
  (time
   (let [v (java.util.concurrent.atomic.AtomicReference. {})]
 (dotimes [x 1]
   (.set v (.get v)

  (print atom: )
  (time
   (let [v (atom 1)]
 (dotimes [x 1]
   (reset! v @v)


[bmillare@sakura ~]$ java -server -cp 
.m2/repository/org/clojure/clojure/1.7.0-alpha5/clojure-1.7.0-alpha5.jar 
clojure.main timereference.clj 
Java:  1.7.0_75
1.7.0-alpha5
volatile: Elapsed time: 793.525092 msecs
AtomicLong: Elapsed time: 606.658899 msecs
AtomicReference: Elapsed time: 606.253989 msecs
atom: Elapsed time: 881.198546 msecs
volatile: Elapsed time: 787.714655 msecs
AtomicLong: Elapsed time: 603.810759 msecs
AtomicReference: Elapsed time: 603.811366 msecs
atom: Elapsed time: 1417.625552 msecs
volatile: Elapsed time: 794.154652 msecs
AtomicLong: Elapsed time: 603.718131 msecs
AtomicReference: Elapsed time: 603.723479 msecs
atom: Elapsed time: 866.220579 msecs
volatile: Elapsed time: 787.459397 msecs
AtomicLong: Elapsed time: 603.735881 msecs
AtomicReference: Elapsed time: 603.720108 msecs
atom: Elapsed time: 866.208679 msecs
volatile: Elapsed time: 787.455661 msecs
AtomicLong: Elapsed time: 603.720906 msecs
AtomicReference: Elapsed time: 603.735316 msecs
atom: Elapsed time: 866.226066 msecs
volatile: Elapsed time: 787.455482 msecs
AtomicLong: Elapsed time: 603.720222 msecs
AtomicReference: Elapsed time: 603.718667 msecs
atom: Elapsed time: 866.205402 msecs
volatile: Elapsed time: 789.429405 msecs
AtomicLong: Elapsed time: 603.71242 msecs
AtomicReference: Elapsed time: 603.717922 msecs
atom: Elapsed time: 866.212896 msecs
volatile: Elapsed time: 787.461736 msecs
AtomicLong: Elapsed time: 603.728396 msecs
AtomicReference: Elapsed time: 603.727234 msecs
atom: Elapsed time: 866.203579 msecs
volatile: Elapsed time: 787.462185 msecs
AtomicLong: Elapsed time: 603.721207 msecs
AtomicReference: Elapsed time: 603.716769 msecs
atom: Elapsed time: 866.207913 msecs
volatile: Elapsed time: 787.468805 msecs
AtomicLong: Elapsed time: 603.721715 msecs
AtomicReference: Elapsed time: 603.73172 msecs
atom: Elapsed time: 866.210223 msecs


On Wednesday, March 11, 2015 at 11:57:50 AM UTC-4, tbc++ wrote:

 This is interesting, but there could be many things in play here. Try 
 re-running the tests outside of lein (via compilation to a uberjar and then 
 running with java -jar) and also use criterium, as it will warn about many 
 things that coul effect performance . 

 https://github.com/hugoduncan/criterium

 Timothy Baldridge

 On Wed, Mar 11, 2015 at 9:38 AM, Brent Millare brent@gmail.com 
 javascript: wrote:

 Doing some simple microbenchmarks, I found something unexpected:

 (time
  (let [v (volatile! 1)]
(dotimes [x 1]
  (vreset! v @v
 Elapsed time: 1016.992146 msecs

 (time
  (let [v (java.util.concurrent.atomic.AtomicLong. 1)]
(dotimes [x 1]
  (.set v (.get v)
 Elapsed time: 672.869727 msecs

 (time
  (let [v (java.util.concurrent.atomic.AtomicReference. {})]
(dotimes [x 1]
  (.set v (.get v)
 Elapsed time: 678.143133 msecs

 (time
  (let [v (atom 1)]
(dotimes [x 1]
  (reset! v @v
 Elapsed time: 1100.689493 msecs

 I expected volatile's to be faster. Maybe I'm not understanding the 
 correct use case for volatiles but java.util.concurrent.atomic.Atomic* 
 seems to be clearly the most performant. Given the downsides of using 
 volatiles, is their existence justified when safer and faster alternatives 
 exist?

 -- 
 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 
 javascript:
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 “One of the main causes of the fall of the Roman Empire was that–lacking 
 zero–they had no way to indicate successful termination of their C 
 programs.”
 (Robert Firth) 
  

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email

Re: volatile vs java.util.concurrent.atomic.* vs atom

2015-03-11 Thread Brent Millare
Thanks for the extra analysis!

  

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

2014-09-10 Thread Brent Millare
So to summarize, Clojure's volatile provides synchronization across threads 
but does not provide atomaticity with vswap!. So, as a follow up question, 
then why would the creation of a volatile be dangerous but creating an 
atom isn't? (Hence the exclamation point in the name volatile!)

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

2014-09-10 Thread Brent Millare
When I say synchronization, I specifically mean writes are guaranteed to 
be seen by subsequent reads on any thread* *as Alex said.

On Wednesday, September 10, 2014 9:37:09 AM UTC-4, Brent Millare wrote:

 So to summarize, Clojure's volatile provides synchronization across 
 threads but does not provide atomaticity with vswap!. So, as a follow up 
 question, then why would the creation of a volatile be dangerous but 
 creating an atom isn't? (Hence the exclamation point in the name 
 volatile!)


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

2014-09-10 Thread Brent Millare
I understand usage of volatiles are dangerous via vswap! but what about 
creation? Again relating to what you said, 'I asked Rich and he said 
making a volatile is as dangerous as any ! op.'

On Wednesday, September 10, 2014 10:19:33 AM UTC-4, Alex Miller wrote:

 Usually that's called visibility. 

 Atoms are *not* subject to race conditions if swap! is called from 
 multiple threads (the state of the atom will not change while the update 
 function is being applied). The atom is thus safe to be used from 
 multiple threads.

 Volatiles *are* subject to race conditions with vswap! is called from 
 multiple threads (the state of the volatile may change while the update 
 function is being applied). The volatile is thus dangerous and safety is 
 derived from how it's used.

 On Wednesday, September 10, 2014 8:44:27 AM UTC-5, Brent Millare wrote:

 When I say synchronization, I specifically mean writes are guaranteed to 
 be seen by subsequent reads on any thread* *as Alex said.

 On Wednesday, September 10, 2014 9:37:09 AM UTC-4, Brent Millare wrote:

 So to summarize, Clojure's volatile provides synchronization across 
 threads but does not provide atomaticity with vswap!. So, as a follow up 
 question, then why would the creation of a volatile be dangerous but 
 creating an atom isn't? (Hence the exclamation point in the name 
 volatile!)



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

2014-09-09 Thread Brent Millare
Excuse my ignorance but does volatile! have anything to do with Java's 
volatile keyword? Is there any relation at all? I'm not suggesting a name 
change, but it can be confusing coming from that angle. Maybe a blurb in 
the doc string?

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

2014-07-23 Thread Brent Millare
I forgot to include in the snippet, that I would do something like

(def live-repl-client (cljs.repl/channel-repl repl-env))

When you say channel-repl/cider-function, do you mean user/live-repl-client?

I don't quite understand what you mean by (prefix).

What I want is just to be able to evaluate clojurescript code in a buffer 
just like I do with regular clojure code. This way I get the same access to 
large chunks of scratch code that I can only easily access when I have it 
in an emacs buffer.

I don't really know much about piggieback or austin. I'd prefer to stay as 
close to upstream/vanilla clojurescript as possible.

On Tuesday, July 22, 2014 9:36:56 PM UTC-4, frye wrote:

 Ooh, this looks interesting. Afraid I don't know enough elisp to be 
 useful. But it looks like you're already prompting the caller for the 
 *channel-repl/cider-function* name. Is there a reason you're not using it 
 (*prefix*) ? 

 Also can I ask how / where you plan to use this? Or is it just a generic 
 piece of code that will fit into a processing pipeline. 

 Is this something you would integrate with piggieback 
 https://github.com/cemerick/piggieback or austin 
 https://github.com/cemerick/austin? 


 Tim Washington 
 Interruptsoftware.com http://interruptsoftware.com 
  

 On Mon, Jul 21, 2014 at 1:31 PM, Brent Millare brent@gmail.com 
 javascript: wrote:

 As a work in progress, here is the code I came up with, it hard codes the 
 function name:


 (defun cider-eval-cljs-defun-at-point (optional prefix)
   Evaluate the current toplevel form, and print result in the minibuffer.
 With a PREFIX argument, print the result in the current buffer.
   (interactive P)
   (let ((form (concat (user/live-repl-client \
   (replace-regexp-in-string (regexp-quote \)
 (regexp-quote \\\)
  (replace-regexp-in-string (regexp-quote \\)
   (regexp-quote )
   (cider-defun-at-point)))
   \
 (if prefix
 (cider-interactive-eval-print form)
   (cider-interactive-eval form

 (define-key cider-mode-map (kbd C-c C-v) 
 'cider-eval-cljs-defun-at-point)
  
  
 -- 
 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 
 javascript:
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 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: How to control evaluation of code with cider

2014-07-21 Thread Brent Millare


 As a work in progress, here is the code I came up with, it hard codes the 
 function name:


(defun cider-eval-cljs-defun-at-point (optional prefix)
  Evaluate the current toplevel form, and print result in the minibuffer.
With a PREFIX argument, print the result in the current buffer.
  (interactive P)
  (let ((form (concat (user/live-repl-client \
  (replace-regexp-in-string (regexp-quote \)
(regexp-quote \\\)
(replace-regexp-in-string (regexp-quote \\)
  (regexp-quote )
  (cider-defun-at-point)))
  \
(if prefix
(cider-interactive-eval-print form)
  (cider-interactive-eval form

(define-key cider-mode-map (kbd C-c C-v) 'cider-eval-cljs-defun-at-point)
 

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


How to control evaluation of code with cider

2014-07-19 Thread Brent Millare
Backstory:

I modified the cljs.repl/repl to instead of pulling characters from *in*, 
but to use core.async channels, and to !! on an input-channel. When an 
input is received, a StringReader with the input is created and evaluation 
continues until either an error or printed output occur. Instead of 
printing to *out*, I use with-out-str to put *out* into a string, and then 
put onto an output-channel. I then wrap this whole repl in a 
clojure.core.async/thread. Then I return a helper function that when called 
with a string, sends it to the input channel, and then waits for the 
output, making it behave like a simple cljs-eval function.

The problem is the input is a string instead of cljs forms. Since cljs has 
different meaning behind the literal tags, I have to pass a string. What's 
really desired in the end, however, is how to get a block of clojurescript 
code in emacs, to be sent to this clojurescript repl.

The desired interface would be like so:

Write some clojurescript code in a scratch cider buffer. Then do something 
like C-c C-s, and the toplevel block of code will be sent to the cljs-repl 
function, and the output will be grabbed and sent to a result buffer, just 
like C-c C-f does for vanilla clojure code.

What emacslisp needs to be written and evaluated to get something like this 
to work?

A difficulty: I need to be able to define what function needs to be called 
each time. I can potentially have multiple channel-repls, and thus multiple 
channel-repl-eval functions that would be passed the code-as-a-strings. So 
we can't hardcode the name of a function that will be called each time (its 
possible the function name could be the same, but then something else that 
would be passed to the function, would be changed).

Code for channel-repl:

(in-ns 'cljs.repl)
(defn channel-repl
  Note - repl will reload core.cljs every time, even if supplied old 
repl-env
  [repl-env  {:keys [analyze-path verbose warn-on-undeclared special-fns 
static-fns] :as opts
   :or {warn-on-undeclared true}}]
  (let [in-chan (clojure.core.async/chan)
out-chan (clojure.core.async/chan)]
(clojure.core.async/thread
 (env/with-compiler-env
   (or (::env/compiler repl-env) (env/default-compiler-env opts))
   (binding [ana/*cljs-ns* 'cljs.user
 *cljs-verbose* verbose
 ana/*cljs-warnings* (assoc ana/*cljs-warnings*
   :unprovided warn-on-undeclared
   :undeclared-var warn-on-undeclared
   :undeclared-ns warn-on-undeclared
   :undeclared-ns-form 
warn-on-undeclared)
 ana/*cljs-static-fns* static-fns]
 (when analyze-path
   (analyze-source analyze-path))
 (let [env {:context :expr :locals {}}
   special-fns (merge default-special-fns special-fns)
   is-special-fn? (set (keys special-fns))
   read-error (Object.)]
   (-setup repl-env)
   (loop []
 (let [rdr (readers/source-logging-push-back-reader
(java.io.PushbackReader. (java.io.StringReader. 
(clojure.core.async/!! in-chan)))
1
NO_SOURCE_FILE)
   form (try
  (binding [*ns* (create-ns ana/*cljs-ns*)
reader/*data-readers* 
tags/*cljs-data-readers*
reader/*alias-map*
(apply merge
   ((juxt :requires :require-macros)
(ana/get-namespace 
ana/*cljs-ns*)))]
(reader/read rdr nil read-error))
  (catch Exception e
(clojure.core.async/!! out-chan
(.getMessage e))
read-error))]
   (cond
(identical? form read-error) (recur)
(= form :cljs/quit) :quit

(and (seq? form) (is-special-fn? (first form)))
(do (apply (get special-fns (first form)) repl-env (rest 
form))
(newline)
(recur))

:else
(do (clojure.core.async/!! out-chan
(with-out-str (eval-and-print 
repl-env env form)))
(recur)
   (-tear-down repl-env)
(fn [txt]
  (clojure.core.async/go
   (clojure.core.async/! in-chan
  txt))
  (clojure.core.async/!! out-chan

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

Found some unexpected behavior to me

2014-02-27 Thread Brent Millare
Clojure 1.5.1

user= (defprotocol IEmit (-emit [x]))
IEmit

user= (defrecord css [y] IEmit (-emit [_] y))
user.css

user= (-emit (-css 3))
3

user= (map -emit [(-css 3)])
IllegalArgumentException No matching field found: emit for class user.css 
 clojure.lang.Reflector.getInstanceField (Reflector.java:271)

user= (map #(-emit %) [(-css 3)])
(3)


Why can't I pass -emit as an argument to map?

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


Re: [ANN] Introducing VDD Core - Visualization Driven Development in Clojure

2013-09-12 Thread Brent Millare
I want to support that notion. For the purpose of information gathering, 
you should create visuals for your project since not everyone can try it 
out on whatever computer they are on.

On Thursday, September 12, 2013 2:25:53 AM UTC-4, martin_clausen wrote:

 Looks very interesting.

 While the examples are easy to get up and running you should consider 
 including a few screenshots in the the wiki and main github page. I think 
 that would give a really good sense of the potential of this project.

 Martin

 On Wednesday, September 11, 2013 2:13:26 AM UTC+2, Jason Gilman wrote:

 I've just released a new open source tool, VDD Core, to help enable 
 Visualization Driven Development in Clojure. Visualization Driven 
 Development and VDD Core are the subject of my Strange Loop talk (
 https://thestrangeloop.com/sessions/visualization-driven-development) 
 next week. VDD Core's goal is to make it easy to capture and send data to 
 be visualized in a web browser. This is an early alpha release. I hoping to 
 get others interested and testing it out. 

 You can read more about VDD Core and Visualization Driven Development at 
 the following places:

   * Blog Announcement: http://www.element84.com/announcing-vdd-core.html
   * Github Page: https://github.com/Element84/vdd-core
   * Wiki: https://github.com/Element84/vdd-core/wiki
   * Example Project: https://github.com/Element84/vdd-core-examples


 Thanks,
 Jason Gilman



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


question about 10k processes post

2013-08-04 Thread Brent Millare
From David Nolen's recent post with core.async, 
http://swannodette.github.io/2013/08/02/10-processes/

in the last let block, what is the purpose of:

(when (zero? (mod i 1000))
(! (timeout 0)))

?

Why pull from a channel that produces nothing useful (nil) ?
What create a timeout of 0, which to my knowledge is a channel that 
produces a nil value immediately?

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




clojure keyword spec

2013-07-31 Thread Brent Millare
I've been discovering in my code that namespaced identifiers are a 
wonderful thing. In particular, I am found of namespaced integers as an id.

Keywords usually serve the role as identifiers, but currently, the spec 
does not allow namespaced integers, which is odd since integers are valid 
as keywords and you can namespace words.

Again in table form:

Keyword...
name-starts-with | has-namespace | is-valid?
letter, no, yes
letter, yes, yes
number, no, yes
number, yes, no -- This is odd

Can we change this so we don't get stack traces like so?

clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: 
Invalid token: :asdf/3a
   LispReader.java:220 
clojure.lang.LispReader.read
 core.clj:3407 clojure.core/read
 core.clj:3405 clojure.core/read
 interruptible_eval.clj:52 
clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
  main.clj:257 clojure.main/repl[fn]
  main.clj:257 clojure.main/repl[fn]
  main.clj:277 clojure.main/repl[fn]
  main.clj:277 clojure.main/repl
  RestFn.java:1096 
clojure.lang.RestFn.invoke
 interruptible_eval.clj:56 
clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
  AFn.java:159 
clojure.lang.AFn.applyToHelper
  AFn.java:151 clojure.lang.AFn.applyTo
  core.clj:617 clojure.core/apply
 core.clj:1788 
clojure.core/with-bindings*
   RestFn.java:425 
clojure.lang.RestFn.invoke
 interruptible_eval.clj:41 
clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:171 
clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
 core.clj:2330 clojure.core/comp[fn]
interruptible_eval.clj:138 
clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
   AFn.java:24 clojure.lang.AFn.run
  ThreadPoolExecutor.java:1145 
java.util.concurrent.ThreadPoolExecutor.runWorker
   ThreadPoolExecutor.java:615 
java.util.concurrent.ThreadPoolExecutor$Worker.run
   Thread.java:724 java.lang.Thread.run
Caused by: java.lang.RuntimeException: Invalid token: :asdf/3a
 Util.java:219 
clojure.lang.Util.runtimeException
   LispReader.java:326 
clojure.lang.LispReader.interpretToken
   LispReader.java:211 
clojure.lang.LispReader.read

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




Re: clojure keyword spec

2013-07-31 Thread Brent Millare
I do want to change the spec since those rules are what the documentation 
say.

Let's highlight the question, does the same reasoning for restrictions on 
symbols also apply for keywords?

On Wednesday, July 31, 2013 5:36:15 PM UTC-4, John Hume wrote:

 It's probably worth distinguishing between the spec as documented on 
 clojure.org (or https://github.com/edn-format/edn if you prefer) and what 
 the reader permits. Symbols are documented to begin with a non-numeric 
 character (with a special note in the EDN spec about the names of 
 namespaced symbols following the same first-character rule. Keywords are in 
 both documents described as following the rules of symbols.

 The first char restriction for symbols makes sense, since they're 
 Clojure's identifier type, and the reader needs to be able to distinguish 
 between a number like `2M` and a symbol. I haven't thought of a reason it's 
 important to have the same restriction on keywords, but there may well be 
 one.

 Switching gears, you can do this (at least in Clojure 1.5.1):

 (keyword foo 1)
 (symbol foo 1)

 but since the docs say these are invalid, I wouldn't recommend using it in 
 non-throw-away code.



 On Wed, Jul 31, 2013 at 2:59 PM, Brent Millare 
 brent@gmail.comjavascript:
  wrote:

 I've been discovering in my code that namespaced identifiers are a 
 wonderful thing. In particular, I am found of namespaced integers as an id.

 Keywords usually serve the role as identifiers, but currently, the spec 
 does not allow namespaced integers, which is odd since integers are valid 
 as keywords and you can namespace words.

 Again in table form:

 Keyword...
 name-starts-with | has-namespace | is-valid?
 letter, no, yes
 letter, yes, yes
 number, no, yes
 number, yes, no -- This is odd

 Can we change this so we don't get stack traces like so?

 clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: 
 Invalid token: :asdf/3a
LispReader.java:220 
 clojure.lang.LispReader.read
  core.clj:3407 clojure.core/read
  core.clj:3405 clojure.core/read
  interruptible_eval.clj:52 
 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
   main.clj:257 clojure.main/repl[fn]
   main.clj:257 clojure.main/repl[fn]
   main.clj:277 clojure.main/repl[fn]
   main.clj:277 clojure.main/repl
   RestFn.java:1096 
 clojure.lang.RestFn.invoke
  interruptible_eval.clj:56 
 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
   AFn.java:159 
 clojure.lang.AFn.applyToHelper
   AFn.java:151 
 clojure.lang.AFn.applyTo
   core.clj:617 clojure.core/apply
  core.clj:1788 
 clojure.core/with-bindings*
RestFn.java:425 
 clojure.lang.RestFn.invoke
  interruptible_eval.clj:41 
 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
 interruptible_eval.clj:171 
 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
  core.clj:2330 clojure.core/comp[fn]
 interruptible_eval.clj:138 
 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:24 clojure.lang.AFn.run
   ThreadPoolExecutor.java:1145 
 java.util.concurrent.ThreadPoolExecutor.runWorker
ThreadPoolExecutor.java:615 
 java.util.concurrent.ThreadPoolExecutor$Worker.run
Thread.java:724 java.lang.Thread.run
 Caused by: java.lang.RuntimeException: Invalid token: :asdf/3a
  Util.java:219 
 clojure.lang.Util.runtimeException
LispReader.java:326 
 clojure.lang.LispReader.interpretToken
LispReader.java:211 
 clojure.lang.LispReader.read
  
 -- 
 -- 
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https

Re: ANN: Windows installer for Leiningen

2013-03-30 Thread Brent Millare
Nice work!

On Saturday, March 30, 2013 1:39:12 PM UTC-4, David Powell wrote:

 Hi,

 I've put together an installer for Leiningen on Windows:
 http://leiningen-win-installer.djpowell.net/

 Hopefully it should make it a bit easier for Windows people to get 
 Leiningen and a Clojure repl up and running.

 It requires a JDK to be installed first, but other than that there aren't 
 any dependencies.
 It should work on Windows XP and above, 32-bit or 64-bit.  With or without 
 powershell available.

 The installer should take the hassle out of setting up paths and 
 environment variables, and changing them when new JDKs are installed.

 The current version is beta1.  If you've got any feedback then give me an 
 email.

 -- 
 Dave



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




Re: Composable mutual recursive function composition

2013-03-11 Thread Brent Millare
I just added aliasing support. This way you can have interface keywords 
and depend on those. Then instead of redefining all functions to use a 
different key, you just change the alias.

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




Re: Windows Installation

2013-03-09 Thread Brent Millare
Does anyone see value in a wizard for lein? Does anyone know how to write a 
wizard, preferably with a scripting language, or xml, rather than c++? And 
can you alter system variables from within the wizard?

On Saturday, March 9, 2013 8:18:44 AM UTC-5, BJG145 wrote:

 As long as you have wget, that works fine. Only problem I've found so far 
 is that lein new app followed by lein check throws an error, but it 
 looks like people are on the case.

 https://github.com/technomancy/leiningen/issues/863



 On Saturday, March 9, 2013 11:24:04 AM UTC, Jonathan Fischer Friberg wrote:

 My experience:

 1. Download lein.bat
 2. Run it

 Jonathan



 On Sat, Mar 9, 2013 at 10:23 AM, BJG145 benmag...@gmail.com wrote:

 Perhaps this general anti-Windows attitude is what Windows-based 
 newcomers to Clojure find off-putting... 


 On Saturday, March 9, 2013 3:55:59 AM UTC, James Ashley wrote:

 Since I've seen a few recent posts about this experience, I figured I'd 
 share mine:

 0a) Install cygwin. I don't understand how any programmer stuck using 
 windows can get by without it
 1) Install the Oracle JDK
 1a) Add javac to my PATH (I added a symbolic link to javac.exe inside 
 cygwin in a directory that was already in my 
 PATH: ~/bin)
 2) Download the lein install script as text from the leiningen home 
 page.
 3) Copy it over to my cygwin directory
 4) Search/replace to replace the HTML entities with the real thing. I 
 think this was a matter of amp; and gt;
 5) It was already executable, so just run it (naming it lein.sh rather 
 than lein.bat was important). I got errors about
 certificates and permissions. They mentioned instructions about setting 
 up an environment variable (something
 about something like `export DOWNLOAD=curl --trusting %1`...that 
 wasn't it, but it was along the same lines).
 I believe that it's some weirdness in the account settings (I have 
 other issues along the same lines in totally 
 unrelated packages), but I suppose I could have just installed some 
 horrible virus. Oh, well.
 6) Create a new project
 7) Change project.clj to use clojure 1.5
 8) `lein repl` inside cygwin didn't work correctly. CLASSPATH was all 
 windows-style, which confused cygwin. So
 basic clojure.core pieces weren't found.
 8a) I suspect I could have set up, say, powershell, to make this work. 
 But that's stupid, and I don't have time
 to waste on it.
 9) nrepl-jack-in inside emacs worked fine.
 9a) I'm using an init.el from other systems that already have clojure 
 set up. But there isn't anything fancy or
 special or customized about it. Just standard configuration stuff that 
 I've found on bare-minimal blog posts
 10) Add a symlink to lein in ~/bin.

 I guess that probably looks big and scary. Windows users are used to a 
 pretty GUI that they ignore and click
 Next a lot. I dont have a lot of sympathy.

 I haven't done anything meaningful here at all. But the bare-bones part 
 of the installation process Just Worked.

 Thank you *so* much to all the people who have worked so hard to make 
 this as simple as it is!

 Respectfully,
 James

  -- 
 -- 
 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/groups/opt_out.
  
  




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




Composable mutual recursive function composition

2013-03-09 Thread Brent Millare
I recently asked about mutual referenced support in the prismatic library 
plumbing

https://github.com/Prismatic/plumbing

and currently its an open question about how to implement that.

So I made a proof-of-concept version of a graph-like library that 
supports mutual recursion.

https://github.com/bmillare/dj.compose

Note some differences:
* fnb are higher order functions, so its expected you use it to wrap an 
existing anonymous function
* functions in the bind-map are just plain functions and accept any number 
of arguments. They are not map oriented.

I encourage those interested to the read the sources, its only 1 macro, and 
1 function. Feedback appreciated.

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




Re: features expression

2013-03-07 Thread Brent Millare
From what I understand, the reader will call the tag function, thus being 
executed at read time and not compile time.

On Thursday, March 7, 2013 4:04:15 AM UTC-5, Akhil Wali wrote:

 IMHO features expressions should be evaluated at read-time only.
 Putting it off till the compilation phase only complicates things.
 So I'm actually favoring a preprocessing step like here -  
 http://dev.clojure.org/display/design/Feature+Expressions?focusedCommentId=6390066#comment-6390066

 The idea is simple; when the reader parses a sexpr, and if there's a 
 feature expression,then  only use the part that's relevant to the current 
 Clojure dialect.
 The only complication with this scheme is that all information in 
 *clojure-version* is related to the version numbers only; however, this 
 could be changed easily.



 On Thu, Mar 7, 2013 at 7:46 AM, Brent Millare 
 brent@gmail.comjavascript:
  wrote:

 +1

 Isn't is possible to accomplish all these efforts using tagged literals? 
 https://github.com/miner/wilkins

 This way the facilities for read-time code generation can be customized 
 and any reader that supports tagged-literals will support this. All of this 
 is data provided as arguments, no evaluation. Evaluation happens from the 
 tag function.

 On Wednesday, March 6, 2013 8:24:15 PM UTC-5, Brian Goslinga wrote:

 Do we really need new syntax for feature expressions? Although it would 
 be more ugly than CL's feature expressions, we could use a reader literal. 
 For example #feature [feature expression value]. Using a reader literal 
 is simple, compatible with EDN, and allows for the feature expressions to 
 be backported to an older version of Clojure using a library.

  -- 
 -- 
 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 unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




 -- 
 Akhil Wali 

 # http://github.com/darth10 https://github.com/darth10
 # http://darth10.github.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/groups/opt_out.




Re: Prismatic Plumbing and Graph Open-Source Release

2013-03-07 Thread Brent Millare
Hi,

Very nice work. I'm interested in using graph but just curious in terms of 
your priorities for future development.

I noticed that you listed as a todo, you might want to save the body of a 
fnk which I see as a potential for inlining the bodies and thus eliminating 
the fn call when creating the final composite fnk. Is this correct?

Also how would you advice situations when you have mutual recursion (with 
conditions to bound execution) but still want the compositional power of 
graph? (like being able to substitute only certain components of the graphs 
in different situations). I understand that my usage of recursion implies 
there will be cycles and graph only emits code in topological order so its 
currently not supported. Is there future support for this or is this 
outside the scope of graph? Any tips for reclaiming compositional power?

-Brent

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




Re: features expression

2013-03-06 Thread Brent Millare
+1

Isn't is possible to accomplish all these efforts using tagged 
literals? https://github.com/miner/wilkins

This way the facilities for read-time code generation can be customized and 
any reader that supports tagged-literals will support this. All of this is 
data provided as arguments, no evaluation. Evaluation happens from the tag 
function.

On Wednesday, March 6, 2013 8:24:15 PM UTC-5, Brian Goslinga wrote:

 Do we really need new syntax for feature expressions? Although it would be 
 more ugly than CL's feature expressions, we could use a reader literal. For 
 example #feature [feature expression value]. Using a reader literal is 
 simple, compatible with EDN, and allows for the feature expressions to be 
 backported to an older version of Clojure using a 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
--- 
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/groups/opt_out.




Re: Why is this so difficult?

2013-02-26 Thread Brent Millare
On another note, I wonder if a leiningen2 wizard installer for windows 
would be in high-demand (does one already exist?). Anyone familiar with 
writing windows wizards?

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




Re: ANN: NEVER use clojure.core/read or read-string for reading untrusted data

2013-02-11 Thread Brent Millare
Is it possible to elaborate on the reasons for not using read/read-string 
with *read-eval* bound to false for clojure 1.5 and greater? Is it just 
because they can execute dumb code that takes CPU cycles? It's not obvious 
to me.

Best,
Brent

On Monday, February 11, 2013 1:59:06 PM UTC-5, Mimmo Cosenza wrote:

 thanks by me too.

 mimmo

 On Feb 11, 2013, at 7:36 PM, AtKaaZ atk...@gmail.com javascript: 
 wrote:

 thank you, this was an easy read even for me


 On Mon, Feb 11, 2013 at 7:32 PM, Andy Fingerhut 
 andy.fi...@gmail.comjavascript:
  wrote:

 And just in case it gets edited by someone else before you have a chance 
 to read it, I've copied and pasted the current version below for reference. 
  Correction/comments/questions all welcome.

 On Feb 11, 2013, at 10:29 AM, Andy Fingerhut wrote:

  Following up on the thread *read-eval* vulnerability, I started 
 writing some documentation for how to read Clojure data safely.  That isn't 
 ready yet, but before I get the time to finish that I wanted to quickly get 
 out a warning that is obvious to some, but probably not all:
 
 NEVER use clojure.core/read or read-string for reading data from 
 untrusted sources, only trusted ones.  Even from trusted sources, binding 
 *read-eval* to false is probably a good idea, but that depends on your 
 particular use case.
 
 
  An example I wrote on ClojureDocs.org for function clojure.core/read 
 several months ago was very badly wrong.  It said that binding *read-eval* 
 to false would cause clojure.core/read to read data safely, even if that 
 data came from an untrusted source.
 
  I have modified that example to be a lot longer, and hopefully as 
 correct and scary as it should be.  Please take a look at it if you use 
 read or read-string anywhere in your Clojure code:
 
 http://clojuredocs.org/clojure_core/clojure.core/read
 
  Andy


 ;; WARNING: You SHOULD NOT use clojure.core/read or 
 clojure.core/read-string to
 ;; read data from untrusted sources.  They were designed only for reading 
 Clojure
 ;; code and data from trusted sources (e.g. files that you know you wrote
 ;; yourself, and no one else has permission to modify them).

 ;; Instead, either:

 ;; (a) use another data serialization format such as JSON, XML, etc. and a
 ;; library for reading them that you trust not to have vulnerabilities, or

 ;; (b) if you want a serialization format that can be read safely and 
 looks like
 ;; Clojure data structures, use edn (https://github.com/edn-format/edn), 
 for
 ;; which Clojure 1.5 has functions clojure.edn/read and 
 clojure.edn/read-string
 ;; to read them safely.

 ;; You definitely should not use clojure.core/read or read-string if 
 *read-eval*
 ;; has its default value of true, because an attacker could cause your
 ;; application to execute arbitrary code while it is reading.  Example:

 user= (read-string #=(clojure.java.shell/sh \echo\ \hi\))
 {:exit 0, :out hi\n, :err }

 ;; It is straightforward to modify the example above into more destructive
 ;; ones that remove all of your files, copy them to someone else's 
 computer
 ;; over the Internet, install Trojans, etc.

 ;; Even if you do bind *read-eval* to false first, like so:

 (defn read-string-unsafely [s]
   (binding [*read-eval* false]
 (read-string s)))

 ;; you may hope you are safe reading untrusted data that way, but in 
 Clojure 1.4
 ;; and earlier, an attacker can send data that causes your system to 
 execute
 ;; arbitrary Java constructors.  Most of these are benign, but it only 
 takes one
 ;; to ruin your application's day.  Examples that should scare you:

 ;; This causes a socket to be opened, as long as the JVM
 ;; sandboxing allows it.
 (read-string-unsafely #java.net.Socket[\www.google.com\ 80])

 ;; This causes precious-file.txt to be created if it doesn't
 ;; exist, or if it does exist, its contents will be erased (given
 ;; appropriate JVM sandboxing permissions, and underlying OS file
 ;; permissions).
 (read-string-unsafely #java.io.FileWriter[\precious-file.txt\])

 ;; The particular issue of executing arbitrary Java constructors used in 
 the
 ;; examples above no longer works in Clojure 1.5 when *read-eval* is 
 false.
 ;; Even so, you SHOULD NEVER USE clojure.core/read or 
 clojure.core/read-string
 ;; for reading untrusted data.

 ;; If you understand all of the above, and want to use read or 
 read-string to
 ;; read data from a _trusted_ source, continue on below.

 ;; read wants *in* set to a java.io.PushbackReader.
 ;; with-open sets *in* and closes it after it's done.
 ;; *read-eval* specifies whether to evaluate #=() forms
 ;; when reading.
 (defn read-from-file-with-trusted-contents [filename]
   (with-open
 [r (java.io.PushbackReader.
  (clojure.java.io/reader filename))]
   (binding [*read-eval* false]
 (read r

 user= (spit testfile.txt {:a 1 :b 2 :c 3})
 nil
 user= (read-from-file-with-trusted-contents testfile.txt)
 {:a 1, :b 2, :c 3}

 --
 --
 You received 

Re: fressian

2013-01-25 Thread Brent Millare
Ok, well I bit the bullet and figured out how to add vectors myself.

See the results here:

https://github.com/bmillare/dj.fressian

On Monday, January 21, 2013 6:26:48 PM UTC-5, Brent Millare wrote:

 Has anyone checked out fressian, the binary serialization/deserialization 
 used by datomic?

 https://github.com/Datomic/fressian

 I want to use it for clojure data but I don't think the handler list is 
 complete at the moment. Anyone have more fleshed out handlers, such as 
 vectors? Currently they get normalized to arraylists.


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

2013-01-24 Thread Brent Millare
I regularly develop clojure on emacs on windows.

I wrote up a guide for myself, you can read it and adapt it to your needs.

https://github.com/bmillare/dj/wiki/Emacs-Setup

https://github.com/bmillare/dj/wiki/Installation-Walkthrough

On Thursday, January 24, 2013 12:56:59 PM UTC-5, sampso...@googlemail.com 
wrote:

 Apparently installing a development environment for Clojure on Windows 7 
 is very difficult. What is the best way, that has a chance that it might 
 work?


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




fressian

2013-01-21 Thread Brent Millare
Has anyone checked out fressian, the binary serialization/deserialization 
used by datomic?

https://github.com/Datomic/fressian

I want to use it for clojure data but I don't think the handler list is 
complete at the moment. Anyone have more fleshed out handlers, such as 
vectors? Currently they get normalized to arraylists.

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

2013-01-11 Thread Brent Millare
I noticed in the code in clojurescript, src/clj/cljs/repl/browser.clj, 
`send-static` has the cases for handling files other than .html such as 
css, jpg, .png etc, but the dispatching `(server/dispatch-on ...)` limits 
this and only accepts .js and .html. Any reason for this? Any chance of 
changing this?

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

Re: clojurescript browser repl and static files

2013-01-11 Thread Brent Millare
Hmm I just realized, send-and-close doesn't quite handle the binary data 
case very well atm. I'd probably need to fix that first.

On Friday, January 11, 2013 2:50:31 PM UTC-5, David Nolen wrote:

 No reason beyond not having received a patch for it :)


 On Fri, Jan 11, 2013 at 2:21 PM, Brent Millare 
 brent@gmail.comjavascript:
  wrote:

 I noticed in the code in clojurescript, src/clj/cljs/repl/browser.clj, 
 `send-static` has the cases for handling files other than .html such as 
 css, jpg, .png etc, but the dispatching `(server/dispatch-on ...)` limits 
 this and only accepts .js and .html. Any reason for this? Any chance of 
 changing this? 

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

[ANN] dj.plurality, generic dispatch decomplected

2012-12-23 Thread Brent Millare
Previously discussed 
here 
https://groups.google.com/forum/?fromgroups=#!searchin/clojure/plural/clojure/KC-zfUE1rXk/ifURo1ReSugJ

In that thread, Chris Ford talked about opening up the implementation of 
the dispatch function of multimethods. I've implemented that idea but I go 
further to decomplect the datastructure and resolving algorithm. Also I've 
decomplected state (identity), as plural-fns are immutable values. To 
reduce the number of protocols generated, I'm using metadata to enable 
extensibility (defining additional methods).

Code is found here:
https://github.com/bmillare/dj.plurality

You should notice that the implementation is almost nothing. The core of 
plural-fns is in the specification as the only real helper function I 
provide is update-implementation.

I've provided a basic multimethod implementation without hiearchies 
(perhaps merge work with brandon 
bloom? 
https://github.com/brandonbloom/dispatch-map/tree/master/src/dispatch_map). 
I've also hacked together a naive predicate dispatching system using David 
Nolen's core.match.

I'm interested in feedback.

Simple example:

(require '[dj.plurality :as dp])
(let [x (dp/-simple-multi-fn {java.lang.Long inc}
  type)
  y (dp/update-implementation x
  assoc
  java.lang.Double
  dec)]
 [(x 3)
  (y 3.0)
  (y 1)])
= [4 2.0 2]

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

2012-12-10 Thread Brent Millare
This thread may be some help
https://groups.google.com/forum/?fromgroups=#!searchin/clojure/brent/clojure/DmnPwrVvfW8/qgnp6MTVWusJ



On Sunday, December 9, 2012 11:53:16 AM UTC-5, Asim Jalis wrote:

 Hi,

 I am trying to follow the Quick Start steps to get a ClojureScript REPL in 
 a browser. Except when I try this I get errors in the REPL (see REPL 
 ERRORS). I am appending steps I am using (see QUICK START STEPS).

 Any ideas on what might be the problem and how to fix it?

 Thanks!

 Asim


 REPL ERRORS

 user= (repl/repl env) ;; start the REPL
 Type:  :cljs/quit  to quit
 ClojureScript:cljs.user Dec 9, 2012 8:36:53 AM 
 com.google.javascript.jscomp.LoggerErrorManager println
 SEVERE: 
 file:/Users/asimjalis/Proj/008-clojurescript/clojurescript/lib/goog.jar!/goog/net/xpc/crosspagechannel.js:26:
  
 ERROR - required goog.async.Deferred namespace never provided
 goog.require('goog.async.Deferred');
 ^

 Dec 9, 2012 8:36:53 AM com.google.javascript.jscomp.LoggerErrorManager 
 println
 SEVERE: 
 file:/Users/asimjalis/Proj/008-clojurescript/clojurescript/lib/goog.jar!/goog/net/xpc/nativemessagingtransport.js:26:
  
 ERROR - required goog.async.Deferred namespace never provided
 goog.require('goog.async.Deferred');
 ^

 Dec 9, 2012 8:36:53 AM com.google.javascript.jscomp.LoggerErrorManager 
 printSummary
 WARNING: 2 error(s), 0 warning(s)
 ERROR: JSC_MISSING_PROVIDE_ERROR. required goog.async.Deferred namespace 
 never provided at 
 file:/Users/asimjalis/Proj/008-clojurescript/clojurescript/lib/goog.jar!/goog/net/xpc/crosspagechannel.js
  
 line 26 : 0
 ERROR: JSC_MISSING_PROVIDE_ERROR. required goog.async.Deferred namespace 
 never provided at 
 file:/Users/asimjalis/Proj/008-clojurescript/clojurescript/lib/goog.jar!/goog/net/xpc/nativemessagingtransport.js
  
 line 26 : 0

 QUICK START STEPS 

 git clone git://github.com/clojure/clojurescript.git
 cd clojurescript
 ./script/bootstrap
 export CLOJURESCRIPT_HOME=$PWD

 cat  CLJS_END  foo.cljs
 (ns foo
   (:require [clojure.browser.repl :as repl]))
 (repl/connect http://localhost:9000/repl;)
 CLJS_END

 ./bin/cljsc foo.cljs  foo.js

 cat  HTML_END  index.html
 html
   head
 meta charset=UTF-8
 titleBrowser-connected REPL/title
   /head
   body
 div id=content
   script type=text/javascript src=out/goog/base.js/script
   script type=text/javascript src=foo.js/script
   script type=text/javascript
 goog.require('foo');
   /script
 /div
   /body
 /html
 HTML_END

 cat  REPL_PASTE_END;
 ;; Start REPL below and paste this into it
 (require '[cljs.repl :as repl])
 (require '[cljs.repl.browser :as browser])  ;; require the browser 
 implementation of IJavaScriptEnv
 (def env (browser/repl-env)) ;; create a new environment
 (repl/repl env) ;; start the REPL
 REPL_PASTE_END

 ./script/repl


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

2012-12-09 Thread Brent Millare
Can you elaborate on the zebra puzzle? What particular aspect is required? 
What would need to be implemented to get it to work on datomic?

On Sunday, December 9, 2012 5:48:55 AM UTC-5, Nick Zbinden wrote:

 You have a misunderstanding.

 core.logic and datomic datalog are not the same thing.

 core.logic is a turing complet logic engine, datomic datalog is only a 
 querying subpart of this. You can not solve the zebra problem with datomic 
 datalog, its impossible.

 Think of datomic datalog as if it would be something like SQL, while 
 core.logic is something like the prolog programming language.

 Am Sonntag, 9. Dezember 2012 07:42:16 UTC+1 schrieb Brent Millare:

 I understand both core.logic and datomic offer a query system. While 
 there are clear interface differences, and the systems are continuing to 
 evolve so the answer will change over time, however, I don't have a good 
 first order approximation understanding of the capabilities or performance 
 differences between the two. Can anyone give a good explanation? As an 
 example, how is the approach to solving the zebra problem different with 
 each system? What's the difference between functional constraints in 
 datomic and constraint programming in core.logic?



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

2012-12-09 Thread Brent Millare
You are right. I am referring to the querying function, not datomic on the 
whole. 

I have my own understanding about the differences but I was interested in 
hearing others. Please don't feel pressured to answer my question. I'm 
trying to compile understanding akin to stackoverflow, where as long as the 
question hasn't been asked before, then its worth posting. I'm not assuming 
answering this question satisfactorily won't take some effort. I hope my 
casual prose hasn't discouraged others from providing their input.

On Sunday, December 9, 2012 3:11:08 PM UTC-5, Nick Zbinden wrote:

 First of all, stop saying 'on datomic'. Datomic as a Database, witch in 
 its Peer library has a implmentation of Datalog. This implmentation of 
 Datalog has basicly nothing to do with the rest of datomic, it can be used 
 as a query language for data from all sources, it just comes with the 
 Datomic Peer Library.

 There is no sence in me explaining this. Learn what logic programming 
 (prolog, core.logic) is and how it works, and then you will understand it.


 @David,

That's actually a good explanation of core.logic I haven't really heard 
before, in that its all about solving constraint satisfaction problems, 
which is well defined. So now, my understanding is that querying in datomic 
is really just declarative code to describe a fancy filter function over a 
data set. Whereas solving constraint satisfaction problems are about 
efficiently exploring the combinatorial expansion of the problem to 
determine the solution space.

Mathematically this seems similar though, in that if you could express the 
expansion of cases in the database, then you could perform the query and 
obtain the answer. Something tells me that this is where the key difference 
lies. Since core.logic gradually expands the partial solutions until it 
meets all the constraints, this happens lazily, whereas datomic querying 
only occurs on existing values. Does this sound right? In addition, 
core.logic provides tools for declaring how this expansion occurs.

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

core.logic vs datomic

2012-12-08 Thread Brent Millare
I understand both core.logic and datomic offer a query system. While there 
are clear interface differences, and the systems are continuing to evolve 
so the answer will change over time, however, I don't have a good first 
order approximation understanding of the capabilities or performance 
differences between the two. Can anyone give a good explanation? As an 
example, how is the approach to solving the zebra problem different with 
each system? What's the difference between functional constraints in 
datomic and constraint programming in core.logic?

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

2012-12-05 Thread Brent Millare
Ah finally, some progress. This is very relieving, I'm not that crazy it 
seems. It's enough for me to fix my cljs tools for now. Thank you.

On Wednesday, December 5, 2012 8:35:26 AM UTC-5, Herwig Hochleitner wrote:

 I can reproduce this.
 When I replace lib/goog.jar with google-closure-library-0.0-2029.jar, 
 however, it works. No idea why (seriously, why?).

 git clone git://github.com/clojure/clojurescript.git
 cd clojurescript
 ./script/bootstrap
 rm lib/goog.jar
 cp 
 ~/.m2/repository/org/clojure/google-closure-library/0.0-2029/google-closure-library-0.0-2029.jar
  
 ./lib
 cp 
 ~/.m2/repository/org/clojure/google-closure-library-third-party/0.0-2029/google-closure-library-third-party-0.0-2029.jar
  
 ./lib
 ./script/repl

 Clojure 1.4.0
 user= (require '[cljs.repl :as repl])
 (require '[cljs.repl.browser :as browser])
 (def env (browser/repl-env)) 
 (repl/repl env) 



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

2012-12-04 Thread Brent Millare
After adding third_party jar as a dependency to classpath (by 
copying google-closure-library-third-party-0.0-2029.jar to 
clojurescript/lib, as it should automatically be picked up by the 
./script/repl script) I still get the clojure is not defined error. The 
other error doesn't appear.

I also tried manually copying the contents of the third_party lib jar into 
the goog.jar with the same result.

On Tuesday, December 4, 2012 3:41:04 AM UTC-5, David Nolen wrote:

 I believe this error is because you're not including the google closure 
 third party jar as a dependency.

 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 browser repl possible regression

2012-12-04 Thread Brent Millare
Strange, so 'rm .repl /out/ -r' is important but only so I see the 
goog.async.Deferred error consistently now.

Starting from scratch:

git clone git://github.com/clojure/clojurescript.git
cd clojurescript
./script/bootstrap
cp 
~/.m2/repository/org/clojure/google-closure-library-third-party/0.0-2029/google-closure-library-third-party-0.0-2029.jar
 
./lib
./script/repl

Clojure 1.4.0
user= (require '[cljs.repl :as repl])
(require '[cljs.repl.browser :as browser])  ;; require the browser 
implementatio  n of IJavaScriptEnv
(def env (browser/repl-env)) ;; create a new environment
(repl/repl env) ;; start the REPL
nil
user= nil
user= #'user/env
user= Type:  :cljs/quit  to quit
ClojureScript:cljs.user Dec 05, 2012 12:47:37 AM 
com.google.javascript.jscomp.L  oggerErrorManager println
SEVERE: 
file:/home/hara/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog/net/   
   xpc/crosspagechannel.js:26: ERROR - required goog.async.Deferred 
namespace nev  er provided
goog.require('goog.async.Deferred');
^

Dec 05, 2012 12:47:37 AM com.google.javascript.jscomp.LoggerErrorManager 
println
SEVERE: 
file:/home/hara/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog/net/   
   xpc/nativemessagingtransport.js:26: ERROR - required 
goog.async.Deferred names  pace never provided
goog.require('goog.async.Deferred');
^

Dec 05, 2012 12:47:37 AM com.google.javascript.jscomp.LoggerErrorManager 
printSu  mmary
WARNING: 2 error(s), 0 warning(s)
ERROR: JSC_MISSING_PROVIDE_ERROR. required goog.async.Deferred namespace 
never   provided at 
file:/home/hara/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog 
 /net/xpc/crosspagechannel.js line 26 : 0
ERROR: JSC_MISSING_PROVIDE_ERROR. required goog.async.Deferred namespace 
never   provided at 
file:/home/hara/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog 
 /net/xpc/nativemessagingtransport.js line 26 : 0


On Tuesday, December 4, 2012 3:41:15 PM UTC-5, Herwig Hochleitner wrote:

 I managed to get your example to work by copying the third-party jar into 
 lib/
 One thing I ran into: Do a `rm .repl/ out/ -r` between runs, especially 
 when compiles have failed.


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

2012-12-03 Thread Brent Millare
Using clojurescript 3842d3f9e0d68853077117a919e93e169079

Trying to do the simplest case of a clojurescript browser repl:

running clojurescript/script/repl, then

Taken straight from the documentation:

(require '[cljs.repl :as repl])(require '[cljs.repl.browser :as browser])  ;; 
require the browser implementation of IJavaScriptEnv(def env 
(browser/repl-env)) ;; create a new environment(repl/repl env) ;; start the REPL

Next after trying to connect with browser at url http://localhost:9000/repl 
I get an error from google chrome's console.

Uncaught ReferenceError: clojure is not defined

htmlheadmeta charset=UTF-8/headbody
script type=text/javascript/scriptscript type=text/javascript
clojure.browser.repl.client.start(http://localhost:9000;);
Uncaught ReferenceError: clojure is not defined
/script/body/html

Note that the rhino repl works fine.

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

2012-12-03 Thread Brent Millare
I've already tried both ways. Creating the html file with the script tag 
with the simple code you showed, and just simply trying to connect directly 
with http://localhost:9000/repl. In both cases, the same error message 
shows. Note that the error message isn't from my source code, but rather 
from the source code returned by http://localhost:9000/repl

On Monday, December 3, 2012 2:27:29 PM UTC-5, Herwig Hochleitner wrote:

 The browser repl works by creating a clojurescript file like:

 (ns foo (:require [clojure.browser.repl :as repl]))

 (repl/connect http://localhost:9000/repl;)

 then compiling it (not in advanced mode) and using the output in a script 
 tag.


 2012/12/3 Brent Millare brent@gmail.com javascript:

 Using clojurescript 3842d3f9e0d68853077117a919e93e169079

 Trying to do the simplest case of a clojurescript browser repl:

 running clojurescript/script/repl, then

 Taken straight from the documentation:

 (require '[cljs.repl :as repl])(require '[cljs.repl.browser :as browser])  
 ;; require the browser implementation of IJavaScriptEnv(def env 
 (browser/repl-env)) ;; create a new environment(repl/repl env) ;; start the 
 REPL

 Next after trying to connect with browser at url 
 http://localhost:9000/repl I get an error from google chrome's console.

 Uncaught ReferenceError: clojure is not defined

 htmlheadmeta charset=UTF-8/headbody
  script type=text/javascript/scriptscript type=text/javascript
  clojure.browser.repl.client.start(http://localhost:9000;);
  Uncaught ReferenceError: clojure is not defined
 /script/body/html

 Note that the rhino repl works fine.

 -- 
 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: clojurescript browser repl possible regression

2012-12-03 Thread Brent Millare
The file with the clojurescript and call to connect isn't named repl, its 
named view.html. repl is the name of the response from the call (repl/connect 
http://localhost:9000/repl;)

On Monday, December 3, 2012 3:29:13 PM UTC-5, David Nolen wrote:

 Don't call your file repl.* this has special meaning - it's the file 
 that's meant to be loaded into the cross page iframe.




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

2012-12-03 Thread Brent Millare
At the moment, all I am doing is dragging and dropping the html file into 
the browser, which contains the compiled clojurescript (js) which looks 
like this

view.html

... compiled cljs stuff ...
body
scriptfoo.main();/script
/body
...

Where foo.cljs is:
(ns foo (:require [clojure.browser.repl]))
(defn main [] (clojure.browser.repl/connect http://localhost:9000/repl;))

hence, the url is like
file:///home/.../out/view.htmlfile:///home/bmillare/dj/usr/src/dj.view/out/view.html

Again only the error message says repl:3

On Monday, December 3, 2012 4:29:43 PM UTC-5, David Nolen wrote:

 It sounds like you are trying to navigate to http://localhost:9000/replthough 
 right? You should be navigating to 
 http://localhost:9000/





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

2012-12-03 Thread Brent Millare
Still getting the same error regardless.

1. creating index.html (with compiled cljs code and call to connect) and 
putting in clojurescript directory
2. starting up clojurescript clojure repl with ./script/repl
3. Running the clojurescript repl with:
(require '[cljs.repl :as repl])
(require '[cljs.repl.browser :as browser])  ;; require the browser 
implementation of IJavaScriptEnv
(def env (browser/repl-env)) ;; create a new environment
(repl/repl env) ;; start the REPL
4. Point browser to http://localhost:9000;

I get the clojure is not defined error, and clojurescript repl is still 
unresponsive (since connection wasn't completed). The compiling step is 
fine and the clojurescript code before the call to connect works.



On Monday, December 3, 2012 6:22:24 PM UTC-5, David Nolen wrote:

 file:// urls don't work anymore due to changes in the Google Closure 
 Library. You need to point your browser to http://localhost:9000/, by 
 default it looks for index.html.

 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 browser repl possible regression

2012-12-03 Thread Brent Millare
https://github.com/downloads/bmillare/dj.web.browser/minimal.tar.gz

@Mimmo, I don't use cljsbuild as thats mainly for automation that doesn't 
fit my use cases. Instead I am using the github clojurescript docs for this 
reference project. Normally, I use my own build tools.

I created a minimal project, you can just run the steps.sh script (and 
follow the comments) to reproduce the error. I assume you are running this 
on linux.

Also another thing I forgot to mention, after loading the url, the repl 
spits out errors:

ClojureScript:cljs.user Dec 03, 2012 8:50:33 PM 
com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: 
file:/home/bmillare/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog/net/xpc/crosspagechannel.js:26:
 
ERROR - required goog.async.Deferred namespace never provided
goog.require('goog.async.Deferred');
^

Dec 03, 2012 8:50:33 PM com.google.javascript.jscomp.LoggerErrorManager 
println
SEVERE: 
file:/home/bmillare/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog/net/xpc/nativemessagingtransport.js:26:
 
ERROR - required goog.async.Deferred namespace never provided
goog.require('goog.async.Deferred');
^

Dec 03, 2012 8:50:33 PM com.google.javascript.jscomp.LoggerErrorManager 
printSummary
WARNING: 2 error(s), 0 warning(s)
ERROR: JSC_MISSING_PROVIDE_ERROR. required goog.async.Deferred namespace 
never provided at 
file:/home/bmillare/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog/net/xpc/crosspagechannel.js
 
line 26 : 0
ERROR: JSC_MISSING_PROVIDE_ERROR. required goog.async.Deferred namespace 
never provided at 
file:/home/bmillare/dj/usr/src/minimal/clojurescript/lib/goog.jar!/goog/net/xpc/nativemessagingtransport.js
 
line 26 : 0


On Monday, December 3, 2012 7:50:11 PM UTC-5, David Nolen wrote:

 Please create a minimal project that demonstrates the issue for you, then 
 we can try to run that.


 On Tue, Dec 4, 2012 at 12:02 AM, Brent Millare 
 brent@gmail.comjavascript:
  wrote:

 Still getting the same error regardless.

 1. creating index.html (with compiled cljs code and call to connect) and 
 putting in clojurescript directory
 2. starting up clojurescript clojure repl with ./script/repl
 3. Running the clojurescript repl with:
 (require '[cljs.repl :as repl])
 (require '[cljs.repl.browser :as browser])  ;; require the browser 
 implementation of IJavaScriptEnv
 (def env (browser/repl-env)) ;; create a new environment
 (repl/repl env) ;; start the REPL
 4. Point browser to http://localhost:9000;

 I get the clojure is not defined error, and clojurescript repl is still 
 unresponsive (since connection wasn't completed). The compiling step is 
 fine and the clojurescript code before the call to connect works.



 On Monday, December 3, 2012 6:22:24 PM UTC-5, David Nolen wrote:

 file:// urls don't work anymore due to changes in the Google Closure 
 Library. You need to point your browser to http://localhost:9000/, by 
 default it looks for index.html.

 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




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

math expression simplifier, kibit implementation

2012-11-30 Thread Brent Millare
Hey all,

Before I diving in detail into the code, can someone provide me a high 
level explanation of how kibit simplifies code? I understand underneath it 
uses core.logic and rules but its not clear to me how it picks one form 
over the other.

I'm trying to extend this to data that represents mathematical expressions. 
Ideally in the future I'd like to have many types of transformations that 
enable one to shape a mathematical expression in one way or another 
depending on the  user's requirements.

My current work (which requires dj atm since its under heavy development) 
is available here

https://github.com/bmillare/dj.math

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

syntax for defrecord literals and tagged literals

2012-11-17 Thread Brent Millare
The syntax for defrecord literals and tagged literals is very similar.

user (defrecord x [y])
user.x
user #user.x[3]
#user.x{:y 3}
user #user.x [3]
RuntimeException Unreadable constructor form starting with #user.x  
 clojure.lang.Util.runtimeException (Util.java:170)

[3]

Basically the difference is tagged literals have a space between the tag 
and the clojure data.

What are the reasons for this difference? Is there an advantage? To me it 
seems too similar that it could be a source of bugs in code.

My pro/con breakdown:
Pro
-Separate namespace, we can have tags that have the same name as a 
classname.
Cons
-Source of compile time bugs when only one is defined. Source of runtime 
bugs if both the tag and class exist.
-more work for parsers

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

files, filenames and datomic

2012-10-15 Thread Brent Millare
After seeing the release of codeq, it got me thinking about making my own 
database app for analyzing other types of text files, images, pdfs etc.

There are a few issues though with regards to dealing with the files. 
Currently, I think its best to just store a reference to the file in the 
datomic db, and have the actual files on some computer. The problem is 
files have a naming problem. Often files will have the same name even 
though the content is different. Also its possible that the file already 
exists on the filesystem and we want to not have duplicates. Also we would 
like to retain usage of standard file management tools like scp, sftp, 
nautilus, finder... etc.

What are some good solutions to dealing with these issues?

Currently, these are my thoughts:

Solution 1: Give each file an incrementing id per file and use it as the 
filename. In the database store the sha and filename.

Problems: Listing the directory can be very large since all the files are 
in one directory. Adding a file will have to perform a lookup to figure out 
what is a free id, although in practice this probably isn't an issue since 
i/o will probably be the main bottleneck.

Solution 2: Compute the SHA of the file. For the first 4 digits, create 
directories, then create directories of the remaining digits, then store 
the file as is with the original filename in the directory.

Problems: More complex. The SHA must be computed.

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

2012-10-14 Thread Brent Millare
https://github.com/bmillare/dj

I've updated the motivation section. Now its a little bit more clear what 
dj is trying to accomplish, to increase the dynamism and integration of our 
runtime, especially with regards to managing our projects. With tools like 
https://github.com/clojure/tools.namespace , the goal of not having to 
close our REPLs is becoming more feasible. dj tries to align with that 
philosophy.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 clojure-doc.org (aka CDS), a new community-driven Clojure documentation site

2012-10-09 Thread Brent Millare
As a start for my contributions, I want to open up some topics for 
discussion.


1. Front Page Design

Currently, it looks like the front page has a bunch of miniature slides. Do 
we want the front page to mainly be the focus of advertisement and have 
a separate navigation system (aka see all contents)? Or do we want 
navigation to be the front page. In this case, we'll need to create some 
sort of high level tree structure.

2. The advertisement page to me, has two purposes:
  I. Provide motivation for the CDS
  II. Provide motivation for using clojure itself

These are separate but important concerns. How should we prioritize these?

We can also talk about adding visuals like abstract pictures that go along 
with the content.

3. Styling Design

I noticed the site changes the style depending on the width, which is a 
cool feature. But I don't like the line breaking behavior of the medium 
width. I feel it might look visually better if the font size was reduced to 
preserve the lines.

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

2012-10-04 Thread Brent Millare
If/when it comes out, it sounds like it will be most easily accessible via 
OpenCL. The architecture sounds similar to cell, have a standard processor 
the OS runs on, then run super computing jobs on all the worker processors.

I'd say the best bet we have to getting clojure in those environments is 
working with the analyzer and compiler developments that were made with 
clojurescript. Then you can emit native code or something a little bit more 
portable. Otherwise, its just basically going to be wrappers over openCL. I 
don't see a future in running jvms on each processor unless the jvm gets 
some builtin support for running threads on the worker processors.

One easy to envision future would be using the reducers library 
abstractions, you could offload this work onto those worker processors.

On Monday, October 1, 2012 8:23:08 AM UTC-4, René Groß wrote:

 Hi,

 Anyone heard of the project 
 Parallellahttp://www.kickstarter.com/projects/adapteva/parallella-a-supercomputer-for-everyone
  
 yet?

 What do you think about it?
 Will it be of any interest for the clojure plattform?


 Kind regards,

 René


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

2012-10-04 Thread Brent Millare
I wouldn't completely discount them yet. First, while absolute performance 
is probably less than i7 in most benchmarks, their main performance metric 
is GFLOPS/watt, not just pure GFLOPS. When you start to include the 
overhead of managing a large system, which includes UPS, heat, and power 
draw, the concept seems more cost competitive. Also, this has applications 
for consumer applications with more compute intensive algorithms, you 
couldn't put an i7 on a phone. Second, not all parallelism tasks run most 
efficiently on GPUs. GPUs get incredible performance but assume very 
predictable memory access patterns. One big limitation of GPUs (at least 
with nvidia) is you can't easily share data between streaming 
multiprocessors (SM) in a coordinated manner (you can within each SM 
though) without going to device memory. Also, the coordination primitives 
for device memory reduce performance dramatically. If you start adding more 
hardware support for more general memory access patterns, the performance 
should improve.

There's a little bit more details of the hardware architecture here:
http://www.adapteva.com/products/silicon-devices/e64g401/

Seems pretty reasonable. Nothing out of the ordinary, they just made 
different decisions on what to prioritize. Just skimming, it looks like you 
should be able to get lower latency between shared data across compute 
nodes when compared to CUDA's architecture.

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

2012-10-04 Thread Brent Millare
lol, That is really awesome!

I'm going to have to really read through the sources now.

On Thursday, October 4, 2012 3:28:41 PM UTC-4, Fogus wrote:

  Here's one approach: Make a github of the code and content that runs the 
 site. People fork and make pull requests. 

 You talked me into it. 

 https://github.com/fogus/www-readevalprintlove-org 


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

Re: Regarding Starting Clojure

2012-10-03 Thread Brent Millare
What's the best way to allow collaborative contribution on content that 
must be agreed upon?

Here's one approach: Make a github of the code and content that runs the 
site. People fork and make pull requests.

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

2012-10-02 Thread Brent Millare
(My library dj relies on other stuff in leiningen-core dependency but 
you're right, for this example, I was lazy and didn't simplify the breaking 
case)

Hmm well my library dj kinda relies on the whole dynamic features of 
pomegranate. Any pointers to literature on those alternative routes?



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

2012-10-01 Thread Brent Millare
Sounds like the main beef is with the official website's styling and 
layout. I agree its not necessarily the prettiest but all the information 
is there. On the other hand, there are plenty of great resources that 
provide a great getting started experience in my opinion. Just typing 
clojure in google I see tryclojure, which provides a interactive guide with 
a simple click. Then next, the clojure wiki, which has a lot of free 
content as well as places to go. Next is the JoyOfClojure book, which is 
*the* book I'd recommend to any beginning clojure user. Also there is 
learn-clojure.com which looks nice and seems to address a lot of those 
getting started points.

Personally, the styling/layout wasn't an issue for me. I found there to be 
a lot of good resources out there, but I couldn't just point to one.

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

error when using pomegranate to load datomic and cemerick.piggieback

2012-09-30 Thread Brent Millare
Using the project file
(defproject test 1.0
  :dependencies [#_ [com.datomic/datomic-free 0.8.3538]
 [leiningen-core 2.0.0-preview10]
 [com.cemerick/piggieback 0.0.2]])
  
Then doing a lein2 repl
and running the following commands in order
user= (require '[cemerick.pomegranate])
nil
user= (cemerick.pomegranate/add-dependencies :coordinates 
'[[com.datomic/datomic-free 0.8.3538]])
...lots of output...
user= (require '[datomic.api])
NoSuchMethodError 
com.google.common.cache.CacheBuilder.maximumSize(J)Lcom/google
/common/cache/CacheBuilder;  datomic.cache/create-computing (cache.clj:129)

If I use lein2 normally with datomic in the project.clj file, everything 
works as normal. Is there something going on differently that prevents this 
from working when adding dependencies dynamically?

(Note I need to have piggieback in there to create the error).

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

dj - installation walkthrough

2012-09-29 Thread Brent Millare
I added a tutorial to install dj and clojure.

https://github.com/bmillare/dj/wiki/Installation-Walkthrough

It should provide another reasonable default way to install clojure.

See project details here: https://github.com/bmillare/dj
dj takes the cacaphony of java, git, clojure, clojurescript and build 
tools and mixes it into something harmonious.

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

Issues with round tripping and tagged literals

2012-09-27 Thread Brent Millare
When one needs to get clojure data passed around over some string carrying 
pipe, one would need to override the print-dup/print-method methods for 
non-roundtrippable objects like java.io.File. This modifies the public and 
functionally global namespace, which is not good practice. A recommended 
approach would be to define one's own print function like so

http://stackoverflow.com/questions/10005102/how-to-override-println-behavior-for-reference-types/10013247#10013247

However, this approach is leaky. Though in some other objects and it fails 
again. One might then provide default methods or Object methods that 
delegate back to print-method. This, however, doesn't work for collections 
since collections delegate only to clojure.core print methods and if you 
see a File in there, it won't use your methods. Therefore, coming back, the 
only way to make a truly non global modifying but complete printer, one 
would need to basically write their own version of 
clojure/src/clj/clojure/core_print.clj. A much larger task.

A couple of observations here:

1. It seems useful to be able to copy an existing multimethod (and its 
implementations) into another namespaced multimethod. Then one should be 
able to make incremental changes. This is analogous to copying someone's 
hashmap, and then using clojure.core/update-in to modify it for your use. 
The other person's hashmap is unmodified.

2. When reading in the strings that contain forms, we rely on the 
*data-readers* hashmap, which is a map from symbols to fns. One limitation 
with this approach is we can't match patterns, only concrete symbols. So 
phrased differently, currently it's not possible to call a fn on anything 
of the pattern #my.personal.namespace/whatever else fits here clojure 
data literals, I realize that we need to be careful of what the reader can 
do in terms of parsing, but I feel it needs to be more flexible. An 
alternative approach would be to have the reader pass the valid symbol to a 
rebindable dispatch function. This may be too powerful, however, since 
parsing classnames and reserved tags wouldn't compose well in this 
situation. To perhaps strike a balance, one compromise would be to do this 
only for full qualified symbols. This way different people's tags and their 
implementations don't step on each other.

Yet another solution (which I am starting to like more as a write and is 
really more a convention then an implementation), would be to treat the 
tags conceptually not as a symbol, but as a namespace reference. Then one 
could print additional data (in the data literal part) that one could then 
dispatch off of. This has the advantage of not requiring modifications to 
the current implementation of tagged literals. I haven't seen many examples 
of tagged literals on the mailing list, but this requires some agreement 
about how we name our tags so that we don't step on each other.

So instead of

#my.namespace/someobject [blah blah]

we have

#my.namespace [:someobject blah blah]

Thoughts?

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

2012-09-18 Thread Brent Millare
Shantanu,

Quiddity does not fulfill my requirements since I need to control the 
environment from interop such as load-file and interop.

On Tuesday, September 18, 2012 12:03:27 AM UTC-4, Shantanu Kumar wrote:



 On Sep 18, 8:27 am, Brent Millare brent.mill...@gmail.com wrote: 
  I forgot to mention an additional condition, this should work with the 
 browser as an eval environment 

 Quiddity (URL below) may not load an entire file, but you can eval an 
 S-expression by supplying all values: 

 https://github.com/kumarshantanu/quiddity 

 Shantanu 


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

2012-09-18 Thread Brent Millare
Hi Frank,

That is pretty much exactly as I wanted. The only problem is that you are 
calling a private fn and therefore the code is susceptible to change. I 
think this should be looked into more and become officially supported. This 
is a great hook that opens up the door to a more interactive development 
experience for clojurescript.

On Tuesday, September 18, 2012 2:00:08 AM UTC-4, FrankS wrote:

 I have the same requirement to have a clojurescript-form in my 
 clojure-environment that I want to evaluate in the browser… 

 To make the following code-snippet work, you're supposed to have a 
 browser-repl session running, and start a new repl-session on that same JVM 
 from where you invoke the following forms to execute either javascript-code 
 or clojurescript-forms in the browser. 

 --- 
 user= (require 'cljs.repl) 
 nil 

 user= (require 'cljs.repl.browser) 
 nil 

 user= (cljs.repl.browser/browser-eval alert('No Way!')) 
 {:status :success, :value } 

 user= (def my-repl-env {:port 9000, :optimizations :simple, :working-dir 
 .lein-cljsbuild-repl, :serve-static true, :static-dir [. out/], 
 :preloaded-libs []}) 
 #'user/my-repl-env 

 user= (def my-env {:context :statement :locals {}}) 
 #'user/my-env 

 user= (#'cljs.repl/eval-and-print my-repl-env my-env '(js/alert Yes 
 Way!)) 
 nil 
 nil 

 user= 
 --- 

 The public function cljs.repl.browser/browser-eval seems to allow you to 
 send javascript code as a string to the browser to execute over the 
 existing browser-repl connection. 

 The private function cljs.repl/eval-and-print will take a clojurescript 
 form, compile it to javascript and send it to the browser for execution. 
 The my-repl-env and my-env values are artifacts needed that are 
 normally only available within the context of the function. 

 My apology for this hugeugly hack… please see it as a proof of principle. 

 There may be much more elegant solutions available… I've only scratch the 
 surface of understanding how this clojurescript repl works in detail. 

 -Enjoy, FrankS 


 On Sep 17, 2012, at 9:03 PM, Brent Millare brent@gmail.comjavascript: 
 wrote: 

  And yes by eval I mean compile and run on the target (browser) 
  
  -- 
  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: Calling Clojurescript code from Clojure

2012-09-18 Thread Brent Millare
Actually, after looking through the source myself, I noticed eval-and-print 
just calls evaluate-form, which is better since its public. I can take care 
of printing myself so this is probably 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: Calling Clojurescript code from Clojure

2012-09-17 Thread Brent Millare
I forgot to mention an additional condition, this should work with the browser 
as an eval environment 

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

2012-09-17 Thread Brent Millare
And yes by eval I mean compile and run on the target (browser)

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


Calling Clojurescript code from Clojure

2012-09-16 Thread Brent Millare
Background: I'm developing a web based development environment.

Problem: Is there a way to evaluate clojurescript code from clojure? I need 
to call clojurescript code like (load-file foo.cljs) from clojure. Note 
this is different then starting a clojurescript repl and typing in 
(load-file foo.cljs). I'm already doing this. It needs to be more like 
(eval-cljs cljs-foo-form). How does one do this?

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

Re: ClojureScript and development workflow

2012-09-11 Thread Brent Millare
I emit the clojurescript code myself by calling cljs.closure/build myself 
and put this into the html file. I cache the code using 
clojure.core.memoize/memo-fifo with my own function that takes the 
dependent files timestamps as args (so that changes result in recompiles). 
Using ring, pages with refreshes automatically update if the source is 
updated.

I also use cemerick.piggieback for the liverepl between refreshes.

See dj.cljs/cljs-repl as part of 'dj', the library I wrote to manage some 
of these things.

https://github.com/bmillare/dj/blob/library/src/dj/cljs.clj

Note that it is sufficient to just use the inserted js code emitted from 
cljs.closure/build from a cljs file with (clojure.browser.repl/connect 
http://localhost:port/repl) and dj.cljs/cljs-repl to get a liverepl. 
You do not need any other files in the html file. (The example 
https://github.com/clojure/clojurescript/wiki/The-REPL-and-Evaluation-Environments
 can 
be misleading since it includes the out/goog/base.js and other statements.

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

2012-09-11 Thread Brent Millare
Actually since you are using def, I believe your method registrations are 
global. You should be using binding with dynamic vars to get thread locals. 
Also with mine, since I have the user specify the pluralfn symbol and since 
it can be called in another namespace, the namespace of the pluralfn is 
preserved. You can define multiple pluralfn's with the same name but in 
different namespaces. I don't think you can do that with your 
implementation. All this harping from me is really nothing though. Just 
details. Your approach well describes the point you are trying to make with 
little code. (Although you can remove the anonymous fn call in the 
update-in line, update-in accepts fns and the args it will pass to it :-P ).

Back to details though, I think that we still specify too much. For 
example, I think to make this more flexible and performant, we must not 
specify the data structure we choose to use. A vector may not provide the 
best data structure for fast lookup as we would like in a multimethod 
imitator. Also, when we reload a namespace, do we clobber all 
implementations? or save them? 

Probably some sort of protocol would be best, but I don't know what that 
approach should look like.

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

2012-09-06 Thread Brent Millare
I've made my own take of your plural dispatch system.

https://gist.github.com/3659663

I switched from using vars and a map for determining which pluralfn to use, 
to atoms and metadata tied to the pluralfn. My method reduces the amount of 
indirection and invocations. I originally tried to make a deftype version 
to store the data, but then I'd have to reimplement all of the microsyntax 
of of clojure.core/fn and expand out the args to all the arities, not fun.

Also I created defplural-body which doesn't specify the argument arity 
which you can use to avoid sequencing/unsequencing arguments for 
performance. I defined defplural in terms of defplural-body, which 
maintains compatibility with your examples.

My code has the advantage over some implementation details in multimethods 
in that redefining the pluralfn does not cause you to forget all the 
implementations since defplural-body checks for existing implementations. 
This, however, will require the user to run clear-implementations! if one 
does want to forget all the implementations.

On Wednesday, September 5, 2012 6:48:36 AM UTC-4, Chris Ford wrote:

 I was watching David Nolan's talk about predicate 
 dispatchhttp://blip.tv/clojure/david-nolen-predicate-dispatch-5953889, 
 and he articulated something that I've found frustrating about multimethods 
 - the set of implementations is open, but the dispatch function is closed. 
 That means that if your dispatch value can't be computed in the same way 
 for all your data, you can't use multimethods.

 Predicate dispatch allows implementations to be registered with a test 
 that decides whether or not they are applicable, so it can do things that 
 multimethods cannot. For example, predicate dispatch would allow you to 
 write an open function that categorises integers as prime, perfect or 
 some other category without baking them all into the dispatch function.

 In his talk, David speaks about the problem of overlap. 2 is both prime 
 and even, for example. That got me thinking whether overlap is a bug or a 
 feature.

 I've hacked together a simple plural dispatch 
 systemhttps://gist.github.com/3634871, 
 which allows the specification of a custom resolution function that can 
 decide whether to use one or all of the registered implementations. You can 
 use this system to implement both multimethods and predicate dispatch.

 What practical reason would you have for doing this? Random dispatch! 
 Can't decide which implementation to use? Now you don't have to!

 (defplural random (fn [implementations args] (- implementations rand-nth 
 (apply args
 (defimplementation random #(+ % 100))
 (defimplementation random #(- % 100))
 (random 1)

 It could also be useful for gathering a set of all possible results, 
 quasi-AOP extension points, broadcasting events etc.

 Cheers,

 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: nREPL 0.2.0-beta9 released

2012-08-22 Thread Brent Millare
First, great work on nrepl! It's a great tool.

Second, I noticed you recently updated leiningen repl to include beta9. I 
was having problems trying to get piggieback to work with the older 
leiningen which depended on beta6. I was trying to customize profiles so 
that I could depend on beta9 but I couldn't find the config to work.

I tried:
~/.lein/profile.clj
{:repl {:dependencies [[blahblah beta9]]}}

and foo/project.clj
{:repl {:dependencies [[blahblah beta9]]}} 

Neither worked. What's the right way to do that?

(Note I got it to work with the updated master branch of leiningen, but I'm 
just trying to know this in the future in case I encounter a similar 
problem).

On Wednesday, August 22, 2012 1:51:33 PM UTC-4, Chas Emerick wrote:

 I have recently released [org.clojure/tools.nrepl 0.2.0-beta9].  No 
 incompatibilities are known between this release and prior betas. 

 Much of this release was focused on simplifying: 

 (a) The use of third-party middlewares; constructing an nREPL handler had 
 become far too difficult from a user perspective, insofar as middlewares 
 often must be stacked in a particular position relative to other 
 middlewares 

 (b) nREPL client responsiveness; there was previously no way for clients 
 to know what operations were supported by an nREPL endpoint, thus forcing a 
 least common denominator approach (i.e. do everything via `eval`) 

 These factors should make life much easier for both users and developers 
 of nREPL middlewares. 

 Unrelated to this release, I'd like to point out that nREPL has previously 
 grown the flexibility to work around the thread stack size limitations 
 frequent on Android devices, so such usage should be reasonably 
 straightforward at this point (see 
 http://dev.clojure.org/jira/browse/NREPL-8).  Feedback on any further 
 Android issues are most welcome. 

 Looking forward, very little stands between us and a final 0.2.0 release. 
  Please file your issues with the appropriate haste. ;-) 

 Finally, here's a summary of the changes in 0.2.0-beta9: 

 * New standard `describe` op, returns a machine- and human-readable 
 directory of all ops supported by an nREPL endpoint's middleware stack 
 (a.k.a. nREPL feature detection) 

 * New standard `load-file` op for loading the contents of a source file 
 with debugging information (source path, etc) (Particularly important for 
 Clojure/ClojureScript REPL uniformity) 

 * Added support for automagically arranging middlewares into a 
 properly-ordered stack based on their runtime dependencies (
 http://dev.clojure.org/jira/browse/NREPL-26) 

 * The response message to requests that contain an unknown op now include 
 a done status in addition to the prior error and unknown-op statuses 

 * Encoding and decoding of bencode bytestrings to Strings via UTF-8 has 
 been pushed up into the default bencode Transport implementation to support 
 sending binary values in messages efficiently (watch 
 http://dev.clojure.org/jira/browse/NREPL-28 for further developments 
 there). 

 * `eval` messages specifying a nonexistent namespace via :ns will provoke 
 a response with statuses of #{error namespace-not-found done} instead 
 of silently failing (http://dev.clojure.org/jira/browse/NREPL-23) 

 Cheers, 

 - Chas 

 -- 
 http://cemerick.com 
 [Clojure Programming from O'Reilly](http://www.clojurebook.com) 



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

Re: nREPL 0.2.0-beta9 released

2012-08-22 Thread Brent Millare
Good to know I wasn't going crazy trying to find the right profile setup.

On another note (and slightly OT), taking the return value of 
cljs.closure/build of the cljs file with the call to repl/connect and 
inserting the outputed js into the index.html appears to be sufficient from 
the clojurescript side to make a browser repl.

I'm happy that it is now both simple and easy to create a nrepl session 
tied to a cljs repl.

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

2012-08-14 Thread Brent Millare
Well just using leiningen2 and then lein repl, and then

user= (require 'clojure.core.logic)
FileNotFoundException Could not locate clojure/core/logic__init.class or 
clojure/core/logic.clj on classpath:   clojure.lang.RT.load (RT.java:432)

If I change it, then it works.


On Tuesday, August 14, 2012 12:32:26 AM UTC-4, David Nolen wrote:

 On Mon, Aug 13, 2012 at 4:38 PM, Brent Millare 
 brent@gmail.comjavascript: 
 wrote: 
  I think the :source-path line in project.clj should be :source-paths 
  [src/main/clojure]. Is :source-path still looked up in leiningen2? 

 Is there something specific you are trying to do? 

 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: clojure.logic project.clj file

2012-08-14 Thread Brent Millare
Well just looking at the source, :source-path is never looked up, only 
:source-paths. All project.clj files that are prepped for leiningen2 use 
:source-paths to my knowledge.

On Tuesday, August 14, 2012 10:20:50 PM UTC-4, David Nolen wrote:

 On Tue, Aug 14, 2012 at 10:09 PM, Brent Millare 
 brent@gmail.comjavascript: 
 wrote: 
  Well just using leiningen2 and then lein repl, and then 
  
  user= (require 'clojure.core.logic) 
  FileNotFoundException Could not locate clojure/core/logic__init.class or 
  clojure/core/logic.clj on classpath:   clojure.lang.RT.load 
 (RT.java:432) 
  
  If I change it, then it works. 

 This is a question for the Lein folks. I only use the project.clj for 
 interactive development. Perhaps they can chime in? 

 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

clojure.logic project.clj file

2012-08-13 Thread Brent Millare
I think the :source-path line in project.clj should be :source-paths 
[src/main/clojure]. Is :source-path still looked up in leiningen2?

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

Building primitives for a clojurescript editor

2012-08-07 Thread Brent Millare
As a step to respond to the push to develop sophisticated web applications, 
Rich Hickey created Clojurescript. Currently, much of the core of web 
development comes from jquery and does not fit well with the google closure 
model. Having tools written in Clojure/Clojurescript would be more ideal by 
improving extensibility and the ability to be interfaced by users.

Coming from the philosophy of increasing productivity by minimizing the 
delay from feedback from the changes we make to our designs, I am 
interested in developing a clojurescript based editor. As hinted earlier, 
there is a lack of primitives for web based editors that are google closure 
friendly. I thus present a simple example of an editor along with the 
primitives used to make it. The goal is to build a library of editor 
primitives so people can customize editors for their applications. For 
example, I would like this work to eventually be incorporated into Light 
Table.

See the github project:

git://github.com/bmillare/dj.web.browser.git

Current work:
-basic utilities for asynchronous io
-key to function map
-basic dom helpers
-example throw away editor

Future work:
-parsers
-interface with a version of clojure's reader that doesn't just convert a 
string into data but also provides more analysis information for comments 
and reader macros (doesn't exist yet)
-more advanced data structure viewers, where functions operate on clojure 
data, and not just a string, this removes having to reparse data, even 
though there are things like cgrande's parsley
-incorporation of cljs analyzers

I would appreciate a discussion of the topic.

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

2012-05-25 Thread Brent Millare
Ok well installing is easy

java -jar jython_installer-2.5.2.jar

# to get python repl
java -jar jython

# to run script
java -jar jython ./python.py

I haven't looked into calling python functions (running in jython) from 
clojure though because unfortunately, I wasn't able to get jython to work 
with sympy, which is what I wanted clojure to interact with to do symbolic 
math do to a bug in jython, so this is already a dead end for me.

I guess its down to calling python as a script from within clojure, not 
ideal, but I guess it'll work for now.

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

2012-05-25 Thread Brent Millare
Until C-in-C works for all the features in Clojure (as long as it makes 
sense), clojure-py will have to wait since vanilla clojure already provides 
that.

0MQ seems interesting. The big advantage I see to this approach is it takes 
care of marking when a send is completed while the program is still 
running, so I don't have to re-incur the startup and shutdown overhead. 
importing sympy takes a lot of time so this might be worthwhile
 

 Since you can't bring the python to the JVM you could try bringing the 
 clojure to python with clojure-py[1] :).  Clojure-py is pretty new though 
 so depending on the nature of your project it may not be a great fit.  
 Another option for inter-process communication would be to use zeromq since 
 both python and clojure bindings exist.  This would at least be a better 
 solution than shelling out to python everything time you needed to use the 
 library.

 -Ben


 1. https://github.com/halgari/clojure-py
  

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

2012-05-25 Thread Brent Millare
I originally assumed core.logic would be the key to symbolic math, but now 
I feel that's not really the case. You still need to implement all the 
algebra manipulation algorithms as usual. One can define the numbers in a 
different way as Ambrose did in his talk, but I imagine we would need to 
have much different performance expectations when performing the other 
symbolic operations. That being said, I would like to see more work going 
into that type of implementation.

On Thursday, May 24, 2012 8:37:57 PM UTC-4, Zack Maril wrote:

 Off topic:
 How hard would it be to build on 
 core.logichttps://github.com/clojure/core.logic#corelogicto do math 
 functions? 
 -Zack



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