Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2016-03-19 Thread Dave Ray
Inline below..

Dave

On Thu, Mar 17, 2016 at 9:37 AM, Jason Zwolak <jzwo...@gmail.com> wrote:

> Paul, yeap, Seesaw is definitely something worth considering. Dave Ray
> hasn't abandoned the project, but I sent a personal email to him asking
> about the state of the project and it does seem the Seesaw is in more of a
> maintenance phase than a continue to move forward and improve phase. Dave
> Ray, if you're on this list, would you chime in?
>

 Yep. Seesaw's definitely in maintenance mode. Once upon a time it
overlapped a lot with my day job, but not anymore so I just don't have a
ton of enthusiasm to spend time on it. I'd be open to new maintainers if
someone's feeling adventurous. Otherwise, JavaFX seems like the future so I
think effort would probably be better spent there. A lot has changed in UI
land in the last 5 years.


> Also, I was at the talk you mentioned and was very impressed with their
> methods. What wasn't mentioned in the talk was the fundamental structure of
> the interface between Clojure and JavaFX. One point that _really_ struck me
> is that they have a reoccurring timer running in the background and each
> time it wakes up it checks for changes on the app-state (presumably an
> atom, but I do not remember). If the app-state has changed then it starts
> re-rendering the UI. If I remember correctly it recreates the UI components
> that rely on any part of the app state that has changed. It sounds a little
> similar to Facebook React. I questioned them on this approach as it sounded
> strange to me... and they convinced me it's a good approach for their
> project and inspired me to try something similar on my own... which I'm
> secretly working on ;-)
>
> One thing that makes this work so well for their approach is that they
> have animations that depend on the app state. So their reoccurring timer is
> almost like a video algorithm redrawing the on screen image at the
> specified frame rate.
>
> --
> Jason Zwolak
>
> On Thu, Mar 17, 2016 at 11:06 AM, Paul L. Snyder <p...@pataprogramming.com
> > wrote:
>
>> Yow, old indeed!
>>
>> In 2011, Dave Ray released Seesaw, which is a very nice wrapper for Swing.
>> I've used it for a bunch of projects, and it works great. Of course, it
>> does look like Swing, but it's plenty usable. (It's also still being
>> maintained, so if you're looking for a toolkit that you can use right now,
>> it's a good way to go.)
>>
>>   https://github.com/daveray/seesaw
>>
>> That said, I'd also love to see a JavaFX wrapper. At the Conj in Philly,
>> Cognitect talked about a project where they'd used it extensively:
>>
>>   https://www.youtube.com/watch?v=ajX09xQ_UEg
>>
>> It's definitely piqued my interest.
>>
>> Paul
>>
>> On Sat, 12 Mar 2016, Jason Zwolak wrote:
>>
>> > +1 JavaFX.
>> >
>> > I know this is an old thread... but in case anyone comes across it
>> (like I
>> > did just now) and wants to see where things are, they should know that
>> > JavaFX has come a long way and seems to be Oracle's replacement for
>> Swing.
>> > Now JavaFX is no longer only in JavaFXscript... in fact, I believe
>> > JavaFXscript is deprecated in favor of the JavaFX Java classes.
>> >
>> > I've seen some major projects done with Clojure and JavaFX... even from
>> the
>> > guys at Cognitect.
>> >
>> > On Thursday, May 27, 2010 at 11:18:41 AM UTC-4, Luke VanderHart wrote:
>> > >
>> > > My side project is a fairly complex GUI application written in
>> > > Clojure. Recently, I've become irritated with using Java interop for
>> > > everything. It's not that Clojure doesn't have nice java interop - it
>> > > does. It's just that when interacting with a GUI framework, which is a
>> > > large part of my app, I have to be back in mutable object-oriented
>> > > land, worrying about class hierarchies, mutable state, locks, etc.
>> > > Yucky.
>> > >
>> > > So, with a perhaps dangerous lack of sanity and without any guarantee
>> > > of success, I've decided to try my hand at writing an idiomatic
>> > > Clojure GUI library. If I have success (which I doubt) I will of
>> > > course make it available as open source.
>> > >
>> > > I intend for it to be mostly declarative, with a nice DSL for defining
>> > > GUI elements. Each component will also implement map, and use one of
>> > > Clojure's reference types as an interface for inspecting / updating
>> > > its state. I may also implement some aspects of Functional Reactive

Re: Reflection warning on setCaretPosition

2015-02-27 Thread Dave Ray
(let [^JEditorPane html-table (editor-pane ...)] ...)  should fix it. Or
just set the caret position in the create function:

(editor-pane :caret-position 0)

or use config:

(config! editor-pane :caret-position 0)

Dave


On Fri, Feb 27, 2015 at 4:07 AM, Cecil Westerhof cldwester...@gmail.com
wrote:

 2015-02-27 11:34 GMT+01:00 Gary Verhaegen gary.verhae...@gmail.com:

 It means the Clojure compiler cannot emit the efficient bytecode
 directly, so it emits bytecode that calls the method reflexively.

 This only impacts performance, so if that code is not used much, it is
 not a problem.


 ​It is not used much, so it should not be a real problem.
 ​



 The underlying problem is that jvm bytecode is typed, so ideally the
 bytecode should be able to say call method M of type T on object O. Here,
 the Clojure Compiler cannot infer a type for html-table, so instead the
 emitted bytecode is more along the lines of ask object O to give a list of
 all of its types, then look into each of these types to find if one has a
 method that matches M in terms of name and number of arguments, and then
 look at that method's signature and check if the arguments can be cast to
 the types of the formal parameters; if there is a type with such a method,
 invoke that method.

 This is not 100% technically accurate (in particular, i have no idea what
 reflection does about the arguments and their types in this case), but it
 should be roughly correct and you can easily see why that would be much
 slower.

 If you want to remove that warning, you can annotate the html-table
 variable, but the place where you must do that will depend on a little more
 context than what you've given here. It is usually done at the level of var
 declaration or in function argument lists.


 ​This is the code:
(let [html-table (editor-pane
  :content-type text/html
  :text (str html-start
 html-records
 html-end))
 ]
 (.setCaretPosition html-table 0)

 So html-table is a JEditorPane. Should Clojure not be able to determine
 that?


 Just to satisfy my curiosity: how can I get rid of the warning?
 ​


 On Friday, 27 February 2015, Cecil Westerhof cldwester...@gmail.com
 wrote:

 On a editor-pane I use:
 (.setCaretPosition html-table 0)

 ​And it does what it should do. But when I run:
 lein check

 I get:
 Reflection warning, quotes/core.clj:98:42 - call to method
 setCaretPosition can't be resolved (target class is unknown).

 Is that something to worry about?

 By the way, I get also some on jdbc and seesaw.​


 ​Strange enough I only get the warnings on my own code now.
 ​

 --
 Cecil Westerhof

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


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


Re: Open html file in Clojure

2014-12-08 Thread Dave Ray
Nope. It barely renders HTML3. JavaFX, I think, has a real embedded browser
component. And, of course, it's always easy to just launch a browser:
http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html#browse%28java.net.URI%29

Dave

On Mon, Dec 8, 2014 at 4:23 AM, Gary Verhaegen gary.verhae...@gmail.com
wrote:

 This seems to be what Fluid is talking about:

 https://docs.oracle.com/javase/tutorial/uiswing/components/html.html

 I wiuld be a bit wary, however: I doubt this is a complete implementation
 of an HTML5-compatible browser with state of the art JavaScript
 interpreter. It's worth trying, but I would not really bet on that being
 able to display a Google Maps widget.

 On Monday, 8 December 2014, Fluid Dynamics a2093...@trbvm.com wrote:

 On Sunday, December 7, 2014 6:50:54 PM UTC-5, juan.facorro wrote:

 Hi Priyanka,

 I don't think there's enough information for someone to be able to help
 you. When you say .html do you mean JavaScript or ClojureScript code? It
 will be a lot easier to help you, if you share the code from the desktop
 app and the code you are using to get the location information.


 It sounds like he just wants to display a web page in his app, and has
 its URL. I think there may be Java Swing components that can do that.

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

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


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

2014-11-13 Thread Dave Ray
How about:

(- (map * (cycle [1 -1]) (range 1 n))
 (reduce +))

?

Dave


On Thu, Nov 13, 2014 at 5:31 PM, Andy L core.as...@gmail.com wrote:

 Hi,

 All I was able to come up with was this

 (defn altsum[n] (reduce + (map * (range 1 (inc n))  (interpose -1 (repeat
 1)

 ... works quite well, however I was wondering if there is more idiomatic
 way to write that.

 Thanks,
 Andy

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


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


Re: CCW bug [SEVERE]

2014-10-28 Thread Dave Ray
Do the names Ken Wesson or Cedric Greevey mean anything to you? Just
checking.

On Tue, Oct 28, 2014 at 1:28 PM, Fluid Dynamics a2093...@trbvm.com wrote:

 On Tuesday, October 28, 2014 12:19:29 PM UTC-4, Marcus Blankenship wrote:

 Agreed.  I've been amazed at how kind this group has been, despite your
 attitude of disrespect toward them.

 On Tue, Oct 28, 2014 at 9:09 AM, Dylan Butman dbu...@gmail.com wrote:

 From your attitude and lack of respect for the very knowledgeable,
 experienced, and respectful people here trying to help improve and
 understand the short comings in your current workflow, I'd say you might be
 walking to work in the near future. Parking's free that way.


 Really? Because I'm not the one who accused someone of nonexistent
 shortcomings and then made the impotent threat to revoke someone's
 driver's license -- and then had his threatening post deleted by the
 moderator. Hmm. :)

 Meanwhile, I think some people still have not grasped the scale of what
 I'm doing, namely how small it is. Small, experimental, limited to one
 person, and so forth. Version control, I repeat, would be MASSIVE overkill
 under the circumstances. It would make barely any less sense to reach for
 version control before writing a hello, world program.

 IF the project grows enough and is successful enough, then I might
 consider creating a github account and basing it there. But right now
 things are NOWHERE NEAR that kind of state. I am unsure how else to try to
 communicate the fact of how small, unpublishable, and etc. it is at this
 stage, so I will probably give up on anyone here who still seems to think
 it's big enough, has enough developers, or whatever to benefit from version
 control. It's not. So far there's two files of combined size 1200 lines,
 most of them comment and docstring lines. There might be as many as 200
 actual lines of Clojure in there so far. Using a version control system,
 and dealing with all of the associated ceremony and formalities, would be
 like renting a factory and setting up all of the process monitoring,
 conveyor belt equipment, robot arms, safety inspections, permits, and
 everything else attendant the use of such a facility, just to put together
 a high school shop project wooden birdhouse to hang from a tree in my own
 back yard. :) It would be like filing a flight plan with the FAA before
 going to the city park with a kite. Like getting in the car and driving to
 the house next door to visit the neighbors for coffee. Like bringing a map,
 compass, pack full of survival supplies, camp stove, satellite phone,
 avalanche beacon, ropes, pitons, and sturdy hiking boots to take a walk in
 NYC that crosses through Central Park. Like commissioning the Glomar
 Explorer to fish a ring out of a toilet bowl. Bringing lawyers and pages of
 CYA contract text to a negotiation with a Starbucks for the purchase of a
 latte. Taking out a business license and city zoning permit to open a kid's
 five-cent lemonade stand. Seeking an import license before bringing a
 couple of Disney T-shirts back from EuroDisney. Requiring a full credit
 check before loaning your neighbor a screwdriver. Using steel-reinforced
 concrete to build a sandcastle.

 I trust everyone now gets the picture, and that any exception is named
 Sheldon Cooper? :)


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


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


Re: leiningen resources folder

2014-09-11 Thread Dave Ray
clojure.java.io/resource isn't specific to the resources folder. It just
scans the classpath. Your classpath probably looks like
test:src:resources or something so test wins. If there was a
test/readme.txt file you'd also get that rather than resources/readme.txt.

Cheers,
Dave

On Thu, Sep 11, 2014 at 5:31 AM, Joc O'Connor johnocon...@fico.com wrote:

 Hi, when I use (.getPath (clojure.java.io/resource readme.txt)) I get
 the file path to the correct file in the resources folder (or nil if it
 doesn't exist).
 However if I pass in an empty string it returns the path to the 'test'
 folder rather then 'resources'. I have tried setting setting the resource
 paths in project.clj with no change in behaviour.

 Can anybody work out where I am going wrong?

 Joc

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


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


Re: Clojure Vim Ctags (oh my!)

2014-09-05 Thread Dave Ray
ctrl-o will take you back to your previous position after gf. At least it
does for me.

Dave


On Fri, Sep 5, 2014 at 11:47 AM, Alan Thompson clooj...@gmail.com wrote:

 Thanks for the 'gf' reference.  I can't seem to find a way to go back,
 though (like popping the tag stack with crtl-T).
 Alan


 On Thu, Sep 4, 2014 at 3:48 PM, Gary Verhaegen gary.verhae...@gmail.com
 wrote:

 Not sure what you're trying to get from ctags, but fireplace itself gives
 you some ability to jump around: gf on an external symbol will jump to that
 symbol's definition.


 On Thursday, 4 September 2014, Alan Thompson clooj...@gmail.com wrote:

 Nothing that fancy.  Just trying to make ctags understand namespaces 
 namespace aliases.  Vim/Ctags works fine for non-namspaced function
 references, like:

 (parseLong  5)

 However, the following won't work:

 (ns demo
   (:require [mylib.parse :as parse]))

   (parse/parseLong5)  ; fail parse/parseLong tag not found
   (mylib.parse/parseLong  5)  ; fail mylib.parse/parseLong tag not
 found

 The problem is that the entire namespace part of a reference (either
 aliased or nor) is not recognized by ctags.  Since ctags does not know
 anything about clojure namespaces, it thinks the whole thing is the
 function name, not just the part after the / character.
 Alan



 On Thu, Sep 4, 2014 at 11:52 AM, Jason Felice jason.m.fel...@gmail.com
 wrote:

 Is using tools.analyzer.jvm overkill?  Do you want to capture
 pre-macro-expansion, post-marco-expanion, both?


 On Thu, Sep 4, 2014 at 2:41 PM, Alan Thompson clooj...@gmail.com
 wrote:

 Hi,

 I've been using Clojure  Vim for a year now, with fireplace, etc.
  However, it seems that Exuberant Ctags is a bit crippled since I have not
 found a way to make it understand namespace aliases. In my current work it
 seems that nearly every function is in a separate namespace with a
 namespace alias.

 Unless there is already a tool (or a ~/.ctags regex) to do that, I was
 thinking about writing a lein plugin (in clojure) to decode namespace
 aliases in the (ns...) form and create a tags file from scratch. About a
 year ago (in a previous job), I had to write a similar tool (in Groovy) to
 create the tags file for PL/I code, so I'm familiar with the ctags file
 format.

 Any thoughts?

 Alan

 P.S.  I have been experimenting with LightTable but GVim is still my
 day-to-day workhorse.

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


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


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

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

Re: Defs with %

2014-06-17 Thread Dave Ray
I believe this is a problem with the Leiningen REPL. It works fine from the
built-in REPL:

$ java -jar ~/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1.jar
Clojure 1.5.1
user= (def top% 4)
#'user/top%
user= top%
4

Dave




On Tue, Jun 17, 2014 at 1:32 AM, Mike Thompson m.l.thompson...@gmail.com
wrote:

 At the REPL ...


 user= (def top% 4)   ;; an unusually named var
 #'user/top%

 But later, it I try to use this var, trouble ...

 user= top%

 CompilerException java.lang.RuntimeException: Unable to resolve symbol:
 top in this context,
 compiling:(Local\Temp\form-init6773082655831127234.clj:1:734)
 CompilerException java.lang.RuntimeException: Unable to resolve symbol: %
 in this context,
 compiling:(Local\Temp\form-init6773082655831127234.clj:1:734)


 Not sure what to make if this. Obviously % is a bit special.  And it is
 certainly not a significant problem for me, at all.  Just seemed odd that
 I'm allowed to successfully do the def, if it is just going to cause
 problems later.

 --

 Mike





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


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


Re: seesaw: drawing text

2014-06-03 Thread Dave Ray
The canvas example shows two ways of doing this:


https://github.com/daveray/seesaw/blob/develop/test/seesaw/test/examples/canvas.clj

paint1 uses the .drawString method directly. paint2 uses string-shape for
the same effect.

Hope this helps,

Dave



On Tue, Jun 3, 2014 at 11:56 AM, Christopher Howard cmhowa...@alaska.edu
wrote:

 Hi. In seesaw, how do you draw text to a graphics 2d object? I see in
 seesaw.graphics how to draw circles and lines and such, but want to
 draw a line of text. (I'm drawing on a canvas.)

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


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


Re: Gradle: how to deal with it

2014-05-10 Thread Dave Ray
You should use Clojuresque [1]. The latest version (1.7.0) can start an
nrepl server for you. Since I'm a bad user (and because of various
dependency-related hurdles at work), I still haven't actually started using
it though. Luckily, with earlier versions it's pretty easy to define a new
task that starts an nrepl server. Here's an example:


https://github.com/Netflix/RxJava/blob/master/language-adaptors/rxjava-clojure/build.gradle#L55

With Cider 0.6.0, you can just M-X cider and connect. If you have the
latest alpha, well, good luck getting back to 0.6.0. For ac-nrepl
auto-complete you'll want to add clojure-complete [2] as a dependency as
well.

Good luck,
Dave

[1] https://bitbucket.org/clojuresque/clojuresque
[2] https://clojars.org/clojure-complete



On Sat, May 10, 2014 at 4:00 AM, Catonano caton...@gmail.com wrote:

 Hello

 I use to press M-. in Emacs to jump to the definition of a function and
 M-, to jump back to where I came from

 This requires an nREPL to be working

 Now I'd like to explore a project using Gradle.

 Can I get an nREPL with Gradle ? Can Gradle export a project file so that
 I can use lein to have an nREPL ?


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


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


Re: Headless server, no GUI, no idea

2014-05-09 Thread Dave Ray
I'm not exactly clear what you're trying to do, but I had similar problems
with running Seesaw tests on Travis CI. Here's the settings I used to work
around it:

  https://github.com/daveray/seesaw/blob/develop/.travis.yml

Hope this helps,

Dave



On Fri, May 9, 2014 at 10:52 AM, Stuart Sierra
the.stuart.sie...@gmail.comwrote:

 This sounds more like a problem with remote access to X-Windows (the Unix
 graphical back-end) than a Clojure-specific problem. You might find some
 helpful answers in Ubuntu docs, forums, or chat rooms.
 -S


 On Friday, May 9, 2014 6:57:26 AM UTC-4, stiffyrabbit jr wrote:

 Hi,

 What should my approach be, if I want my headless server to run a client
 program that uses the client GUI?

 How can my server provide the same resources as a local client, to use
 GUI objects?

 I have a Clojure program that opens a file dialog on the client.  It
 works fine, until I try to run it from the server.

 My setup:

 A Macbook Pro with VirtualBox and LightTable on it;
 VirtualBox running Ubuntu 14.4, Leiningen, Clojure.  Ubuntu has extension
 pack, in response to this problem;

 I start VB - VBoxManage startvm 'Core' --type headless;

 I login to Core - ssh Core normally, ssh -v -X Core in desparation;

 I launch a repl in a Clojure proj.  I use the host:port details as a LT
 nrepl connection.  I get the following error:



 *java.awt.HeadlessException: No X11 DISPLAY variable was set, but this
 program performed an operation which requires it.*I have tried so many
 things to resolve this, that I get lost in it all.

 What approach will ensure that my server can run a program that requires
 DISPLAY, and use client GUI objects?

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


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


Re: seesaw canvas paint

2014-05-02 Thread Dave Ray
Someone asked something similar on reddit and my response had a couple
examples of rendering app state:


http://www.reddit.com/r/Clojure/comments/23uweq/watchers_and_paint_and_repaint_oh_my/ch7iw4s

Hope this helps,
Dave



On Fri, May 2, 2014 at 1:27 PM, Christopher Howard cmhowa...@alaska.eduwrote:

 Suppose one is using seesaw, and wants to have a canvas with lots of
 images and whatnot drawn inside it. The github examples pretty well
 cover that. However, what if you want the paint function to behave
 differently depending on some data elsewhere? (For example, the canvas
 is supposed to be a visual representation of model data.) Should you
 just have the paint function capture the (modifiable) data variable,
 and use that each time? Or...?

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


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


Re: Kwargs vs explicit parameter map for APIs?

2014-04-25 Thread Dave Ray
Seesaw looks nice, but in retrospect I would use explicit maps if I had it
to do all over again for exactly the reasons you mention. These days, I
always use explicit maps for options.

Dave


On Fri, Apr 25, 2014 at 3:56 PM, Andrey Antukh n...@niwi.be wrote:

 Hi!

 I have the same doubt!

 However, At this time, I prefer use a explicit map instead keywords,
 because for me is much clear that using keywords.

 Andrey.


 2014-04-26 0:41 GMT+02:00 Colin Fleming colin.mailingl...@gmail.com:

 Hi all,

 I'm working on an API at the moment, and I'm balancing whether to use
 inline keyword args which I would destructure in the functions, or whether
 to just pass an explicit params map as the last parameter. Comparison of
 the two options in case I'm not explaining myself well:

 Kwargs:
 (class/create-class :instancelist
 :description My description
 :implements  (keys class-methods)
 :methods (calculate-my-methods))

 Map:
 (class/create-class {:instancelist
  :description My description
  :implements  (keys class-methods)
  :methods (calculate-my-methods)})

 A lot of APIs I've seen have favoured kwargs, and it undeniably makes for
 some pretty code - Seesaw is the best example I've seen here, the API is a
 thing of beauty. However it seems to me to have some issues:

1. If I want to delegate to another call from within an API function
and use the same arguments, it's really awkward: (apply delegate
(mapcat identity args)) or some similarly awful black juxt magic. Or
of course writing out all the parameters again, but that's even worse.
2. It's more difficult to make parameters optional based on some
runtime criteria since the params are baked into the function call. I 
 guess
this is usually dealt with by making the calls handle nil for a particular
parameter.

 Both of these are much easier when passing an explicit map. Any
 preferences here, from either writing or using APIs like this?

 Cheers,

 Colin

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




 --
 Andrey Antukh - Андрей Антух - andrei.anto...@kaleidos.net / 
 n...@niwi.be
 http://www.niwi.be http://www.niwi.be/page/about/
 https://github.com/niwibe

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


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


Re: anyone in Santa Cruz?

2014-03-27 Thread Dave Ray
I'd be interested.
Dave


On Thu, Mar 27, 2014 at 1:04 PM, Tim timothy.parthem...@gmail.com wrote:

 Yes, please!


 On Thursday, March 27, 2014 10:21:32 AM UTC-7, Brian Craft wrote:

 Looking for clojure users in the Santa Cruz, Ca area who are interested
 in a meetup, study group, etc.

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


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


Re: get rid of reflection in proxy-super?

2013-12-22 Thread Dave Ray
Seesaw has the same problem with paintComponent. IIRC, it's because it's
protected. I never found a workaround.

Dave

On Sunday, December 22, 2013, Colin Fleming wrote:

 I actually just wrote a long reply detailing how to type hint 'this', and
 then noticed that you've already done that! This exact case
 (paintComponent) is the one reflection warning I can't get rid of in the
 whole Cursive codebase, I can't figure it out either.


 On 23 December 2013 01:03, Jim - FooBar(); 
 jimpil1...@gmail.comjavascript:_e({}, 'cvml', 'jimpil1...@gmail.com');
  wrote:

 Hi all,

 is there any way to get rid of reflection in simmilar looking? Nothing
 seems to work...

 (proxy [JPanel ActionListener KeyListener] []
 (paintComponent [^java.awt.Graphics g]
   (let [^JPanel this this]
   (proxy-super paintComponent g))


 thanks in advance... :)

 Jim

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 
 clojure@googlegroups.comjavascript:_e({}, 'cvml', 
 'clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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.comjavascript:_e({}, 'cvml', 
 'clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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.


Re: get rid of reflection in proxy-super?

2013-12-22 Thread Dave Ray
I've spent a night scratching my head about the behavior of proxy-super in
the presence of exceptions as well. I figured it was something like what
you found, but by that point I just didn't trust proxy that much anymore
and wrote that little bit in Java [1]. If I were a better person I would
have hunted it down and filed a JIRA.

Dave

[1]
https://github.com/daveray/seesaw/blob/develop/jvm/seesaw/ExceptionHandler.java


On Sun, Dec 22, 2013 at 10:26 PM, Colin Fleming colin.mailingl...@gmail.com
 wrote:

 So, I poked around in the code a little, Dave is indeed right - it appears
 to be impossible to remove reflection warnings for proxy-super calling
 protected methods.

 (defn proxy-call-with-super [call this meth]
  (let [m (proxy-mappings this)]
 (update-proxy this (assoc m meth nil))
 (let [ret (call)]
   (update-proxy this m)
   ret)))

 (defmacro proxy-super
   Use to call a superclass method in the body of a proxy method.
   Note, expansion captures 'this
   {:added 1.0}
   [meth  args]
  `(proxy-call-with-super (fn [] (. ~'this ~meth ~@args))  ~'this ~(name
 meth)))

 The method call for proxy-super just expands into the dot form, and
 looking at the Compiler code that does indeed only search public methods.

 There appears to be another problem with proxy-call-with-super: unless I'm
 missing something, the second update-proxy should be in a finally block.
 Currently if the superclass method throws an exception, the proxy will be
 left with the superclass call in its proxy mappings.



 On 23 December 2013 16:41, Colin Fleming colin.mailingl...@gmail.comwrote:

 But surely proxy-super should be designed to call protected methods? I'd
 have to check but I suspect I call other protected methods using it.


 On 23 December 2013 14:13, Dave Ray dave...@gmail.com wrote:

 Seesaw has the same problem with paintComponent. IIRC, it's because it's
 protected. I never found a workaround.

 Dave


 On Sunday, December 22, 2013, Colin Fleming wrote:

 I actually just wrote a long reply detailing how to type hint 'this',
 and then noticed that you've already done that! This exact case
 (paintComponent) is the one reflection warning I can't get rid of in the
 whole Cursive codebase, I can't figure it out either.


 On 23 December 2013 01:03, Jim - FooBar(); jimpil1...@gmail.comwrote:

 Hi all,

 is there any way to get rid of reflection in simmilar looking? Nothing
 seems to work...

 (proxy [JPanel ActionListener KeyListener] []
 (paintComponent [^java.awt.Graphics g]
   (let [^JPanel this this]
   (proxy-super paintComponent g))


 thanks in advance... :)

 Jim

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


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

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



  --
 --
 You received this message because you are subscribed to the Google
 Groups 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: How would I do this in Clojure?

2013-12-05 Thread Dave Ray
It's also doable with just swap!, fwiw:

(defn make-blah [xs]
  (let [a (atom [nil xs])]
(fn []
  (first (swap! a
(fn [[_ tail]]
  [(first tail) (next tail)]))

Dave



On Thu, Dec 5, 2013 at 12:43 PM, Mark Engelberg mark.engelb...@gmail.comwrote:

 Although I think that a ref is the right tool for this purpose, for the
 sake of completeness, I'll illustrate the threadsafe way to use an atom
 here:

 (defn make-blah [v]
   (let [a (atom v)]
 (fn [] (let [current-val @a]
  (if (compare-and-set! a current-val (rest current-val))
(first current-val)
(recur))





 On Thu, Dec 5, 2013 at 12:35 PM, Mark Engelberg 
 mark.engelb...@gmail.comwrote:

 It's worth pointing out that if you really care about using it across
 multiple threads, an atom really isn't the right tool for the job.  You
 should use a ref in order to place both the first and the rest into a
 single transaction:

 (defn make-blah [v]
   (let [a (ref v)]
 (fn [] (dosync (let [x (first @a)] (alter a rest) x)



 On Thu, Dec 5, 2013 at 12:24 PM, David Simmons 
 shortlypor...@gmail.comwrote:

 Hi Puzzler


 I like the first approach you defined and it works perfectly thank you.

 cheers

 Dave

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



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


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

2013-11-16 Thread Dave Ray
FWIW, Netflix uses a sorta similar approach but the overload detection
lives on the client-side since different clients may have varying
definitions of slow, may want finer grained control of fallback behavior,
etc:

  http://techblog.netflix.com/2012/02/fault-tolerance-in-high-volume.html

There's a library for this:

  https://github.com/Netflix/Hystrix

and Clojure bindings:

  https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-clj

Cheers,

Dave



On Sat, Nov 16, 2013 at 6:35 PM, James Reeves ja...@booleanknot.com wrote:

 On 17 November 2013 01:52, Cedric Greevey cgree...@gmail.com wrote:

 The distribution will be narrow and peak at around 1 second, though,
 which may not be what you want. Of course, the OP has since indicated that
 he meant non-web uses of HTTP rather than serving web sites...


 Web services are generally considered to be part of the web, hence the
 term *web* service :)

 - James

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


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

2013-11-14 Thread Dave Ray
As noted over on the Seesaw list, your pdf loading code is blocking the UI
thread. When you call it from the REPL, it's a separate thread so the
button has a chance to update itself. You'll need to put the pdf loading on
a separate thread if you want to the UI to update and stay responsive.

Cheers,

Dave


On Thu, Nov 14, 2013 at 12:19 PM, Josh Kamau joshnet2...@gmail.com wrote:

 Try to create a simple app that just demonstrate the issue.  Then send the
 sample to the mailing list. Most likely you won't have to send because you
 will discover the problem in the process.

 Josh
 On 14 Nov 2013 23:08, Jim - FooBar(); jimpil1...@gmail.com wrote:

 Hi people,

 I 'll have to apologise in advance for the potential vagueness of my
 question but I am utterly baffled by the behaviour I am seeing and I'd like
 to share  ask.

 I have a (seesaw) GUI with a swingx.busy-label which I want activated
 when certain tasks are performed. The code that i've written so fat works
 perfectly at the repl but for some bizarre reason it won't work when
 attached as a handler to a button. I mean literally the same code works
 perfectly at the REPL while the GUI is up but from the GUI itself the
 effect does not happen, even though the actual work is being done (i.e.
 loading a big pdf file)!

 my question is what could possibly cause such a different behaviour? What
 is so different between the REPL and attaching a handler to a button? If
 anything, the REPL involves a compilation step whereas the handler has been
 sitting there all along... any ideas? I don't even know where to start
 looking since the code runs fine at the repl... This has never happened to
 me before!

 many thanks in advance,

 Jim

 ps: even though I have posted at the seesaw list, I am starting to doubt
 this is a seesaw-related issue simply because it works at the 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
 --- 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.

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


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

2013-10-28 Thread Dave Ray
... or the no-sentinel find-based approach:

(if-let [[_ v] (find a-map :b)]
  v
  (my-foo))

Cheers,

Dave



On Mon, Oct 28, 2013 at 9:08 AM, Alex Baranosky 
alexander.barano...@gmail.com wrote:

 Or a shorter variant of the sentinel approach:

 (let [r (get a-map :b ::unfound)]
   (if (= r ::unfound)
 (my-foo)
 r))


 On Sun, Oct 27, 2013 at 2:57 PM, Cedric Greevey cgree...@gmail.comwrote:

 (get a-map :b my-foo) will result in the function object itself being
 returned if :b is not found. If you want it to be called only in the event
 of not found, you need either

 (if (contains? a-map :b) (a-map :b) (my-foo)) -- which may perform the
 lookup twice -- or

 (if-let [r (a-map :b)] r (my-foo)) -- which does not, but treats a {:b
 nil} entry as the same as absence of :b -- or

 (let [sentinel (Object.)
   r (get a-map :b sentinel)]
   (if (identical? r sentinel)
 (my-foo)
 r)) -- which is longer and more complex, but calls my-foo (and
 returns what it returns) if and only if :b is genuinely absent from the map
 (like the first solution above) and performs the lookup only once (like the
 second solution above). If this has to be done in a tight loop, the extra
 efficiency over the second solution may be worth it, but you'll want to
 avoid repeatedly creating and discarding the sentinel object as well,
 resulting in something like

 (def {^:private} sentinel (Object.))

 ...

 (defn ...
 ...
   (loop ...
 ...
 (let [r (get a-map :b sentinel)]
   (if (identical? r sentinel)
 (my-foo)
 r)) ... ) ... )



 On Sun, Oct 27, 2013 at 1:00 PM, Ryan arekand...@gmail.com wrote:

 Silly me, thank you for your replies guys!

 One more question though, what if my-foo had parameters?

 Ryan


 On Sunday, October 27, 2013 6:55:34 PM UTC+2, Luc wrote:

 You are getting my-foo evaluated, remove the parens around it.

 Luc P.


  Hello,
 
  I am trying to understanding why is this happening:
 
   (defn my-foo [] (println Why do I get printed?))
   #'sandbox4724/my-foo
(get {:b 1} :b (my-foo))
   Why do I get printed?
   1
   
 
 
  Shouldn't (my-foo) only be called in case the key isn't found? Why am
 I
  seeing the above behavior instead?
 
  Thank you for your time,
 
  Ryan
 
  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clo...@googlegroups.com
  Note that posts from new members are moderated - please be patient
 with your first post.
  To unsubscribe from this group, send email to
  clojure+u...@**googlegroups.com
  For more options, visit this group at
  http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
  ---
  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_outhttps://groups.google.com/groups/opt_out.

 
 --
 Softaddictslprefo...@**softaddicts.ca sent by ibisMail from my ipad!

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


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


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

Re: Are there any GUI based Clojure apps out there?

2013-10-17 Thread Dave Ray
Nightcode is also client-side and all Clojure: https://nightcode.info/

Dave


On Thu, Oct 17, 2013 at 7:02 AM, Andy Fingerhut andy.finger...@gmail.comwrote:

 The Clojure namespace browser was developed using the Seesaw library:

 https://github.com/franks42/clj-ns-browser




 On Thu, Oct 17, 2013 at 6:33 AM, Arie van Wingerden xapw...@gmail.comwrote:

 Seesaw? https://github.com/daveray/seesaw



 2013/10/17 Jonathon McKitrick jmckitr...@gmail.com

 I'd be interested in seeing some client-side apps with a GUI, if there
 are any.  'Ants' is a good demo, but I'm looking for something a little
 more.  ;-)

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


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


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


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

2013-09-17 Thread Dave Ray
Hey,

You have too many colons:

user= (read-string :l/test)
:l/test


Dave



On Tue, Sep 17, 2013 at 4:03 PM, Casper Clausen casp...@gmail.com wrote:

 I am reading a bunch of clojure files using the build-in reader (or
 tools.reader, it has the same problem) and I am running into a problem
 regarding namespaced keywords (is that the right term?) such as ::l/test.

 = (read-string ::l/test)
 RuntimeException Invalid token: ::l/test
  clojure.lang.Util.runtimeException (Util.java:219)

 It seems that the reader requires the namespace alias 'l' to exist. This
 is a shame because in most (all?) other respects the reader is able to just
 read in the symbols even if their namespace is not loaded. So in order for
 me to read a file with a namespaced keyword I need to eval at least the ns
 form of the file, which then requires me to eval the ns forms of its
 dependencies (and so on). My code is basically building on the excellent
 codeq analyzer (
 https://github.com/Datomic/codeq/blob/master/src/datomic/codeq/analyzers/clj.clj),
 so I am guessing this would have the same problem when running into a
 similar namespaced keyword.

 So my question is how do I best get around 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
 ---
 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.


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

2013-09-17 Thread Dave Ray
A namespace-qualified keyword has a single colon:

:my-namespace/something

The double-colon is only shorthand for the current namespace:

(in-ns 'my-namespace)
::something - :my-namespace/something

Dave



On Tue, Sep 17, 2013 at 4:58 PM, Casper Clausen casp...@gmail.com wrote:

 The double colon keyword creates a namespaced keyword and is perfectly
 valid syntax. It's just not used that often :)

 By default a keyword like ::test resolves to the current namespace like
 ::current-ns/test, but you can also provide another ns which causes the
 problem when reading.

 Have at look at
 https://github.com/clojure/core.logic/blob/0d1d545f0a81c585c7449aecb5d661120f3da568/src/main/clojure/clojure/core/logic/fd.cljfor
  instance.

 On Wednesday, September 18, 2013 1:05:01 AM UTC+2, daveray wrote:

 Hey,

 You have too many colons:

 user= (read-string :l/test)
 :l/test


 Dave



 On Tue, Sep 17, 2013 at 4:03 PM, Casper Clausen cas...@gmail.com wrote:

 I am reading a bunch of clojure files using the build-in reader (or
 tools.reader, it has the same problem) and I am running into a problem
 regarding namespaced keywords (is that the right term?) such as ::l/test.

 = (read-string ::l/test)
 RuntimeException Invalid token: ::l/test  
 clojure.lang.Util.**runtimeException
 (Util.java:219)

 It seems that the reader requires the namespace alias 'l' to exist. This
 is a shame because in most (all?) other respects the reader is able to just
 read in the symbols even if their namespace is not loaded. So in order for
 me to read a file with a namespaced keyword I need to eval at least the ns
 form of the file, which then requires me to eval the ns forms of its
 dependencies (and so on). My code is basically building on the excellent
 codeq analyzer (https://github.com/Datomic/**
 codeq/blob/master/src/datomic/**codeq/analyzers/clj.cljhttps://github.com/Datomic/codeq/blob/master/src/datomic/codeq/analyzers/clj.clj),
 so I am guessing this would have the same problem when running into a
 similar namespaced keyword.

 So my question is how do I best get around 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.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@**googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 ---
 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_outhttps://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.


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

2013-09-17 Thread Dave Ray
Cool. You learn something new every day :)

On Tuesday, September 17, 2013, Brandon Bloom wrote:

  The double-colon is only shorthand for the current namespace:

 Or other namespaces via an alias:

 (alias 'clj 'clojure.core)
 ::clj/foo = :clojure.core/foo

 Inside ns forms, the :as keyword creates aliases.

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 
 clojure@googlegroups.comjavascript:_e({}, 'cvml', 
 'clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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.


Re: how does one unquote a list of records that implement IFn without treating the first item as a function?

2013-09-05 Thread Dave Ray
~(vec attrs), perhaps?


On Thu, Sep 5, 2013 at 12:20 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

 HI all,

 I've gotten myself into a weird situation...

 I'm defining a def-like macro and I want to use 'name-with-attributes'.
 Consider the following skeleton:


 (defmacro defX [name  args]
  (let [[name attrs] (name-with-attributes name args)]
 `(let [cs-coll# ~attrs]
(assert (every? component? cs-coll#) Can only accept IComponents)
(def ~name (Workflow. cs-coll# {:description (- ~name meta :doc)}
 nil)))

 now consider that I am calling this like so:

 (defworkflow my-stem-pipe my own basic stemming pipe my-ssplit
 my-tokenizer porter-stemmer)

 where the last three symbols refer to records which implement IFn...

 doing ~attrs tries to invoke the list as a function-call because the
 first symbol happens to be a function but I just want the list of records
 (eval'd symbols) so the assertion can proceed...


 any ideas?

 Jim

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


Re: Handling name collisions with clojure.core

2013-09-04 Thread Dave Ray
Maybe this is a dumb idea, but could you have a macro that rewrites code to
use your ops?

  (require '[clojure.core.matrix :as m])
  (m/with-ops (+ ... (* ...) ...))

and then all the special symbols get rewritten/qualified with
clojure.core.matrix?

Dave



On Wed, Sep 4, 2013 at 10:26 PM, Sean Corfield seancorfi...@gmail.comwrote:

 You only get the warning if you 'use' the namespace or 'refer all'
 tho', correct?

 And we've recently seen a lot of discussion that basically says don't
 do that so it seems that either users of core.matric are going to
 have two approved choices:
 * require core.matrix with an alias, or choose to rename colliding
 names however you want
 * exclude the colliding symbols via refer-clojure and require them
 from core.matrix as referred symbols

 That's seems right to me: it is explicit and provides no surprises; it
 gives the user control over how to manage things.

 Sean

 On Wed, Sep 4, 2013 at 6:22 PM, Mikera mike.r.anderson...@gmail.com
 wrote:
  Hi all,
 
  While building the API for core.matrix, I've fun into a few cases where
 the
  best name is a direct clash with clojure.core.
 
  Examples are +, zero?, vector?, ==
 
  In many of these cases, the core.matrix behaviour is a natural extension
 of
  the clojure.core function (i.e. it extends the same functionality to
  arbitrary N-dimensional arrays).
 
  I'm not very happy with any of the options I can see for handling this:
 
  A) Use the good names in the clojure.core.matrix namespace. Problem:
 that
  gives you a ton of nasty warnings of the type WARNING: + already refers
 to:
  #'clojure.core/+ in namespace: test.blank, being replaced by:
  #'clojure.core.matrix/+. Significant boilerplate must be maintained by
 the
  user in their ns declaration to prevent these warnings. I don't like
 forcing
  users to maintain boilerplate, and I think that normal idiomatic usage
  should be warning-free.
 
  B) Separate the name-clashing functions into separate namespaces - e.g.
  clojure.core.matrix.operators. Problem: that's something of an
 artificial
  division, and again it forces users to do extra ns-management work to
 access
  the functions they want.
 
  C) Use different names. Problem: names would be worse, and this would be
  inconsistent and confusing, especially for functions that do effectively
 the
  same thing.
 
  D) Encourage users to use aliases. Problem: that's horrendously ugly and
  inconvenient for numerical code. Users with any sense of elegance in
 their
  coding style would quite rightly throw their hands up in disgust.
 
  Currently we're doing B), I'd prefer to do A) but can't figure out a way
 to
  automatically suppress the warnings.
 
  Any better ideas?
 
 
 
  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from 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.



 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

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

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


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

Re: Rxjava + Clojure Users

2013-08-29 Thread Dave Ray
Hi,

Thanks for your feedback on your RxJava usage. I'm glad to hear that
neither of you feel too strongly about direct IFn support because...

In an effort to simplify the implementation and improve the RxJava
experience for all JVM-based languages, we'll be dropping direct IFn
support (and Groovy closure, Ruby proc, etc) in the next release. Instead,
for each supported language (Scala, Groovy, and Clojure at the moment),
we'll be providing a set of utility functions/macros/implicits to assist
with interop. In the Clojure case, this will consist of a namespace,
probably rx.lang.clojure, with the following helpers:

  (defn fn* [f])   Takes a function f, and wraps it in an object that
implements all the various Rx FuncX interfaces

  (defmacro fn [ body])Makes an anonymous Rx FuncX object with body
(multi-arities and everything from clojure.core/fn are supported)


So usage would basically be as I noted in my message above:

(require '[rx.lang.clojure :as rx])

(- my-observable
(.map (rx/fn [v] (Long/parseLong v)))
(.reduce (rx/fn* +)))

A similar function/macro pair will be provided for the Rx ActionX
interfaces for which there's currently no direct support.

This will provide us with base Clojure interop support which is slightly
more tedious to use than before. In the longer term, we'll be releasing a
more expansive, idiomatic set of Clojure bindings. We're not quite there on
that one though.

If anyone knows any reason this should not happen, speak now or forever
hold your peace.

Cheers,

Dave





On Wed, Aug 28, 2013 at 2:32 AM, Joseph Wilk j...@josephwilk.net wrote:

 On Tuesday, August 27, 2013 6:03:29 PM UTC+2, daveray wrote:

 Hi.

 I'm writing to see if there's anyone out there using RxJava [1] from
 Clojure and to get their opinion on it's current, built-in support for
 non-Java languages.

 Just to recap, the current implementation knows about clojure.lang.IFn
 allowing functions to be passed directly to RxJava methods:

   (- my-observable
 (.map (fn [v] (Long/parseLong v)))
 (.reduce +))

 RxJava will automatically convert these functions to the underlying
 rx.util.functions.FuncX interface and re-dispatch to the appropriate method.

 So, the question is: as a user of RxJava, how valuable is this feature?
 Do you just end up wrapping things anyway,



 We are using RxJava and Hystrix with Clojure @ SoundCloud. All our
 Observables come from Hystrix cmds.

 I've have not added any wrappers around the RxJava stuff yet, not really
 felt the need.
 I've found it convenient to pass in fns but I would also be happy with
 what you suggest below (rx/fn).
 I suspect in those cases I might start wrapping rx/fn, so it continues to
 look like the current behaviour (recognising Clojure fns).

 Thanks,
 --
 Joseph Wilk
 http://blog.josephwilk.net
 @josephwilk



 so you could easily perform the same transformation in your wrapper?
 Would helper fns/macros be a sufficient alternative:

   (- my-observable
 (.map (rx/fn [v] (Long/parseLong v)))
 (.reduce (rx/fn* +)))

 There will be some changes in this area in the near future and we'd like
 to get a feel for if/how people are using RxJava from Clojure.




 Thanks!

 Dave

 [1] https://github.com/Netflix/**RxJavahttps://github.com/Netflix/RxJava

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


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

2013-08-29 Thread Dave Ray
Seems to work fine in my tests as long as I fully qualify it in the fn
macro that uses it.  What am I missing?

If someone :uses or :refer-alls the ns, I'm assuming bad thing would
happen, but I'm not worried about that.

Dave


On Thu, Aug 29, 2013 at 12:15 PM, Cedric Greevey cgree...@gmail.com wrote:

 On Thu, Aug 29, 2013 at 2:00 PM, Dave Ray dave...@gmail.com wrote:

  In the Clojure case, this will consist of a namespace, probably
 rx.lang.clojure, with the following helpers:

   (defn fn* [f])   Takes a function f, and wraps it in an object that
 implements all the various Rx FuncX interfaces


 Erm, there's already a Clojure special form with the name fn*, so you'll
 need to change this one to something else I expect.

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


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


Rxjava + Clojure Users

2013-08-27 Thread Dave Ray
Hi.

I'm writing to see if there's anyone out there using RxJava [1] from
Clojure and to get their opinion on it's current, built-in support for
non-Java languages.

Just to recap, the current implementation knows about clojure.lang.IFn
allowing functions to be passed directly to RxJava methods:

  (- my-observable
(.map (fn [v] (Long/parseLong v)))
(.reduce +))

RxJava will automatically convert these functions to the underlying
rx.util.functions.FuncX interface and re-dispatch to the appropriate method.

So, the question is: as a user of RxJava, how valuable is this feature? Do
you just end up wrapping things anyway, so you could easily perform the
same transformation in your wrapper? Would helper fns/macros be a
sufficient alternative:

  (- my-observable
(.map (rx/fn [v] (Long/parseLong v)))
(.reduce (rx/fn* +)))

There will be some changes in this area in the near future and we'd like to
get a feel for if/how people are using RxJava from Clojure.

Thanks!

Dave

[1] https://github.com/Netflix/RxJava

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 (eval (list (quote (println Clojure)))) is throwing a Null Pointer Exception?

2013-08-24 Thread Dave Ray
You have an extra list in there which causes the evaluated code to look
like this:

  ((println Clojure))

The println is executed, it returns nil, and then because of the extra
parens, Clojure tries to execute nil as a function, giving a NPE. This
works:

user= (eval (quote (println Clojure)))
Clojure
nil

Cheers,

Dave




On Sat, Aug 24, 2013 at 12:48 PM, Hussein B. hubaghd...@gmail.com wrote:

 Hi,

 Why the following snippet:

 (eval (list (quote (println Clojure

 is throwing a null pointer exception?

 Thanks for help and time.

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


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

2013-08-02 Thread Dave Ray
In Seesaw [1] you can specify your shortcuts as menu S instead of ctrl
S and it will pick the right one for the platform.

Cheers,

Dave

[1] my memory's a little fuzzy here :)



On Fri, Aug 2, 2013 at 12:00 PM, Zach Oakes zsoa...@gmail.com wrote:

 That's a good point, I should be using command instead of control on OSX.
 I don't have a Mac so that slipped my mind; I'll make a note of it.


 On Friday, August 2, 2013 2:54:45 PM UTC-4, Lee wrote:


 On Aug 2, 2013, at 1:53 PM, Jeff Heon wrote:
  If I can suggest the one feature that I couldn't bear to use an IDE
 without:
  Strict Structural Editing Mode (paredit-style)

 But please note that while many love paredit, many others hate it -- so
 if you implement this I would make it optional.

 Also:

 On Aug 2, 2013, at 2:26 PM, John Gabriele wrote:
  . (Hm, when using Run with REPL, having trouble calling a function I
 added above -main...)

 That happened to me and in my case it was because I hadn't saved the
 changed file... thought I did because I had hit command-s (on a mac) while
 Nightcode save is control-s.

  One big issue I see right now: no smart indentation in the editor
 window.

 Totally essential, IMHO.

 If I can dream big, after the core editing features, somewhere near the
 top of my own feature wish-list would be a debugging feature that I think
 is currently available for Clojure only in emacs via nrepl-ritz (oh,
 actually now I think I see that it's available in a vim environment too):
 the ability to browse or at least print the values of locals up and down
 the stack at the point of an exception (presumably in a run with
 locals-clearing off, although it'd be great to see whatever hasn't been
 cleared anyway).

 There's a long thread of discussion about this and related ideas here:
 https://groups.google.com/**forum/#!topic/clojure/**qhdCrUoT_O0https://groups.google.com/forum/#!topic/clojure/qhdCrUoT_O0

 It'd be totally fabulous to have this feature in a Clojure IDE that's as
 clean and usable as Clooj or Nightcode.

  -Lee




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




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

2013-06-18 Thread Dave Ray
My team at Netflix is using Clojure for all new development these days.

Dave

On Tue, Jun 18, 2013 at 7:12 AM, Hussein B. hubaghd...@gmail.com wrote:
 According to their Jobs page, Doo is using Clojure to implement their
 backend and web application:
 https://doo.net/en/


 On Monday, June 10, 2013 11:47:25 PM UTC+2, Plinio Balduino wrote:

 Hi there

 I'm writing a talk about Clojure in the real world and I would like to
 know, if possible, which companies are using Clojure for production or
 to make internal tools.

 Thank you

 Plínio Balduino

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



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

2013-05-29 Thread Dave Ray
Hi David.

Himera by Fogus is a ClojureScript compiler as a service which seems
like it may be an example of what you're looking for.

  https://github.com/fogus/himera

Cheers,

Dave

On Wed, May 29, 2013 at 1:49 PM, David Pollak
feeder.of.the.be...@gmail.com wrote:
 Howdy,

 I'm looking to embed the ClojureScript compiler into an app I'm building
 (I'm packaging the app via uberjar). I'm trying to figure out how to compile
 ClojureScript to JavaScript in memory so that I get JavaScript stuff that I
 can shuttle off to places that can run JavaScript.

 Are there any examples of running the ClojureScript compiler inside an
 uberjar'ed app?

 Thanks,

 David

 --
 Telegram, Simply Beautiful CMS https://telegr.am
 Lift, the simply functional web framework http://liftweb.net
 Follow me: http://twitter.com/dpp
 Blog: http://goodstuff.im

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



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

2013-05-16 Thread Dave Ray
On Wednesday, May 15, 2013, Dave Sann wrote:

 If you are not using Leiningen, what do you use?


At home I use leiningen because its easy and well supported. At work I use
gradle and sometimes ant because it's the quickest path to getting clojure
in the build.


 why do you prefer it?

 D

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 
 clojure@googlegroups.comjavascript:_e({}, 'cvml', 
 'clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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.




Re: Utility libraries and dependency hygiene

2013-05-13 Thread Dave Ray
On Mon, May 13, 2013 at 1:42 AM, Meikel Brandmeyer (kotarak)
m...@kotka.de wrote:
 Hi,

 Am Montag, 13. Mai 2013 10:35:14 UTC+2 schrieb Stuart Sierra:



 I believe lightweight dependency loading system is an oxymoron. Either
 you A) design a new module format and try to get everyone to follow it
 (OSGI) or B) build an ad-hoc solution that tries to guess at the right
 behavior (JBoss). Either way, application developers still have a mess to
 deal with, just with an added layer of complexity.

 If someone out there can fix this problem once and for all, I will buy you
 a drink. But you can't bill me for all the drinks you'll need along the way.
 ;)


 Write  a tool which rebases the dependency in your namespace tree. Et voila.
 No nifty class loader magic necessary. As long as you always use *ns* to get
 hold of the namespace name, this should work.


In Java-land this tool is called Jar Jar Links
(http://code.google.com/p/jarjar/).

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

2013-05-09 Thread Dave Ray
I agree that you probably don't need to go overboard with hiding
stuff. For option 2 though there's no need for deftype. Just implement
the protocol with reifiy within the create function and use the
closure for state.

(defn create-woobly
   [...]
   (let [... put your queues and stuff here ...]
  (reify Woobly
  ... implement protocol here ...)))

Dave


On Thu, May 9, 2013 at 9:15 AM, Gary Trakhman gary.trakh...@gmail.com wrote:
 If the interface provides everything that's needed, then there will be no
 need to dive in?

 I find attempts to hide that stuff frustrating when I'm a consumer of the
 code, if I need it, and I acknowledge that implementation details are
 subject-to-change when I take that risk, so only having something clearly
 marked off by documentation of intent would be what I would do as a producer
 of the code.


 On Thu, May 9, 2013 at 12:07 PM, Colin Yates colin.ya...@gmail.com wrote:

 (newbie, but trying hard!)

 I am designing a Woobly.  A Woobly is non-trivial and has a number of
 internal data structures (queues, worker threads etc.).  You can 'add' and
 'remove' jobs from a Woobly.

 In OO land I might have a Woobly interface with the various methods which
 provides a public API.  I might also have a factory or more likely builder
 somewhere which creates Wooblies.

 The part I am struggling with is how to create a Woobly without exposing
 its internals.  Let's imagine that Woobly uses an internal
 LinkedBlockingQueue of a certain size.

 Option 1 - a big bag of data.
 I could create a map of config/state/data that comprises the
 implementation and have the creator function return that.  Consumers can
 then call other methods passing back that bag of config/state, but what
 stops them simply diving into that bag themselves?  For example:

 [code]
 (defn create-woobly
  ([] (create-woobly 100)
  ([queue-size] {:queue (java.util.concurrent.LinkedBlockingQueue
 queue-size)}))

 (defn add-job [woobly job] )

 ;; nothing stopping me diving into that state...
 (.clear (:queue (create-wobbly)))
 [/code]

 Option 2 - protocol and deftype
 Alternatively I could implement an IWoobly protocol and create a single
 deftype which is instantiated and returned from the 'create-woobly'
 function?  I am not sure I like this as it is really back to OO isn't it?

 I want to retain the notion of create returning a handle which is the
 first argument in the other public functions, but the first way just feels
 far too dangerous.

 Am I overthinking this - what do you all do to address this?

 Thanks a bunch.

 Col

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




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



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

2013-04-04 Thread Dave Ray
The latest Seesaw version on Clojars is 1.4.3. It addresses the Clojure
dependency issue.

Cheers,

Dave

On Thu, Apr 4, 2013 at 4:40 PM, Jim - FooBar(); jimpil1...@gmail.comwrote:

  [ghostandthemachine/seesaw 1.4.3-SNAPSHOT :exclusions [
 org.clojure/clojure]]

 Jim

 ps: maybe the actual coordinate for clojure  is wrong but I can


 On 05/04/13 00:32, Mark Engelberg wrote:

 Right now, I'm experimenting with seesaw.  In Clojars, it appears the
 latest version is 1.4.2.

 When I include [seesaw 1.4.2] in my project.clj file, then the REPL
 comes up as 1.3.0 (even though I explicitly define clojure 1.5.1 as a
 dependency in the project.clj file).  How do I make my preferred clojure
 version take precedence over whatever seesaw is requesting?

 Thanks,

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




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




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

2013-03-03 Thread Dave Ray
Thanks. It's impress.js [1]. Fortunately, I'm to lazy to really go
overboard with it.

Dave

[1] http://bartaz.github.com/impress.js/


On Sun, Mar 3, 2013 at 1:02 AM, Mayank Jain firesof...@gmail.com wrote:
 What did you use to create this presentation[1]?
 It's so beautiful!

 [1] : http://darevay.com/talks/clojurewest2012/#/title-slide


 On Sun, Mar 3, 2013 at 12:34 PM, Dave Ray dave...@gmail.com wrote:

 Hi,

 Since it's been a while, thought I'd mention that Seesaw 1.4.3 was
 just released. You can find release notes here:

   https://github.com/daveray/seesaw/wiki/Release-Notes

 Mostly just small maintenance issues.

 The one good reason to upgrade is if you're planning on using Clojure
 1.5 and don't feel like being confused by the horrors of Maven
 dependency resolution. More information here [1] and here [2].

 Cheers,

 Dave

 [1] https://github.com/daveray/seesaw/issues/102
 [2]
 https://groups.google.com/forum/?fromgroups=#!topic/clojure/kzF5O0Yfdhc

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





 --
 Regards,
 Mayank.

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



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

2013-03-02 Thread Dave Ray
I'll push a new release of seesaw this weekend to isolate the issue.
It seems like a clj-ns-browser release with the new seesaw version
would then be appropriate.

Nelson pointed this issue out to me a while ago, but 1.5 seemed so far
off at the time. Sorry about the pain.

Dave

On Sat, Mar 2, 2013 at 2:17 PM, Frank Siebenlist
frank.siebenl...@gmail.com wrote:
 ...
 The chain causing problems for you is:

 [clj-ns-browser 1.3.0] - [seesaw 1.4.2] - [j18n 1.0.1] -
 [org.clojure/clojure [1.2,1.5)]

 The last one there allows clojure below 1.5, which includes -RC17.  As
 soon as you bump to to 1.5 it ignores the soft version in your
 :dependencies, and chooses one in the range based on your other
 dependencies.

 You should just need the :exclusion in clj-ns-browser.

 -
 Nelson Morris

 As i'm responsible for the clj-ns-browser release...
 And although the dependency issue seems another 2 levels down, can i specify 
 anything differently in my project file to prevent this?

 Or is this a bug in leiningen's dependency resolution?

 Or both...

 Regards, Frank.

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



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

2013-03-02 Thread Dave Ray
 As i'm responsible for the clj-ns-browser release...
 And although the dependency issue seems another 2 levels down, can i specify 
 anything differently in my project file to prevent this?

 You could add the a similar exclusion for org.clojure/clojure in the
 seesaw dependency declaration, but I'd just wait for the next seesaw
 release which will handle it.

Seesaw 1.4.3 is released and addresses this issue. Release notes here:
https://github.com/daveray/seesaw/wiki/Release-Notes

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.




ANN: Seesaw 1.4.3 release

2013-03-02 Thread Dave Ray
Hi,

Since it's been a while, thought I'd mention that Seesaw 1.4.3 was
just released. You can find release notes here:

  https://github.com/daveray/seesaw/wiki/Release-Notes

Mostly just small maintenance issues.

The one good reason to upgrade is if you're planning on using Clojure
1.5 and don't feel like being confused by the horrors of Maven
dependency resolution. More information here [1] and here [2].

Cheers,

Dave

[1] https://github.com/daveray/seesaw/issues/102
[2] https://groups.google.com/forum/?fromgroups=#!topic/clojure/kzF5O0Yfdhc

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

2013-01-04 Thread Dave Ray
I don't know if it will answer your history question, but there was a
fairly long discussion about this last year:

  
https://groups.google.com/forum/?fromgroups=#!searchin/clojure/let-else/clojure/1g5dEvIvGYY/EWjwFGnS-rYJ

Cheers,

Dave

On Fri, Jan 4, 2013 at 7:23 AM, Edward Tsech edts...@gmail.com wrote:
 Sorry guys, I forget to mention that it should behave like let in Clojure
 or like let* in Scheme.

 I mean e.g.:
 (if-let* [x 1 y nil z (inc y)]
   (+ x y z)
   0) ; = 0
 ;; (inc y) shouldn't be evaluated here.

 Which means and doesn't work there.
 In terms of implementation I mean smth like that:

 (defmacro if-let*
   ([bindings then]
`(if-let* ~bindings ~then nil))
   ([bindings then else]
(if (seq bindings)
  `(if-let [~(first bindings) ~(second bindings)]
 (if-let* ~(drop 2 bindings) ~then ~else)
 ~else)
  then)))

 But anyway I'm more interested in history of that behavior rather than
 implementation.
 Because for me it seems logical if let support more than two forms
 if-let also could do that.
 And I'd like to understand: Am I wrong or it's just historical reason?

 Ed

 On Friday, January 4, 2013 1:29:41 PM UTC+6, Andy Fingerhut wrote:

 I don't know the history of the answer to why, except perhaps as hinted
 by Evan's answer, which is that it becomes implicit how to combine the
 results of the multiple values to get the final true/false for the if
 condition.  You imply and, which is a perfectly reasonable choice.

 My main reason for responding is to let you know that if you really want
 such behavior, macros let you roll your own without much trouble.

 Andy

 On Jan 3, 2013, at 10:24 PM, Edward Tsech wrote:

 Hey guys,

 if-let and when-let macros support only 2 forms in binding vector:

 (if-let [x 1 y 2]
   ...)
 java.lang.IllegalArgumentExcepdtion: if-let requires exactly 2 forms in
 binding vector(NO_SOURCE_FILE:1)

 Why doesn't if-let support any even amount of binding forms as let
 does?

 e.g.
 (if-let [x 1 y 2 z 3]
   (+ x y z)
   0) ; = 6

 (if-let [x 1 y nil z 3]
   (+ x y z)
   0) ; = 0

 Thanks!


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

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

2012-12-20 Thread Dave Ray
You can avoid superfluous anonymous functions. For example, this:

  (map #(get % :id) my-sequence)

vs this:

  (map :id my-sequence)

Cheers,

Dave


On Thu, Dec 20, 2012 at 3:13 PM, Jonathon McKitrick
jmckitr...@gmail.com wrote:
 I thought it was pretty interesting to treat maps as functions, and even
 more intrigued at treating keywords as functions as well.

 What does this gain from a language design perspective, that you cannot get
 with (get map keyword) or ever (map keyword)?  Why the additional option of
 (keyword 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Little namespace question

2012-12-19 Thread Dave Ray
A function seems to work fine unless I don't understand your requirement:

  ; normal version that takes code forms and symbols
  (defn eval-in
[code ns]
(let [old (- *ns* str symbol)]
  (try
(in-ns ns)
(eval code)
(finally
  (in-ns old)

  ; sugary version that takes strings
  (defn eval-strs [code-str ns-str]
(eval-in (read-string code-str) (symbol ns-str)))

and now try it out:

  user= (eval-strs (def z 500) bar)
  #'bar/z
  user= (in-ns 'bar)
  #Namespace bar
  bar= z
  500

Making this bullet-proof and deciding whether it's actually a good
design is left as an exercise for the reader.

Cheers,

Dave

On Tue, Dec 18, 2012 at 11:22 PM, Alan Shaw noden...@gmail.com wrote:
 As an aside, I'm curious about whether this could have been implemented
 without a macro.

 -A

 On Dec 18, 2012 11:06 PM, Alan Shaw noden...@gmail.com wrote:

 Thanks very much Juan, that's some good study material for me.

 -A

 On Dec 18, 2012 10:45 PM, juan.facorro juan.faco...@gmail.com wrote:

 The macro sees it arguments as symbols and does not resolve to the
 corresponding var until evaluation, so the value for the local code var in
 the macro is actually the symbol generator.

 The eval-in macro uses the read-string function to evaluate the code you
 provide, this function expects a string but it's getting the symbol
 generator instead, since that's what the macro got as a first argument.

 Here's a modified version of the eval-in macro, that delays the
 evaluation of the call to read-string:

 (require '[clojure.pprint :as p])

 (defmacro eval-in
   [code ns]
   `(do
  (in-ns '~(symbol ns))
  (let [ret# (eval (read-string ~code))] ; This line was changed
(in-ns '~(ns-name *ns*))
ret#)))

 (p/pprint (macroexpand '(eval-in generator another-ns)))

 Here's the output:

 (do
  (clojure.core/in-ns 'another-ns)
  (clojure.core/let
   [ret__1879__auto__
(clojure.core/eval (clojure.core/read-string generator))] ; The
 unquoting of code resulted in the symbol generator
   (clojure.core/in-ns 'test-eval)
   ret__1879__auto__))

 If you want to use a var as an argument for the code, you could resolve
 the var before changing namespaces, delaying the read-string until the forms
 evaluation:

 (ns another-ns)

 (defn X [w h] [w h])
 ;---
 (ns this-ns
   (:require [clojure.pprint :as p]))

 (defmacro eval-in
   [code ns]
   `(let [code# ~code]
  (in-ns '~(symbol ns))
   (let [ret# (eval (read-string code#))]
(in-ns '~(ns-name *ns*))
ret#)))

 (def generator (X 300 300))
 (p/pprint (eval-in generator another-ns))

 Hope it helps,

 Juan


 On Wednesday, December 19, 2012 1:13:00 AM UTC-3, nodename wrote:

 From yesterday:

 (defmacro eval-in
   Eval a Clojure form in a different namespace and switch back to
 current namespace.

Args:
code - Clojure form as string
ns - Target namespace as string
   [code ns]
   `(do
  (in-ns '~(symbol ns))
  (let [ret# (eval '~(read-string code))]
(in-ns '~(ns-name *ns*))
ret#)))



 user= (def generator (X 400 400))
 #'user/generator
 user= (def image (eval-in generator
 clevolution.version.version0-1-1))
 CompilerException java.lang.ClassCastException: clojure.lang.Symbol
 cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1)

 user= (def image (eval-in (X 400 400)
 clevolution.version.version0-1-1))
 #'user/image

 So it's OK to pass the explicit string but not the symbol. What am I not
 getting here?

 -A


 On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw node...@gmail.com wrote:

 Now I do, and the macro worked!
 I believe I have a problem using the macro from a function, but leaving
 that for tomorrow.

 Thanks BG!

 -A



 On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose b.g...@gmail.com
 wrote:

 Do you have target ns clevolution.version.version0-1-1 required?

 -BG

 On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw node...@gmail.com wrote:
  BG,
  The macro doesn't seem to do the trick. The function X is interned
  in the
  target namespace, but:
 
  user= (def image (eval-in (X 400 400)
  clevolution.version.version0-1-1))
  CompilerException java.lang.RuntimeException: Unable to resolve
  symbol: X in
  this context, compiling:(NO_SOURCE_PATH:1)
 
 
  On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw node...@gmail.com
  wrote:
 
  Oh yes, the something.something is fixed so I can just prepend it,
  thanks.
  (Hadn't noticed your macro takes the ns as a string!)
 
  -A
 
 
 
  On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose
  b.g...@gmail.com
  wrote:
 
  Alan,
 
  What you're asking for is to derive the ns clojure.core given
  only
  core. Not sure if that's possible.
 
  The namespace constitutes the whole dotted structure and not just
  the
  last component, I am afraid.
 
  If the actual ns is something.something.version-0-1-1, then you
  need
  the string something.something.version-0-1-1 and not just
  version-0-1-1 [unless 

Re: Little namespace question

2012-12-19 Thread Dave Ray
It does, right?

On Wednesday, December 19, 2012, Alan Shaw wrote:

 But returning the evaluation was a requirement...


 On Wed, Dec 19, 2012 at 2:58 PM, Alan Shaw noden...@gmail.com wrote:

 No, there was no requirement that it be a macro. Thanks!

 -A



 On Wed, Dec 19, 2012 at 7:40 AM, Dave Ray dave...@gmail.com wrote:

 A function seems to work fine unless I don't understand your requirement:

   ; normal version that takes code forms and symbols
   (defn eval-in
 [code ns]
 (let [old (- *ns* str symbol)]
   (try
 (in-ns ns)
 (eval code)
 (finally
   (in-ns old)

   ; sugary version that takes strings
   (defn eval-strs [code-str ns-str]
 (eval-in (read-string code-str) (symbol ns-str)))

 and now try it out:

   user= (eval-strs (def z 500) bar)
   #'bar/z
   user= (in-ns 'bar)
   #Namespace bar
   bar= z
   500

 Making this bullet-proof and deciding whether it's actually a good
 design is left as an exercise for the reader.

 Cheers,

 Dave

 On Tue, Dec 18, 2012 at 11:22 PM, Alan Shaw noden...@gmail.com wrote:
  As an aside, I'm curious about whether this could have been implemented
  without a macro.
 
  -A
 
  On Dec 18, 2012 11:06 PM, Alan Shaw noden...@gmail.com wrote:
 
  Thanks very much Juan, that's some good study material for me.
 
  -A
 
  On Dec 18, 2012 10:45 PM, juan.facorro juan.faco...@gmail.com
 wrote:
 
  The macro sees it arguments as symbols and does not resolve to the
  corresponding var until evaluation, so the value for the local code
 var in
  the macro is actually the symbol generator.
 
  The eval-in macro uses the read-string function to evaluate the code
 you
  provide, this function expects a string but it's getting the symbol
  generator instead, since that's what the macro got as a first argument.
 
  Here's a modified version of the eval-in macro, that delays the
  evaluation of the call to read-string:
 
  (require '[clojure.pprint :as p])
 
  (defmacro eval-in
[code ns]
`(do
   (in-ns '~(symbol ns))
   (let [ret# (eval (read-string ~code))] ; This line was changed
 (in-ns '~(ns-name *ns*))
 ret#)))
 
  (p/pprint (macroexpand '(eval-in generator another-ns)))
 
  Here's the output:
 
  (do
   (clojure.core/in-ns 'another-ns)
   (clojure.core/let
[ret__1879__auto__
 (clojure.core/eval (clojure.core/read-string generator))] ; The
  unquoting of code resulted in the symbol generator
(clojure.core/in-ns 'test-eval)
ret__1879__auto__))
 
  If you want to use a var as an argument for the code, you could resolve
  the var before changing namespaces, delaying the read-string until the
 forms
  evaluation:
 
  (ns another-ns)
 
  (defn X [w h] [w h])
  ;---
  (ns this-ns
(:require [clojure.pprint :as p]))
 
  (defmacro eval-in
[code ns]
`(let [code# ~code]
   (in-ns '~(symbol ns))
(let [ret# (eval (read-string code#))]
 (in-ns '~(ns-name *ns*))
 ret#)))
 
  (def generator (X 300 300))



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

2012-12-15 Thread Dave Ray
Yep.

   java -jar clojure.jar hello.clj

Should do the trick. Alternatively,

  java -cp clojure.jar clojure.main hello.clj

Will also work if you need to control the classpath more.

Dave

On Saturday, December 15, 2012, Mark Engelberg wrote:

 Let's say I have a file hello.clj that simply contains the line:
 (println hello, world)

 What's the simplest way to run this clojure file?  I'm looking for
 something simpler than setting up a lein project.  Is there something along
 the lines of:
 java clojure.jar hello.clj
 that would actually 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.comjavascript:_e({}, 'cvml', 
 'clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@googlegroups.com');
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

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

Re: Change the CCW compile output catalog

2012-12-13 Thread Dave Ray
On Thu, Dec 13, 2012 at 12:08 AM, Laurent PETIT laurent.pe...@gmail.com wrote:
Laurent,

 Hey Dave,

 2012/12/3 Dave Ray dave...@gmail.com

 Hey Laurent,

 For what it's worth, I was a little surprised that CCW used it's own
 output folder rather than Eclipse's, but I understand why you'd do it
 that way.

 One thing that was a little problematic was that CCW automatically
 created the folder and added it to the Eclipse classpath when all I
 had done was open a .clj file for editing. I would have expected a
 more explicit enable Clojure support on this project action to be
 required before it starts making changes to the project. Not a big
 deal, but I though I'd share.


 Actually, I think it is CCW's Builder which does that, meaning that
 probably Clojure support is already enabled for your project?

Yep. I must be going crazy because I can't reproduce. Sorry about that :)

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


Re: A bearded person, Clojure and JavaFX

2012-12-05 Thread Dave Ray
Although it's not obvious from the JavaFX docs since they're written
for a Java audience, it is very possible to create apps in an
interactive style without inheritance. Two caveats:

* Ignore the Application class. Just create your scene, etc directly.
* Most execution has to run on the JavaFX thread so everything you do
has to be wrapped in an invoke-now that dispatches the code to that
thread and waits for the result. Swing is much more forgiving on this
front at the expense of allowing a lot of badly threaded code to be
written.

I've captured some of this stuff in upshot
(https://github.com/daveray/upshot) which is on hiatus at the moment
but kind of works at least. There's an example here [1] without an
Application or inheritance in sight.

Cheers,

Dave

[1] 
https://github.com/daveray/upshot/blob/develop/test/upshot/test/examples/example.clj

On Wed, Dec 5, 2012 at 4:08 PM, Stephen Compall
stephen.comp...@gmail.com wrote:
 On Dec 5, 2012 6:38 PM, Christian Sperandio
 christian.speran...@gmail.com wrote:
 And I find that the Clojure code is damaged by the JavaFX inheritance. You
 must write  :gen-class extends to just display a window.

 There are many things in JavaFX for which documentation suggests
 subclassing, but it is entirely reasonable to simply instantiate and call
 methods.  Keep the API docs handy; they are your friend.

 Even if occasionally you run into BuilderFactory or ill-typed lambda
 representations.

 And when I read documentation about bindings, I thought it was complicated
 to make a simple thing (look at watch in clojure). OK, the JavaFX bindings
 work but I feel writing code for writing code.

 Fortunately, Clojure has good tools for writing code for writing code.

 My second bad point for JavaFX, it's about the interactive development. I
 love languages like Groovy and Clojure because you can test the code in a
 console (GroovyConsole or REPL). Can we do that with JavaFX?

 Yes, absolutely.

 My main problem is the following: for launching of your JavaFX
 application, you have to call the start method in your main.

 Spawning a thread to run start is as easy as (future (.start ...)) in
 clojure.  Futures are GC-rooted in Clojure, so you can forget the future if
 you want.

 It blocks the current thread and the REPL waits for closing the window.

 Again, the documented approach is not always best; the API provides tools
 for customizing initialization.

 When I read code like callbackTableColumnPerson, String,XXX,
 sorry but I'm discouraged.

 JavaFX's big problem is that it doesn't use *enough* type parameters,
 really.

 I won't call myself a fan of JFX, though, because as I recall the
 implementation is not yet entirely Free, though most of it is available
 under GPL.  If I am wrong, though, I encourage you to explore it further.

 --
 Stephen Compall
 If anyone in the MSA is online, you should watch this flythrough.

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

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


Re: Change the CCW compile output catalog

2012-12-02 Thread Dave Ray
Hey Laurent,

For what it's worth, I was a little surprised that CCW used it's own
output folder rather than Eclipse's, but I understand why you'd do it
that way.

One thing that was a little problematic was that CCW automatically
created the folder and added it to the Eclipse classpath when all I
had done was open a .clj file for editing. I would have expected a
more explicit enable Clojure support on this project action to be
required before it starts making changes to the project. Not a big
deal, but I though I'd share.

Cheers,

Dave

On Sat, Dec 1, 2012 at 1:04 PM, Laurent PETIT laurent.pe...@gmail.com wrote:
 Hello,

 2012/12/1 Vladimir Tsichevski tsichev...@gmail.com:
 Hi,

 CCW always outputs compiled classes into the classes catalog. AFAIK, this
 name is compiled into CCW and hence cannot be changed. My two questions are:

 1. Why the catalog path is not configurable? Was this made intentionally?

 It is a limitation, for sure, which comes from the past. Will
 eventually go. There's not reason for it to not be configurable, but
 no having dedicated time to do so.

 2. Why this catalog differs from the Java output catalog? Was it made
 intentionally, or it is Ok to put all project output classes to same
 catalog?

 Yes, it is intentional that CCW's output is not in the same folder
 hierarchy as other Java output.
 Indeed, it's not possible (or sufficiently complex to have been
 considered so) to inform Eclipse (which manages java source/classes
 via the JDT - Java Development Tools-) that there are contents in the
 same output as where it compiles classes, and that it would be polite
 not to erase the folder content as if it were under its full control.

 Now, beyond your interesting in understand why things are how they
 are, I'd be interesting in knowing if that's currently getting in your
 way, and if so, try to see  if I can help you find a workaround until
 this is eventually customizable.


 HTH,

 --
 Laurent

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

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


Re: Run Counterclockwise nREPL on specific port

2012-11-20 Thread Dave Ray
 Run: Actually, maybe this makes sense, isn't this a bit like the remote
 connection java launcher ? Several remotes could be saved in different
 launch configurations. Some other configuration options could come up
 quickly, like things to prepend on each launch - via a potential additional
 op to nrepl, etc. This would require creating a specific kind of launch
 configuration.

+1. I think the custom launch config is the idiomatic Eclipse way to
do it. To put it another way, as a long-time Eclipse user, I would
look in the launch configs first if I was going to connect to a remote
repl. Of course, as a long-time Eclipse user, my mind is also
irreparably mutilated.

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


Re: code waiting on something - cannot debug - driving me insane!!!

2012-11-13 Thread Dave Ray
Just a wild guess, but if something's shown on the screen,
#'draw-tiles will probably get invoked to paint the canvas and it
might end up blocking on the #'curr-game promise.

Dave

On Tue, Nov 13, 2012 at 12:19 PM, Jim - FooBar(); jimpil1...@gmail.com wrote:
 Hi all,

 I've had this unbelievable problem for some time now but I'm sick and tired
 of ignoring it! It is literally driving nuts...Due to the nature of the
 problem my terminal hangs and Eclipse crashes altogether (potentially losing
 work)!

 So what is the problem...Well I really don't have a clue! it is pretty
 obvious that my code is waiting on something but it only happens when I've
 got a dependency on a namespace of mine which uses seesaw. It is basically
 my gui...the bad behaviour is exhibited every time I try to reload my
 namespace after having opened a JFrame regardless of having done anything on
 the frame! I mean the same happens if I open it and close it straight after!

 anyway, I managed to mock the behaviour with a minimal example:
 -

 (ns Clondie24.games.dummy
   (:require [Clondie24.lib.gui :as gui]))

 (def details {:name 'Dummy
   :players 2
   :arena-size [420 :by 505]
   :tile-size 133})

 (defn -main
 Starts a graphical (swing) Chess game.
 [ args]
 (gui/show-gui! details))


 (ns Clondie24.lib.gui
 (:require [Clondie24.lib.util :as ut]
   [Clondie24.lib.core :as core]
   [seesaw.core :as ssw]
   [seesaw.chooser :as choo])
 (:import  [java.awt AlphaComposite Graphics Graphics2D Toolkit]
   [java.awt.event MouseEvent]
   [javax.swing SwingWorker UIManager]) )

 (def curr-game (promise))
 (def status-label (ssw/label :id :status :text Ready!))

 (defn draw-tiles [d ^Graphics g]
   (let [w (ssw/width d)
 h (ssw/height d)
 tile-size (:tile-size @curr-game)
 tiles (map vector (for [x (range 0 w tile-size)
 y (range 0 h tile-size)] [x y])
   (cycle (:alternating-colours @curr-game)))]
 (when (:alternating-colours @curr-game)
   (doseq [[[x y] c] tiles]
(.setColor g c)
(.fillRect g x y tile-size tile-size)) )
  (draw-grid d g)
  (draw-images g)
  (highlight-rects g)))

 (def canvas The paintable canvas - our board
  (ssw/canvas
 :paint draw-tiles
 :id :canvas
 :listen [:mouse-clicked (fn [e] (when-not (and (:block? @knobs)
  (realized? curr-game))
   (canva-react e)))]
 ))

 (defn arena Constructs and returns the entire arena frame. []
  (ssw/frame
 :title Clondie24 Arena
 :size  (:arena-size @curr-game)
 :resizable? false
 :on-close :exit
 :menubar  nil ;(make-menubar)
 :content  (ssw/border-panel
:border 10
:hgap 10
:vgap 10 ;;IGNORE ALL THIS FOLLOWING CODE TO SAVE TIME
:north  (ssw/horizontal-panel :items
[(ssw/button :text Undo  :listen [:action (fn [e]
 (when-not (:block? @knobs)
 (do (refresh :highlighting? false
 :hint nil)
 (undo!) (ssw/repaint! canvas]) [:fill-h 10]
 (ssw/button :text Clear :listen [:action (fn [e]
 (when-not (:block? @knobs)
 (do (refresh :highlighting? false
 :hint nil)
 (clear!) (ssw/repaint! canvas]) [:fill-h 10]
 (ssw/button :text Available Moves :listen [:action
 (fn [e] (when-not (:block? @knobs)
 (do (refresh
 :highlighting? true
 :hint nil)
 (ssw/repaint! canvas]) [:fill-h 10]
 (ssw/button :text Hint :listen [:action (fn [e]
 (when-not (:block? @knobs)
  (do (knob!
 :highlighting? false)
 (with-busy-cursor canvas
   (hint (:pref-depth
 @curr-game)) :hint]) [:fill-h 10]])
:center canvas
:south  status-label)))


 (defn show-gui! Everything starts from here. [game-map]
   (deliver curr-game game-map) ;firstly make the gui aware of what game we
 want it to display
(ssw/invoke-later
  (doto (arena) ssw/show!)))

 ---

 any thoughts / feedback are greatly welcome. I cannot see why such a
 standard setup would hang after trying to reload the dummy namespace.
 everything reloads just fine as long as i don't show anything on
 screen...scary stuff!

 thanks in advance...

 Jim



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

Re: code waiting on something - cannot debug - driving me insane!!!

2012-11-13 Thread Dave Ray
Dump the JVM's threads [1] and see what it's stuck on?

Dave

[1] http://www.crazysquirrel.com/computing/java/basics/java-thread-dump.jspx

On Tue, Nov 13, 2012 at 1:42 PM, Jim - FooBar(); jimpil1...@gmail.com wrote:
 On 13/11/12 20:36, Dave Ray wrote:

 Just a wild guess, but if something's shown on the screen,
 #'draw-tiles will probably get invoked to paint the canvas and it
 might end up blocking on the #'curr-game promise.

 thanks for your response Dave,

 even though I'm not entirely sure what you mean, I can confirm that the
 promise is not to blame...I replaced it with an atom and the same thing
 happened...Delivering the promise is the very 1st thing happening so I can't
 see how it might be blocking...also, the canvas does not react unless the
 promise has been realized. After closing the gui I can't do anything on the
 dummy namespace...it hangs indefinately...

 any other thoughts? I am quite desperate here...

 Jim

 ps: thanks Laurent, I'll check out the stable release on Thursday. The
 problem is that I'm not getting any exceptions so I'm not sure to much
 extent  the eclipse debugger can help me.

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

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

2012-11-07 Thread Dave Ray
There aren't any problems with with-open/doseq/line-seq. The issue is
with with-open/line-seq. For example, it's instinctive (at least for
me anyway) to want to write a function like this:

(defn get-records [file-name]
  (with-open [r (reader file-name)]
(line-seq r)))

Of course, the problem here is that the lazy sequence escapes the
with-open scope and you get an exception when you start consuming it.
And given a sequence there's no mechanism to say I'm done with you,
clean up any resources you may be using.

That's the crux of it for me anyway. It seems like the simplest
approach is to just adjust my instincts and always make sure the
sequence is fully consumed within the with-open.

Cheers,

Dave

On Wed, Nov 7, 2012 at 10:56 AM, Jim - FooBar(); jimpil1...@gmail.com wrote:
 I know I'm coming a bit late in this thread but i did not have the chance to
 reply earlier...

 Can somebody elaborate briefly what is the problem with the combination of
 with-open/doseq/line-seq? In a project of mine I'm dealing with files larger
 than 200MB (which of course will not even open on a regular text-editor) and
 I've been happily using with-open/doseq/line-seq with great success...As
 Stuart pointed out as long as the entire processing happens within a
 'with-open' all is good and this is the approach I'm always following with
 no memory issues...What am I missing? What exactly do you mean by close the
 file? Do you mean close the clojure.java.io/reader? which happens
 implicitly when a with-open exits? I've also not understood what the
 original problem is...Has anyone had problems with large files?

 sorry for the inconvenience...I read the entire thread and I'm still not
 understanding!

 Jim



 On 29/10/12 03:21, Dave Ray wrote:

 Stuart,

 Thanks for the link. It confirms the suspicions I had about a general
 solution for this issue. For the particular code I'm working with,
 I'll try pushing with-open further up and see if that gives me some of
 the flexibility I'm looking for.

 Cheers,

 Dave

 On Sun, Oct 28, 2012 at 2:21 PM, Stuart Sierra
 the.stuart.sie...@gmail.com wrote:

 On Friday, October 26, 2012 11:11:48 PM UTC-4, daveray wrote:

 I guess I looking for a magical line-seq that closes the file correctly
 even if you consume part of the sequence, is resilient to exceptions,
 etc, etc. I realize that it might be impossible, so I asked. :)


 It's been discussed extensively in the past, but no one has come up with
 a
 solution that adequately solves the general problem. See
 http://dev.clojure.org/display/design/Resource+Scopes for examples of
 some
 attempts.

 The best approach I've found is to manage resources like files farther up
 the stack. Instead of having a 'with-open' block that returns a sequence,
 put the 'with-open' block at a higher level, so that it encompasses the
 entire scope in which the file will be used.

 -S

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


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

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

2012-10-28 Thread Dave Ray
Stuart,

Thanks for the link. It confirms the suspicions I had about a general
solution for this issue. For the particular code I'm working with,
I'll try pushing with-open further up and see if that gives me some of
the flexibility I'm looking for.

Cheers,

Dave

On Sun, Oct 28, 2012 at 2:21 PM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 On Friday, October 26, 2012 11:11:48 PM UTC-4, daveray wrote:

 I guess I looking for a magical line-seq that closes the file correctly
 even if you consume part of the sequence, is resilient to exceptions,
 etc, etc. I realize that it might be impossible, so I asked. :)


 It's been discussed extensively in the past, but no one has come up with a
 solution that adequately solves the general problem. See
 http://dev.clojure.org/display/design/Resource+Scopes for examples of some
 attempts.

 The best approach I've found is to manage resources like files farther up
 the stack. Instead of having a 'with-open' block that returns a sequence,
 put the 'with-open' block at a higher level, so that it encompasses the
 entire scope in which the file will be used.

 -S

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

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


with-open and line-seq

2012-10-26 Thread Dave Ray
Hi,

At work I've had a few conversations about treating files, especially
large ones, as seqs of lines. In particular, the apparent conflict
between using clojure.core/with-open to ensure a file is closed
appropriately, and clojure.core/line-seq as a generic sequence of
lines which may be consumed by code that has no idea it's coming from
a file. I've been told [1] that C# solves this problem because the
IEnumerator interface is disposable so it's possible to clean up the
underlying file, even if it's been wrapped in several layers of
enumerators... and that since Clojure doesn't do this, it's flawed :)

Thoughs? I'm aware of the custom seq that closes the file when the
end is reached hack, but that doesn't seem very satisfying. How do
others process large files in Clojure? Just make sure that the
sequence is totally consumed within with-open? Just don't worry about
closing files?

Cheers,

Dave


[1] My C# experience is limited to a few days of writing example code
for the C# bindings of a product's API. :)

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


Re: with-open and line-seq

2012-10-26 Thread Dave Ray
Andy,

That's the custom seq that closes the file... I was referring to. I
guess I looking for a magical line-seq that closes the file correctly
even if you consume part of the sequence, is resilient to exceptions,
etc, etc. I realize that it might be impossible, so I asked. :)

Thanks,

Dave

On Fri, Oct 26, 2012 at 7:10 PM, Andy Fingerhut
andy.finger...@gmail.com wrote:
 Devin, did you mean read-line from the old clojure.contrib.io?

 http://clojuredocs.org/clojure_contrib/clojure.contrib.io/read-lines

 Click the + symbol next to Source to see source code, also available here:

 https://github.com/richhickey/clojure-contrib/blob/061f3d5b45657a89faa335ffa2bb80819f2e6918/src/main/clojure/clojure/contrib/io.clj#L302

 Andy

 On Oct 26, 2012, at 5:23 PM, Devin Walters wrote:

 I usually wind up with the line-seq from old contrib. Could you be more 
 clear about what isn't satisfying about that? For me it usually boils down 
 to: it's unsatisfying that core line-seq doesn't do that by default.

 '(Devin Walters)

 On Oct 26, 2012, at 6:45 PM, Dave Ray dave...@gmail.com wrote:

 Hi,

 At work I've had a few conversations about treating files, especially
 large ones, as seqs of lines. In particular, the apparent conflict
 between using clojure.core/with-open to ensure a file is closed
 appropriately, and clojure.core/line-seq as a generic sequence of
 lines which may be consumed by code that has no idea it's coming from
 a file. I've been told [1] that C# solves this problem because the
 IEnumerator interface is disposable so it's possible to clean up the
 underlying file, even if it's been wrapped in several layers of
 enumerators... and that since Clojure doesn't do this, it's flawed :)

 Thoughs? I'm aware of the custom seq that closes the file when the
 end is reached hack, but that doesn't seem very satisfying. How do
 others process large files in Clojure? Just make sure that the
 sequence is totally consumed within with-open? Just don't worry about
 closing files?

 Cheers,

 Dave


 [1] My C# experience is limited to a few days of writing example code
 for the C# bindings of a product's API. :)

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

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

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

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


Re: Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath

2012-10-25 Thread Dave Ray
Why don't you have clojure.data.json in your dependencies in
project.clj? That seems like a problem to me.

Dave

On Thu, Oct 25, 2012 at 10:01 AM, larry google groups
lawrencecloj...@gmail.com wrote:
 I asked this previously but I thought I would start a new thread to go into
 more detail. This is driving me crazy. I was using json in my app and
 everything was working great. Then I did something, but I don't know what.
 Now it is broken.

 My project.clj is:

 (defproject who-is-logged-in 1.1
   :description When users arrive 
   :dependencies [
  [org.clojure/clojure 1.3.0]
  [net.cgrand/moustache 1.1.0]
  [ring 1.1.5]
  [ring/ring-jetty-adapter 1.1.5]
  ]
   :main who-is-logged-in.core
   :jvm-opts [-Xmx1000m])


 and the top of core.clj looks like this:

 (ns who-is-logged-in.core
   (:gen-class)
   (:import (java.util Date)
(java.io File))
   (:require clojure.string clojure.java.io who-is-logged-in.memory_display
 [clojure.data.json :as json])
   (:use   [net.cgrand.moustache :only [app delegate]]
   [ring.util.response]
   [ring.middleware.params]
   [ring.adapter.jetty :only [run-jetty]]))

 I run lein deps and then lein compile. I get this error:

 Exception in thread main java.io.FileNotFoundException: Could not locate
 clojure/data/json__init.class or clojure/data/json.clj on classpath: ,
 compiling:(core.clj:1)
 at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3342)
 at clojure.lang.Compiler.compile1(Compiler.java:6985)
 at clojure.lang.Compiler.compile1(Compiler.java:6975)
 at clojure.lang.Compiler.compile(Compiler.java:7046)
 at clojure.lang.RT.compile(RT.java:385)
 at clojure.lang.RT.load(RT.java:425)
 at clojure.lang.RT.load(RT.java:398)
 at clojure.core$load$fn__4610.invoke(core.clj:5386)
 at clojure.core$load.doInvoke(core.clj:5385)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.core$load_one.invoke(core.clj:5200)
 at clojure.core$compile$fn__4615.invoke(core.clj:5397)
 at clojure.core$compile.invoke(core.clj:5396)
 at user$eval27.invoke(NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:6465)
 at clojure.lang.Compiler.eval(Compiler.java:6455)
 at clojure.lang.Compiler.eval(Compiler.java:6431)
 at clojure.core$eval.invoke(core.clj:2795)
 at clojure.main$eval_opt.invoke(main.clj:296)
 at clojure.main$initialize.invoke(main.clj:315)
 at clojure.main$null_opt.invoke(main.clj:348)
 at clojure.main$main.doInvoke(main.clj:426)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.main.main(main.java:37)
 Caused by: java.io.FileNotFoundException: Could not locate
 clojure/data/json__init.class or clojure/data/json.clj on classpath:


 Like I said, this was working, and now it is broken. Can anyone guess why?









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

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


Re: Calling name on a keyword gives nil??

2012-10-22 Thread Dave Ray
The name parameter of your function is shadowing clojure.core/name.

On Mon, Oct 22, 2012 at 7:58 AM, JvJ kfjwhee...@gmail.com wrote:
 I'm getting a REALLY weird error.  I'm trying to check if a set of keywords
 are all uppercase.
 When binding a value to 'res' in the let statement, I traverse a list of
 keywords.  However, the calls to the name function on those
 keywords give nil.  The debug print statement clearly shows that the class
 of k is a keyword, and yet its name is nil?

 I really don't get it.


 ;; Program
 (defn defrel-fn
   Adds a relation definition to the *relations* map.
   [name keys]
   (let [res (every? (fn [k]
   (println k:  (name k) ,  (class k)) ;; Added for
 debugging
   (= (name k) (.toUpperCase (name k  keys)
 ;; keys need to be all in uppercase letters!
 ;;_ (when-not res (throw (Exception. Error.  All keys must be
 upper-case.)))
 kns (apply hash-map (mapcat vector keys (range))) ;; represents a
 map of keys to indices
 ]
 (swap! *relations*
assoc name {:fields kns
:unfields (vec keys) ;; A map of indices to keys is
 best represented as a vector
})))

 ;; Output from repl
 = (worldrep.core/defrel-fn 'mother [:SELF :CHILD])
 k:  nil ,  clojure.lang.Keyword
 NullPointerException   clojure.lang.Reflector.invokeNoArgInstanceMember
 (Reflector.java:314)

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

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


Re: Simple way to get image from url

2012-10-15 Thread Dave Ray
Something like this perhaps:

(with-open [in (clojure.java.io/input-stream http://google.com/favicon.ico;)]
  (clojure.java.io/copy in (clojure.java.io/file favicon.ico)))

Dave

On Mon, Oct 15, 2012 at 6:23 AM, AtKaaZ atk...@gmail.com wrote:
 = (use 'clj-http.client)
 nil
 = (= (:body (clj-http.client/get http://google.com/favicon.ico; {:as
 :steam})) (slurp http://google.com/favicon.ico;))
 true

 or if you want to save it locally as a file(thanks Apage43):
 = (with-open [bodystream (:body (clj-http.client/get
 http://google.com/favicon.ico; {:as :stream}))]
  (clojure.java.io/copy bodystream (clojure.java.io/file
 google_favicon.ico)))
 nil


 On Mon, Oct 15, 2012 at 12:29 PM, Andreas Liljeqvist bon...@gmail.com
 wrote:

 Haven't got access to my tools, but couldn't you just slurp it?

 (slurp http://somesite/picture.jpg;)

 On Mon, Oct 15, 2012 at 11:08 AM, dennis zhuang killme2...@gmail.com
 wrote:

 I think you can use clj-http:
 https://github.com/dakrone/clj-http

 (client/get http://site.com/favicon.ico; {:as :byte-array})



 2012/10/15 Yakovlev Roman felix...@gmail.com

 Hi
 I am pretty new to java world so as i found there is no simple way to
 get image file from url like : http://example.com/image.jpg.
 What i need just to get file from url and store it to db.
 So we need to use buffer, stream and stuff to get file. I found this
 code but i guess there is a way to get things simplier.

 (defn fetch-data [url]
   (let  [con(- url java.net.URL. .openConnection)
  fields (reduce (fn [h v]
   (assoc h (.getKey v) (into [] (.getValue v
 {} (.getHeaderFields con))
  size   (first (fields Content-Length))
  in (java.io.BufferedInputStream. (.getInputStream con))
  out(java.io.BufferedOutputStream.
  (java.io.FileOutputStream. out.file)) ; Here is our
 file
  buffer (make-array Byte/TYPE 1024)]

 ; Not sure about that loop it's just prints size to repl if we don't
 need that we can omit that part i guess

 (loop [g (.read in buffer)
r 0]
   (if-not (= g -1)
 (do
   (println r / size)
   (.write out buffer 0 g)
   (recur (.read in buffer) (+ r g)

 (.close in)
 (.close out)
 (.disconnect con)))

 (fetch-data http://google.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




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



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


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


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

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


Bug in printing futures

2012-10-11 Thread Dave Ray
In Clojure 1.4, I came across the following this week:

  user= (def f (future (Thread/sleep 2)))
  #'user/f
  user= f
  #core$future_call$reify__6110@27adc5f7: :pending
  user= (future-cancel f)
  true
  user= f
  CancellationException   java.util.concurrent.FutureTask$Sync.innerGet
(FutureTask.java:220)

That is, when printing a future, the cancellation state isn't checked for
resulting in an exception when Future.get() is called. It's more annoying
when the future is part of a larger data structure.

Cheers,

Dave

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

Question about Seesaw breaking change

2012-09-13 Thread Dave Ray
Hi,

Over on the Seesaw list, there's a little question about a possible
breaking change to the way selection works:

  https://groups.google.com/forum/?fromgroups=#!topic/seesaw-clj/qJe7RElZmYw

Thought I'd mention it here in case anyone wants to object.

Cheers,

Dave

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

Re: How do I get the total memory used by the app?

2012-09-12 Thread Dave Ray
You can connect jconsole or visualvm to your running app to monitor memory
usage, GC, threads, etc, etc. On my machine, jconsole lives in
$JAVA_HOME/bin/jconsole.

Cheers,

Dave

On Wed, Sep 12, 2012 at 10:12 AM, larry google groups 
lawrencecloj...@gmail.com wrote:

 I need to know how much memory my app is using (it is a long running
 service). I see that some people have asked about how to measue memory use.
 Robert McIntyre asked, get the total memory used by a data structure?
 Some of the answers imply that it is easy to get the total memory use of
 the app (much easier than getting the memory used by a particular data
 structure?). I am ignorant of the JVM. How can I find the total memory used
 at any given moment by my app?

 Goal: I wrote a small app that uses Ring and Moustache and Enlive. It
 lives on my server and runs perpetually. I worry about it crashing, or
 becoming overloaded. I am setting up some ping services (not sure which
 yet, Nagios, or Puppet or something) to ask the app Are you still alive?
 I've established a special Moustache route just for the ping. It occurred
 to me that the ping could get some useful info, like memory, and save that
 to a file. That would give me the a good time series about the real world
 memory use, maybe every 5 minutes.

 I established the app with this JVM setting:

  :jvm-opts [-Xmx4000m]

 Within that limit, I'd like to know what is going on.

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

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

Re: clojure library code fails to load resource file when called from java

2012-09-07 Thread Dave Ray
slurp is happy to slurp from a URL, no need for the (.getFile) call on
the resource. In other words, the file returned for a resource that's
been compiled into a jar isn't very useful. Stick with the URL
returned bye clojure.java.io/resource.

Dave

On Fri, Sep 7, 2012 at 10:58 AM, fenton fenton.trav...@gmail.com wrote:
 https://github.com/ftravers/PublicDocumentation/blob/master/clojure/resource-file.md


 Reading a resource file

 File/directory layout:

 $ tree
 .
 |-- pom.xml
 |-- project.clj
 |-- README.md
 `-- src
 |-- test_project
 |   `-- Core.clj
 `-- test.txt

 Setting up this to be a library for use in Java. Here is my project.clj and
 my Core.clj

 (defproject test-package/test-project 0.1.0-SNAPSHOT
   :plugins [[lein-swank 1.4.4]]
   :dependencies [[org.clojure/clojure 1.4.0]]
   :main test-project.Core)

 (ns test-project.Core
   (:gen-class
:methods [[readFile [] String]]))
 (defn read-file []
   (slurp (.getFile (clojure.java.io/resource test.txt
 (defn -readFile [this]
   (read-file))

 Now if I try to use this in the REPL

 test-project.Core (read-file)
 abc\n

 Works no problem. However when I try this from Java:

 Core c = new Core();
 c.readFile();

 A FileNotFound exception is thrown:

 java.io.FileNotFoundException:
 /home/fenton/.m2/repository/test-package/test-project/0.1.0-SNAPSHOT/test-project-0.1.0-SNAPSHOT.jar!/test.txt
 (No such file or directory)

 Whereas:

 InputStream stream =
 this.getClass().getClassLoader().getResourceAsStream(test.txt);

 Finds the file no problem. So whats the problem?

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

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

2012-08-31 Thread Dave Ray
Thanks Kevin and Laurent for the suggestions! It's too bad these
aren't higher in google results for clojure classloader. My current
approach is essentially the same as Classlojure so at least I wasn't
totally in the weeds.

Cheers,

Dave

On Thu, Aug 30, 2012 at 11:35 PM, Laurent PETIT laurent.pe...@gmail.com wrote:
 Hi,

 Currently, counterclockwise is using classlojure to maintain separate
 Leiningen environments for separate open projects.

 HTH,

 Laurent

 Sent from a smartphone, please excuse the brevity/typos.

 Le 31 août 2012 à 03:38, Dave Ray dave...@gmail.com a écrit :

 Hi,

 I'm looking for the best way to execute some Clojure code in a more or
 less completely isolated environment. That is, say we load one piece
 of code:

 A:
 ---
 (ns my-ns)

 (def foo [] (println hi))

 (foo)
 ---

 if a second piece of code was loaded:

 B:
 ---
 (ns my-ns)

 (foo) ; -- This should fail
 ---

 the reference to foo would fail because they're two completely
 different environments.

 What seems to be foiling this goal is the static global
 clojure.lang.Namespace.namespaces. Even if I compile the code in
 separate class loaders, the namespace map is still shared.

 The best solution I've come up with so far is just to load the Clojure
 jar in its own class loader so there's no chance of different
 environments messing with each other through the global namespace
 table. It also means loading multiple copies of Clojure.

 I've looked a bit at the tryclojure/clojail approach of restricting
 access to (in-ns), (ns), etc and just generating a unique namespace
 for each piece of code. That may be an easier approach at the risk of
 the code being less isolated.

 This is being integrated into a larger, existing framework, which is
 where the isolation requirements come from.

 Thoughts?

 Thanks,

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

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


Isolated Clojure Environments

2012-08-30 Thread Dave Ray
Hi,

I'm looking for the best way to execute some Clojure code in a more or
less completely isolated environment. That is, say we load one piece
of code:

A:
---
(ns my-ns)

(def foo [] (println hi))

(foo)
---

if a second piece of code was loaded:

B:
---
(ns my-ns)

(foo) ; -- This should fail
---

the reference to foo would fail because they're two completely
different environments.

What seems to be foiling this goal is the static global
clojure.lang.Namespace.namespaces. Even if I compile the code in
separate class loaders, the namespace map is still shared.

The best solution I've come up with so far is just to load the Clojure
jar in its own class loader so there's no chance of different
environments messing with each other through the global namespace
table. It also means loading multiple copies of Clojure.

I've looked a bit at the tryclojure/clojail approach of restricting
access to (in-ns), (ns), etc and just generating a unique namespace
for each piece of code. That may be an easier approach at the risk of
the code being less isolated.

This is being integrated into a larger, existing framework, which is
where the isolation requirements come from.

Thoughts?

Thanks,

Dave

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


Re: having trouble setting the cursor with seesaw

2012-08-26 Thread Dave Ray
Hi,

It's probably better to ask on the seesaw mailing list [1] rather than
this more general list.

With the info you've given it's hard to tell, but I'd guess you're
setting the cursor and then doing a long-running operation in the UI
thread. When you do that, the cursor (and ui) is never updated. You'll
have to move the operation to another thread. Here's a rough sketch:

(do
  ; Set the cursor on the ui thread
  (seesaw/config! canvas :cursor :wait)
  (future
  (... something that takes a while on another thread ...)
  (invoke-later
 ; now restore the cursor on the ui thread.
(seesaw/config! canvas :cursor :default

regards,
dave

[1] https://groups.google.com/forum/?fromgroups#!forum/seesaw-clj

On Sun, Aug 26, 2012 at 7:17 AM, Jim - FooBar(); jimpil1...@gmail.com wrote:
 another question...why won't this do anything?

 (seesaw/config! canvas :cursor :wait) ;;canvas is a result of (seesaw/canvas
 ... ... ...)

 I also tried

 (seesaw/config! (seesaw/to-root canvas) :cursor :wait)

 but the proxied JFrame does not support the :cursor option!

 what am I missing?

 thanks
 Jim


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

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

2012-07-25 Thread Dave Ray
For what it's worth, the docstrings are indeed hand-formatted, but that's
pretty easy with vim or any decent editor. The size of the docstrings is a
bit of a problem. At one point on Twitter Fogus suggested that Trammel
could help off-load documentation elsewhere, but I never was motivated
enough to pursue it.

Cheers,
Dave

On Wednesday, July 25, 2012, Laurent PETIT wrote:



 2012/7/25 Dimitrios Jim Piliouras jimpil1...@gmail.comjavascript:_e({}, 
 'cvml', 'jimpil1...@gmail.com');
 

 ooo thanks Tassilo...I knew that the docstring is stored as metadata but
 I did not know I could mutate it after the binding is set..this is very
 cool on its own!

 As far as IDEs go i will have a look around even though i was quite happy
 with my minimal setup...I also tend to use clooj when on the road which is
 steadily getting better...I gave ccw several chances as I was totally in
 love with eclipse in my java days, but even though I do like the editor and
 all the clever things it can do, I still cannot get my head round how to
 work efficiently on the eclipse repl...I specifically remember spawning a
 new repl every time i was loading a namespace which seemed very odd cos i
 had to close them all at the end...


 Then by all means give ccw another try


 emacs on the other hand seems more like a religion rather than an
 editor!!! The thing is my timetable atm does not allow any deviations and
 it would big deviation if i was to decide to learn emacs any time soon

 thank you both for your precious time and suggestions... cheers!

 Jim


 On Wed, Jul 25, 2012 at 4:02 PM, Laurent PETIT laurent.pe...@gmail.comwrote:



 2012/7/25 Dimitrios Jim Piliouras jimpil1...@gmail.com

 Hmmm I see...you're saying that this is all due to my minimalistic repl
 enviroment (raw terminal embedded in gedit + leiningen2)...I know eclipse
 does folding and stuff but what about when you want to hit enter to break
 a line and then you want to align some other sentence underneath? will it
 show on the raw terminal exactly as it shows on the eclipse text-editor?
 I'm asking because in gedit the only way i can predict where things go is
 whenever i have a continuous string (no line breaks)...


 tbh, Counterclockwise does not yet have folding (tho it is a WIP in a
 contributor's branch I haven't yet had the time to review - shame on me)




 Jim




 On Wed, Jul 25, 2012 at 12:17 PM, Laurent PETIT 
 laurent.pe...@gmail.comwrote:

 2012/7/25 Dimitrios Jim Piliouras jimpil1...@gmail.com

 Hi all,

 I've just watched Dave Ray's mini demo of seesaw on infoQ and what amazed
 me (apart from the actual library) was the gorgeous documentation that is
 attached to all the functions. Dave has done an amazing job - even though
 it is essentially a swing wrapper you can get a lot done without knowing
 any swing at all!!! This is pretty good stuff...I was wondering if there is
 an easier way to generate docstrings like that without alligning spaces and
 tab manuallys and more importantly without inlining them with the
 functions.  I know it sounds a bit silly but if your source code is
 dominated by docs then it is really hard to navigate up and down...I am
 generally trying to keep my docs minimal with only plain english and rarely
 more than 3-4 lines. However, after seeing what Dave has done I feel rather
 jealous! Whenever I tried to produce docs like his the result is rather
 ugly unless i systematically fiddle with it through trial and error...So in
 essence 2 questions:

 -Is there a way write the docs in a separate place (different section of
 the document or different document altogether)?
 -Is there another way to style your documentation text other than manual
 evolutionary means (trial and error)?


 Third option : use an editor/IDE which allows you to fold docs (one by
 one / fold all / unfold all), and / or to navigate in your source code via
 code outlines



 Just in case Dave is lurking around,
 -You actually wrote and styled  all that documentation by hand?


 Jim

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


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

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

Re: scanLeft

2012-06-11 Thread Dave Ray
Try reductions:

  user= (reductions + 0 [1 2 3])
  (0 1 3 6)

Dave

On Mon, Jun 11, 2012 at 5:51 PM, Andy Coolware andy.coolw...@gmail.com wrote:
 Hi,

 I am looking for a way to express following function in Clojure:
 scala scanLeft(List(1,2,3))(0)(_ + _)
 res1: List[Int] = List(0, 1, 3, 6)

 Any insight?
 Andy ...

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

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

2012-05-31 Thread Dave Ray
Lacij (https://github.com/pallix/lacij) and Vijual
(https://github.com/drcode/vijual) both implement graph layout
algorithms in Clojure.

Dave

On Thu, May 31, 2012 at 6:42 AM, Ulises ulises.cerv...@gmail.com wrote:
 I have a contest going with a colleague, where we each have to render a
 network layout in SVG.  My gut says that Synthetic Annealing is the right
 tool for the job here.

 I haven't heard of synthetic annealing (I have heard of simulated
 annealing though) but if you're looking to draw a network of nodes and
 to have them self-organise on a 2D space force-directed graphs are a
 pretty nifty technique for that, see an example with d3 (don't know if
 these graphs are available in d2 thought):
 http://mbostock.github.com/d3/ex/force.html

 U

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

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


Re: using - on a nested hash-map with string keywords.

2012-05-31 Thread Dave Ray
Keywords implement IFn meaning they can act as functions that look
themselves up in a map. Strings are just strings. Replace b with
(get b) and you'll get the behavior you're looking for.

Dave

On Thu, May 31, 2012 at 7:55 AM, Boris V. Schmid boris.sch...@gmail.com wrote:
 Can someone tell me what I'm overlooking (clojure 1.4)

 (- (hash-map :b (hash-map :a 3)) :b :a)
 3
 user (- (hash-map b (hash-map :a 3)) b :a)
 ; Evaluation aborted: java.lang.String cannot be cast to clojure.lang.IFn

 I'm not sure why the first can work, and the second cannot. Is it a logical
 limitation of the language, or an oversight in how the macro - is build?

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

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


Re: using - on a nested hash-map with string keywords.

2012-05-31 Thread Dave Ray
Too true.

On Thu, May 31, 2012 at 10:22 AM, Alan Malloy a...@malloys.org wrote:
 Yes, but really to GET a value nested IN a series of maps, he should
 just be using get-in, rather than threading anything at all.

 On May 31, 7:59 am, Dave Ray dave...@gmail.com wrote:
 Keywords implement IFn meaning they can act as functions that look
 themselves up in a map. Strings are just strings. Replace b with
 (get b) and you'll get the behavior you're looking for.

 Dave

 On Thu, May 31, 2012 at 7:55 AM, Boris V. Schmid boris.sch...@gmail.com 
 wrote:







  Can someone tell me what I'm overlooking (clojure 1.4)

  (- (hash-map :b (hash-map :a 3)) :b :a)
  3
  user (- (hash-map b (hash-map :a 3)) b :a)
  ; Evaluation aborted: java.lang.String cannot be cast to clojure.lang.IFn

  I'm not sure why the first can work, and the second cannot. Is it a logical
  limitation of the language, or an oversight in how the macro - is build?

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

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

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


Re: ClassCastException clojure.lang.Var$Unbound Help

2012-04-30 Thread Dave Ray
I think what you actually want is:

(defn get-id []
  (session/get :uid))

in your code, you're trying to call #'session/get directly and bind it
to get-id. Of course, the problem with this is that #'session/get
expects to be called in the context of a request which is where your
Unbound var exception is coming from.

Hope this helps,

Dave

On Mon, Apr 30, 2012 at 11:39 AM, Travis Smith tra...@legomaster.net wrote:
 What does 'java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be
 cast to clojure.lang.IDeref' mean. I'm getting this a lot and I want to
 understand it better, make it easier for me to avoid this. Most of the time
 I just end up adjusting my def/defn's around until it works. This is hardly
 optimal.

 (this is all on clojure 1.3.0)

 An example...

 (ns app-admin.models.current-user
   (:require [noir.session :as session]
             [app-admin.models.users :as users]))

 (def get-id
   (session/get :uid))

 (defn set-user! [user]
   (session/put! :uid {:_id user}))

 Give me an exception for get-id

 ClassCastException clojure.lang.Var$Unbound cannot be cast to
 clojure.lang.IDeref  clojure.core/deref (core.clj:2078)

 So set-user! binds correctly, but get-id doesn't seem to...

 = (get-id)
 llegalStateException Attempting to call unbound fn:
 #'app-admin.models.current-user/get-id  clojure.lang.Var$Unbound.throwArity
 (Var.java:43)

 Then I check it...

 = (meta #'get-id)
 {:ns #Namespace app-admin.models.current-user, :name get-id}

 So it's there, the fn is bound; I'm not exactly sure what's going on and nor
 what I'm missing about how this works to help me avoid problems like this in
 future. Just guessing and tweaking has gotten me so far, but that's not
 sustainable.

 Thanks!

 -Travis

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

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


Re: New release of Paredit mode for Vim with support for VimClojure repls and Map literals

2012-04-22 Thread Dave Ray
Note that Tomas recently extracted paredit from slimv, so it has its
own home now: https://bitbucket.org/kovisoft/paredit
Also, there have been several important bug fixes applied to paredit
in the last few months. It would be great if any improvements you've
made could make it back into the official version.

Dave

On Sun, Apr 22, 2012 at 10:24 PM, dgrnbrg dsg123456...@gmail.com wrote:
 I am having trouble porting my simple VimClojure support with the
 version 0.9.6 of the script. The integration w/ slimv's REPL appears
 to have increased. I'm not sure what the best course of action is,
 since I don't really want to continue trying to merge the codebases,
 and instead just fix any bugs in my implementation. There aren't any
 other new features to gain, otherwise.

 On Apr 22, 7:47 pm, John Szakmeister j...@szakmeister.net wrote:
 On Sun, Apr 22, 2012 at 3:28 PM, Evan Mezeske emeze...@gmail.com wrote:
  Version 0.9.3 does indeed support balanced map literals.

  I believe that the bitbucket repository is the official home of slimv (from
  which paredit.vim comes): https://bitbucket.org/kovisoft/slimv/ .

 Just an FYI, but there seems to be version 0.9.6 here:
    http://www.vim.org/scripts/script.php?script_id=3998

 -John

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

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


Re: Returning Success

2012-03-19 Thread Dave Ray
On Mon, Mar 19, 2012 at 7:14 PM, jk john.r.kru...@gmail.com wrote:
 I read this and wondered why you care? Isn't it sufficient to return
 the new world state? You could use identical? as someone suggested but
 why bother? It sounds like the player should be able to keep bumping
 into the wall if they keep making the same move.

One good example is you want to play a bump sound each time they hit
the wall. Without some info in the state about what just happened,
i.e. the result of the last action, you don't know whether to do
side-effects like this.

In his Clojure/West talk (sorry, slides aren't posted), Stuart Sierra,
suggested storing results or side-effects of a pure function in a
result or action key on the state map. I also like this approach for a
few reasons:

* assuming your state's in an atom or ref, your state transition
functions will play nicely with swap! and alter. No need to create an
anonymous wrapper function just to use them and check return codes.
Anonymous functions passed to swap! always seems like a smell to me.
* your state transition functions will play nicely with the threading
operator. They'll read nicely like (- my-state funca funcb ...)
* storing side-effects and errors as say a vector of values in a key
on the state can be manipulated by other transition functions later in
the chain and easily dispatched over by a multi-method or whatever

One area I'm not quite sure about is multiple threads beating on
something like this. Suppose the typical pattern is something like
this:

(doseq [action (:actions (swap! state-atom do-something))]
(execute-action action))

well if several threads are doing this at once, the actions could be
executed multiple times. I'm not sure of a great solution to this. I
have ideas, but I'm not that fond of any of them.

hope this helps. feel free to correct me if I'm totally wrong.

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


ANN: Seesaw 1.4.0

2012-03-05 Thread Dave Ray
Hi,

Seesaw 1.4.0 is out now. The release notes [1] have highlights of all
the changes since 1.3.0. Note there are two breaking changes in the
API. I believe the impact of these changes should be minimal since
they were in areas of the API even I was never able to use
effectively.

I'd also like to thank Sam and Jeff and everyone else working on
Overtone. Its custom widget development really pushed the Seesaw API
and exposed a number of issues I probably wouldn't have found
otherwise.

I'll see everybody at Clojure/West!

Cheers,

Dave

[1] https://github.com/daveray/seesaw/wiki/Release-Notes

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

2012-03-04 Thread Dave Ray
Brad,

As Kevin points out, because the values in the property file go
through read-string, they're read as Clojure literals, symbols in this
case. One solution is to make the string values look like string
literals to the reader:

host=foo.com
port=2525
user=me
pass=pwd

Try that and never believe anything you read on StackOverflow :)

Dave

On Sun, Mar 4, 2012 at 10:23 AM, Brad Lucas b...@beaconhill.com wrote:
 I'm using Postal (https://github.com/drewr/postal) and found something
 I don't know how to fix.

 I have my application working fine if I have a var with my smtp
 properties created as follows:

 (def smtp-original {:host foo.com
                      :port 2525
                      :user me
                      :pass pwd
                      })

 Since I want to release my project for others I thought to modify it
 to read the smtp values from a Properties file. I used the routine
 from Dave Ray's answer on StackOverFlow (http://stackoverflow.com/a/
 7781443/406220).

 ;; Load smtp information out of a file from 
 http://stackoverflow.com/a/7781443/406220
 (defn load-props
  [file-name]
  (with-open [^java.io.Reader reader (clojure.java.io/reader file-
 name)]
    (let [props (java.util.Properties.)]
      (.load props reader)
      (into {} (for [[k v] props] [(keyword k) (read-string v)])

 This works well in that it returns a Map that looks just like the smtp-
 original when reading the following file.

 host=foo.com
 port=2525
 user=me
 pass=pwd


 The trouble is when I run my app and it calls into Postal I get a
 java.lang.ClassCastException.

 I notice that the smtp-original created with a def is a
 clojure.lang.PersistentHashMap while the return from load-props is a
 clojure.lang.PersistentArrayMap.

 I looked into Postal but don't see why this matters.

 So, I guess I have a few questions.

 Can I convert the PersistentArrayMap to a PersistentHashMap? Is this
 the right way to go?
 Is load-props doing something unusual? It seems fine.
 Does anyone understand the internals of Postal? Why would it not work
 with the PersistentArrayMap?

 Any ideas or pointers would be greatly appreciated. I'm looking to
 understand what is going on.

 Thanks

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

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

2012-02-19 Thread Dave Ray
Is satisfies? sufficient for your needs? It seems to be implemented in
ClojureScript and is, I think, the official way to check whether and
object implements a protocol.

Dave

On Sun, Feb 19, 2012 at 9:26 AM, Shantanu Kumar
kumar.shant...@gmail.com wrote:
  I noticed that `extends?`, `class` and `type` are not implemented on
  ClojureScript (yet) – will they eventually be implemented? Is there a
  way beside these to determine if a reified object implements a certain
  protocol?

  Shantanu

 class is a Java-ism, probably doesn't make sense. There's a branch with
 type defined in it waiting on more feedback. extends? would probably need
 to be a macro.

 Is there a JIRA ticket on this I can track? (Searching didn't get any
 results.) Also, is there any page on the Wiki to track this?

 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

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

2012-01-31 Thread Dave Ray
 ;; This is how I repaint the frame, after changing the list
 (doto *frame*
       (.setContentPane (make-panel))
       .repaint
       (.setVisible true))


This is probably the reason it's slow (you don't say how many rects
you're drawing). It's only necessary to set the content pane of the
frame and set it visible once. After that, you should call repaint on
*just the panel*:

  (.repaint panel)

You can use add-watch on your list to call this automatically whenever
the ref changes.

If, for some reason, this is still too slow, you can use a more
explicit version of repaint [1] which requests that only a specific
area of the panel be repainted.

Hope this helps,

Dave

[1] 
http://docs.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#repaint(long,%20int,%20int,%20int,%20int)

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

2012-01-31 Thread Dave Ray
Calling repaint directly on the panel (not the frame) should be all
that's necessary to update the display. updateComponentTreeUI() is
only used when the look and feel of an app changes.

Dave

On Tue, Jan 31, 2012 at 8:44 AM, Jonathan Cardoso
jonathancar...@gmail.com wrote:
 I used   (SwingUtilities/updateComponentTreeUI *frame*), worked great and
 seems faster even without using watch yet.

 Thank's

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

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


Re: seesaw texteditor.clj classpath error

2012-01-23 Thread Dave Ray
Jay,

That's enough.

You've asked this question and many related questions over the last
several months [1][2][3][4][5][6]. Usually the simplest answer is
download Leiningen [7] and learn to use it. The advice is the same
here. Since this is the point in a thread when you usually disappear
only to resurface somewhere else a week or two later I'll leave it at
that. I don't know how to help you.

Dave

p.s. That example hasn't looked like that in 8 months. You'll find the
latest here: 
https://github.com/daveray/seesaw/blob/develop/test/seesaw/test/examples/text_editor.clj


[1] 
https://groups.google.com/group/seesaw-clj/browse_thread/thread/69155ac1d1f11e67
[2] 
https://groups.google.com/group/seesaw-clj/browse_thread/thread/79f6d47baad95a72
[3] 
https://groups.google.com/group/clojure/browse_thread/thread/2a0d85c5fee9f59d/
[4] 
https://groups.google.com/group/clojure/browse_thread/thread/5931c8f60a36b3b4/
[5] 
https://groups.google.com/group/clojure/browse_thread/thread/5fc68b5233698d7c
[6] 
https://groups.google.com/group/clojure/browse_thread/thread/3475c70556c03746/
[7] https://github.com/technomancy/leiningen

On Sun, Jan 22, 2012 at 11:24 PM, jayvandal s...@ida.net wrote:
 I get this error with classpath. I This is not leiningen  but should
 be simple

 c:/opt/jars contains seesaw-1.2.2.jar

 Classpath = c:/opt/jars/*;
 Program is by Daveray. I copied it and changed name(line 1) to
 seeeditor.core

 (ns seeeditor.core
  (:use seesaw.core
        [clojure.java.io :only [file]])
  (:import [javax.swing JFileChooser JEditorPane JScrollPane
 BorderFactory]
           java.awt.Font)
  (:gen-class))

 I run this and line
 java -jar c:/opt/jars/clojure.jar c:/aproject/seeeditor.clj
  and got this

 C:\Aprojectjava -jar c:/opt/jars/clojure.jar c:/aproject/
 seeeditor.clj
 Exception in thread main java.io.FileNotFoundException: Could not
 locate seesa
 w/core__init.class or seesaw/core.clj on classpath:  (seeeditor.clj:1)

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

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

2012-01-06 Thread Dave Ray
On Fri, Jan 6, 2012 at 3:02 PM, Jozef Wagner jozef.wag...@gmail.com wrote:
 Consider this contrived piece of code:

 (def aval (atom {:dumped false :contents hello world}))

 (defn update!
   [item]
   (when-not (:dumped item)
     (spit a.out (:contents item) :append true)
     (assoc item :dumped true)))

 How should I correctly call update! ? Each of following two calls have
 drawbacks.

 (swap! aval update!) ;; update! can be called more than once

 (let [new-val (update! aval)]
   ;; aval can be changed in between from other thread
   (reset! aval new-val))

 Best,
 Jozef


Jozef,

I think you can solve this by adding a little more info and keeping
the update function and side effects separate:

(def aval (atom { :contents hello world }))

(defn update-item [{:keys [dumped] :as item}]
  (assoc item :dumped true :needs-dump (not dumped)))

(let [{:keys [needs-dump contents]} (swap! aval update-item)]
  (if needs-dump
(spit a.out contents :append true)))

Whoever gets to aval first while it hasn't been dumped will see
needs-dump as true and write the file. Depending on your requirements,
if the file write fails, you'll might need to do some extra work to
put aval back in a state consistent with reality.

Hope this helps,

Dave

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


Re: Bug in extend-protocol macro? (Clojure 1.3.0)

2011-12-30 Thread Dave Ray
On Fri, Dec 30, 2011 at 4:13 PM, Alan Malloy a...@malloys.org wrote:
 On Dec 30, 11:34 am, Marshall T. Vandegrift llas...@gmail.com
 wrote:
 Peter Taoussanis ptaoussa...@gmail.com writes:
  Thanks- that explains it: dropping to extend works as expected.

 Another option I've been making use of for exactly this situation is to
 use the #= reader macro to evaluate the Class/forName at read-time.
 Something like:

   (extend-protocol MyProtocol
     java.lang.Integer (action [x] Integer)
     #=(Class/forName [B) (action [x] ByteArray))

 It may not be ideal stylistically, but lets you use extend-protocol in
 such situations.

 Stuff like this always worries me. It may happen to work now, but I
 doubt if that's a guarantee. extend-protocol's contract is that you
 give it a Symbol, which it resolves into a Class. It surely isn't
 expecting a Class as an argument, because you can't enter that as a
 source-code literal. If you give it a Class, it could conceivably do
 something dreadful like try to call (resolve s) on it to figure out
 what Class you mean, and that will fail when passed a Class.

 For that matter, trying out your example, it doesn't seem to work for
 me. The first fix is to use java.lang.Class instead of just Class,
 since reader evaluation happens in a no-frills environment. But after
 that, it seems the extend-protocol just silently does nothing:

 repl-1= (defprotocol P)
 P
 repl-1= (extend-protocol P #=(java.lang.Class/forName [B))
 nil
 repl-1= (satisfies? P (Class/forName [B))
 false


satisfies? works on an instance:

user= (satisfies? P (byte-array []))
true


Dave

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


Re: ANN: Seesaw 1.3.0

2011-12-21 Thread Dave Ray
Thanks Sam! Of course my experience with Overtone had more than a
little to do with this work :)

On Wed, Dec 21, 2011 at 4:12 AM, Sam Aaron samaa...@gmail.com wrote:
 Hi Dave,

 very cool - I love that you're working on improving the explorability of the 
 system. It's clearly a focus that REPL driven development emphasises and I 
 hope we see more people working in this area.

 Sam

 ---
 http://sam.aaron.name

 On 21 Dec 2011, at 03:24, Dave Ray wrote:

 Hi,

 I've just release Seesaw 1.3.0. Details of this release can be found
 in the release notes [1]. There are a few features I'm pretty happy
 about, so I'll mention them briefly here.

 Interactive development: So far, learning Seesaw has meant getting
 familiar with Java and Swing. I think that element will always be
 there, but it can be made better. Toward that end, two new functions,
 (seesaw.dev/show-options) and (seesaw.dev/show-events) can be used at
 the repl to ask a widget about it's options and events respectively.
 Hopefully this will save a few trips to the Javadocs. I've already
 used it several times myself. Example output can be found in this gist
 [2]

 Value Semantics: As I threatened, I've borrowed the value semantics
 which Stathis Sedaris introduced in Clarity [3]. (seesaw.core/value)
 will give you the value of a widget, or a map of values for
 composites. It's really a nice way to work, especially for forms.

 Key Mapping: Like everything else in Swing, setting up key
 mappings/bindings is a pain in the ass. This interface hopefully makes
 that much easier. For example, to handle the enter key in a list box,
 just do (map-key my-box ENTER (fn [e] ... do something ...)).

 Improved Interop: Seesaw will now play nicely with whatever widget you
 give it whether it was created by Seesaw or not. This should make it
 straightforward to use UIs built with wysiwyg editors from Clojure.

 Those are the biggies. There have also been several bug fixes and
 minor improvements.

 Cheers,

 Dave


 [1] https://github.com/daveray/seesaw/wiki/Release-Notes
 [2] https://gist.github.com/1450241
 [3] https://github.com/stathissideris/clarity

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

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

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


Re: ANN: Seesaw 1.3.0

2011-12-21 Thread Dave Ray
Kevin,

Being a Swing app, I'd take a look at how Clooj
(https://github.com/arthuredelstein/clooj) does it.

Dave

On Wed, Dec 21, 2011 at 4:36 AM, Kevin Ilchmann Jørgensen
kijm...@gmail.com wrote:
 Hi

 Regarding explorability, what would be the best way to provide an repl
 directly in a Seesaw app?

 /kevin

 On Dec 21, 2011 10:12 AM, Sam Aaron samaa...@gmail.com wrote:

 Hi Dave,

 very cool - I love that you're working on improving the explorability of
 the system. It's clearly a focus that REPL driven development emphasises and
 I hope we see more people working in this area.

 Sam

 ---
 http://sam.aaron.name

 On 21 Dec 2011, at 03:24, Dave Ray wrote:

  Hi,
 
  I've just release Seesaw 1.3.0. Details of this release can be found
  in the release notes [1]. There are a few features I'm pretty happy
  about, so I'll mention them briefly here.
 
  Interactive development: So far, learning Seesaw has meant getting
  familiar with Java and Swing. I think that element will always be
  there, but it can be made better. Toward that end, two new functions,
  (seesaw.dev/show-options) and (seesaw.dev/show-events) can be used at
  the repl to ask a widget about it's options and events respectively.
  Hopefully this will save a few trips to the Javadocs. I've already
  used it several times myself. Example output can be found in this gist
  [2]
 
  Value Semantics: As I threatened, I've borrowed the value semantics
  which Stathis Sedaris introduced in Clarity [3]. (seesaw.core/value)
  will give you the value of a widget, or a map of values for
  composites. It's really a nice way to work, especially for forms.
 
  Key Mapping: Like everything else in Swing, setting up key
  mappings/bindings is a pain in the ass. This interface hopefully makes
  that much easier. For example, to handle the enter key in a list box,
  just do (map-key my-box ENTER (fn [e] ... do something ...)).
 
  Improved Interop: Seesaw will now play nicely with whatever widget you
  give it whether it was created by Seesaw or not. This should make it
  straightforward to use UIs built with wysiwyg editors from Clojure.
 
  Those are the biggies. There have also been several bug fixes and
  minor improvements.
 
  Cheers,
 
  Dave
 
 
  [1] https://github.com/daveray/seesaw/wiki/Release-Notes
  [2] https://gist.github.com/1450241
  [3] https://github.com/stathissideris/clarity
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

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

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

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


Re: ANN: Seesaw 1.3.0

2011-12-21 Thread Dave Ray
Hi Laurent!

...

On Wed, Dec 21, 2011 at 7:42 AM, Laurent PETIT laurent.pe...@gmail.com wrote:
 Hello Dave !

 2011/12/21 Dave Ray dave...@gmail.com:
 Hi,

 I've just release Seesaw 1.3.0. Details of this release can be found
 in the release notes [1]. There are a few features I'm pretty happy
 about, so I'll mention them briefly here.

 Interactive development: So far, learning Seesaw has meant getting
 familiar with Java and Swing. I think that element will always be
 there, but it can be made better. Toward that end, two new functions,
 (seesaw.dev/show-options) and (seesaw.dev/show-events) can be used at
 the repl to ask a widget about it's options and events respectively.
 Hopefully this will save a few trips to the Javadocs. I've already
 used it several times myself. Example output can be found in this gist
 [2]

 This sounds great !

 As a tool builder, I'd also be interested if what is printed in *out*
 by these functions could also be made available as pure data, so that
 e.g. at some point in time, CCW could provide a specialized tabular
 view to display (edit?) this information.

 What do you think about that ?

Sounds fun to me. show-options and show-events are already working off
structured data provided by functions called get-option-map and
events-for, respectively (sitting next to each other those names
aren't that consistent, are they?). So it would be pretty easy I
think. The examples for each option are currently just a vector of
values. Editing would probably need some more metadata about types and
valid values.

Dave

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


Re: Question about accessing java methods?

2011-12-21 Thread Dave Ray
On Wed, Dec 21, 2011 at 3:10 PM, Alan Malloy a...@malloys.org wrote:


 On Dec 21, 12:03 pm, Jonas jonas.enl...@gmail.com wrote:
 You can also do (.. boxWidget GetProp3D (SetUserTransform t)) or (-
 boxWidget .GetProp3D (.SetUserTransform t))

 Well, neither of these are strictly equivalent to his original code,
 which returns the boxWidget; yours return the result of
 SetUserTransform. However, the option to leave off the parens, or
 use .. instead are both still valid. Leaving off the doto might be
 valid also, if he doesn't care about the return value.

 FWIW, I don't really care for .. - my understanding is it's fallen out
 of favor: it was added in the bad old days before - existed.

I don't use .. in real code, but I use it a lot at the REPL because I
can chain a bunch of java methods without having to type dots. For
example, this:

   (.. foo getBar doBaz getYum)

instead of this:

  (- foo .getBar .doBaz .getYum)

yeah. it's only 3 characters, but for whatever reason it sees to make
a difference to me :)

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


ANN: Seesaw 1.3.0

2011-12-20 Thread Dave Ray
Hi,

I've just release Seesaw 1.3.0. Details of this release can be found
in the release notes [1]. There are a few features I'm pretty happy
about, so I'll mention them briefly here.

Interactive development: So far, learning Seesaw has meant getting
familiar with Java and Swing. I think that element will always be
there, but it can be made better. Toward that end, two new functions,
(seesaw.dev/show-options) and (seesaw.dev/show-events) can be used at
the repl to ask a widget about it's options and events respectively.
Hopefully this will save a few trips to the Javadocs. I've already
used it several times myself. Example output can be found in this gist
[2]

Value Semantics: As I threatened, I've borrowed the value semantics
which Stathis Sedaris introduced in Clarity [3]. (seesaw.core/value)
will give you the value of a widget, or a map of values for
composites. It's really a nice way to work, especially for forms.

Key Mapping: Like everything else in Swing, setting up key
mappings/bindings is a pain in the ass. This interface hopefully makes
that much easier. For example, to handle the enter key in a list box,
just do (map-key my-box ENTER (fn [e] ... do something ...)).

Improved Interop: Seesaw will now play nicely with whatever widget you
give it whether it was created by Seesaw or not. This should make it
straightforward to use UIs built with wysiwyg editors from Clojure.

Those are the biggies. There have also been several bug fixes and
minor improvements.

Cheers,

Dave


[1] https://github.com/daveray/seesaw/wiki/Release-Notes
[2] https://gist.github.com/1450241
[3] https://github.com/stathissideris/clarity

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

2011-12-18 Thread Dave Ray
java.library.path is only good for the first layer of libraries you
load. Any dependent libs (like libvtkCommon.so) are loaded with the
normal dynamic loading provided by the OS. So, i think there's two
options:

* Just use LD_LIBRARY_PATH env variable (or OS equivalent) and don't
bother with java.library.path.
* Make sure all the libs are loaded manually in the right order:

   (clojure.lang.RT/loadLibrary vtkCommon)
   (clojure.lang.RT/loadLibrary vtkCommonJava)

Now the vtkCommon lib is already loaded before vtkCommonJava. Of
course, this means you have to figure out the deps, sort them, and
deal with changes over time. Good times.

Hope this helps,

Dave

On Sun, Dec 18, 2011 at 11:20 AM, Baishampayan Ghose b.gh...@gmail.com wrote:
 It seems the JVM is unable to locate certain shared library in the
 path you specified. Can you see whether that .so file actually exists
 in that directory?

 This is what the VTK wiki says about this type of errors -
 http://www.vtk.org/Wiki/VTK/FAQ#When_I_try_to_run_my_program_with_Java-wrapped_VTK.2C_why_do_I_get_.22java.lang.UnsatisfiedLinkError:_no_vtkSomeLibraryName.22.3F

 Regards,
 BG

 On Sun, Dec 18, 2011 at 1:00 AM, Antonio Recio amdx6...@gmail.com wrote:
 When I try to load native libraries in the System ClassLoader I get an error
 of cannot open shared object file, and I don't know how to solve it.

 In linux in REPL :
 clojure java -Djava.library.path=/usr/local/lib/vtk-5.9/ -cp
 /usr/share/java/clojure.jar:/usr/local/lib/vtk-5.9/java/vtk.jar clojure.main

 when I execute this code :
 (ns project.core
   (:import (javax.swing JButton JFrame JPanel)
            (vtk vtkConeSource vtkPolyDataMapper vtkRenderWindow
                 vtkRenderWindowInteractor vtkCamera vtkActor vtkRenderer
                 vtkInteractorStyleTrackballCamera)))

 (clojure.lang.RT/loadLibrary vtkCommonJava)

 I obtain this error :
 UnsatisfiedLinkError /usr/local/lib/vtk-5.9/libvtkCommonJava.so.5.9.0:
 libvtkCommon.so.5.9: cannot open shared object file: No such file or
 directory  java.lang.ClassLoader$NativeLibrary.load (ClassLoader.java:-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



 --
 Baishampayan Ghose
 b.ghose at gmail.com

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

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


Re: ANN: Clarity 0.5.1 - New GUI library

2011-12-06 Thread Dave Ray
Stathis,

I use the Lazytest watcher partly out of convenience. I happen to use
Lazytest for testing so it's usually already running anyway. However,
some work has already been done to extract the watch functionality
[1]. It might be fun to combine your viewer with it. Maybe have a
naming convention for the watch entry point of an app or component so
you can use it without editing the file.

[1] 
https://groups.google.com/group/clojure-dev/browse_thread/thread/32ab1a5e7f819196/dde7a347e7f56b0a

Cheers,

Dave

On Tue, Dec 6, 2011 at 1:45 PM, Stathis Sideris side...@gmail.com wrote:
 Hello Dave,

 I'll clarify some of Stathis' remarks about Seesaw below. Obviously,
 I'm a little biased, but Clarity looks cool and I plan on borrowing
 some of its features for Seesaw in the next release or two :)  I think
 it's great to have multiple projects like this to inspire each other
 and keep everyone honest. Keep up the nice work!

 Thanks for your kind words, if you're borrowing I must be doing
 something right! I too think that it's really cool to have multiple
 projects, and it may help us learn from each other! We do have similar
 problems after all.

 Seesaw selectors are basically Enlive selectors [1] ported to Swing.
 So it supports all the usually CSS hierarchical stuff, ids and classes
 (Clarity's categories). It can also select on Java class/sub-class
 relationships. I left it at that since selector+filter seemed a
 reasonable enough way to add custom predicates or whatever if
 necessary.

 [1]http://enlive.cgrand.net/syntax.html

 OK that looks pretty powerful too, I retract my comments about being
 able to do more with Clarity's selectors. :-)

  The other thing that I think differentiates Clarity is the live
  preview of layouts using clarity.dev/watch-component.

 I think that's very cool too. I approximate that workflow using
 lazytest's watcher to re-run my code when it changes.

 I think that's a much better way. Currently, when watching a
 component, Clarity bashes the JVM by creating the component every X
 seconds (I did say it was an experimental feature!). I'll look into
 lazytest's code to see how it detects the code changes. I suppose it
 watches for changes in the class files, right?

 Stathis

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

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


ANN: Seesaw 1.2.2

2011-12-04 Thread Dave Ray
Hi,

Seesaw 1.2.2 has been released. It includes several enhancements, most
notably SwingX support and some tools to make debugging exceptions in
the UI thread easier.

The full release notes can be found here:
https://github.com/daveray/seesaw/wiki/Release-Notes.

Cheers,

Dave

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


Re: ANN: Clarity 0.5.1 - New GUI library

2011-12-03 Thread Dave Ray
Howdy,

I'll clarify some of Stathis' remarks about Seesaw below. Obviously,
I'm a little biased, but Clarity looks cool and I plan on borrowing
some of its features for Seesaw in the next release or two :)  I think
it's great to have multiple projects like this to inspire each other
and keep everyone honest. Keep up the nice work!

Cheers,

Dave

more inline below ...

On Sat, Dec 3, 2011 at 8:15 PM, Stathis Sideris side...@gmail.com wrote:
 Hello Gary,

 Hello Gary,

 To be honest I didn't look at seesaw much while developing Clarity, so
 I didn't make any conscious decision to differentiate with seesaw.
 It's very interesting to see that both me and Dave Ray came up with
 similar solutions/features.

 It seems that Seesaw is more concise in comparison to Clarity, and
 from the project page it does look like a more mature project. On the
 other hand, it seems to me (and I might be wrong) that Clarity has a
 more complete solution when it comes to selectors because it supports
 categories on top of the IDs, and the syntax caters for arbitrary
 logic operations and custom selectors.

Seesaw selectors are basically Enlive selectors [1] ported to Swing.
So it supports all the usually CSS hierarchical stuff, ids and classes
(Clarity's categories). It can also select on Java class/sub-class
relationships. I left it at that since selector+filter seemed a
reasonable enough way to add custom predicates or whatever if
necessary.

[1] http://enlive.cgrand.net/syntax.html

 It seems that Seesaw uses binding for keeping GUI values and atoms/
 refs in sync, and Clarity instead provides easy ways to retrieve all
 the values of all components in a panel as a map (see the HasValue
 interface). I like Clarity's approach better because it's more de-
 coupled.

Yep. I like Clarity's (value) function as well, especially for forms
in dialogs. I'll be borrowing that. If you need to update one or more
aspects of the UI based on changes in a reference type or some aspect
of a widget, bindings (in the Seesaw sense) work nicely because they
provide that automatic propagation and fine granularity.

 The other thing that I think differentiates Clarity is the live
 preview of layouts using clarity.dev/watch-component.

I think that's very cool too. I approximate that workflow using
lazytest's watcher to re-run my code when it changes.

 Finally, let me repeat that all of the above are based on a
 superficial reading of Seesaw's docs, I may as well be wrong!

 Thanks,

 Stathis


 On Dec 3, 2:52 pm, Gary Trakhman gary.trakh...@gmail.com wrote:
 Have you looked at seesaw?  What differences are there in the design and
 intent?

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

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


Re: classpath on seesaw????

2011-11-15 Thread Dave Ray
Thanks for the tip Gregg. It looks like I merged badly or something
for the 1.2.0 release. The extra examples directory
(src/seesaw/examples) isn't present in master, develop, or the 1.2.1
tag. kitchensink.clj is in there too, although I should probably
delete it lest someone pick up bad habits. It's a bit of an
abomination :)

Dave

On Tue, Nov 15, 2011 at 10:28 PM, Gregg Williams greg...@innerpaths.net wrote:
 Hello! As a beginning Seesaw user, I had the same trouble. Here is a
 solution that I just confirmed as working:

 $ cd seesaw/src
 $ lein deps
 $ lein run -m seesaw.examples.kitchensink

 (in the last line, note the omission of ...test. ...)

 Dave, thanks for all your work. One small problem: you've got a very
 similar but not identical set of sample programs at:

 * seesaw-v1_20-13dd772/test/seesaw/test

 and

 * seesaw-v1_20-13dd772/src/seesaw/examples

 kitchensink.clj is in the second directory but not the first. Other
 differences exist.

 I hope this helps everybody.


 Gregg W.



 On Nov 12, 8:56 pm, sixs s...@ida.net wrote:
 seesaw downloads as follows c:\seesaw\test\seesaw\test\examples\kitchensink
 first wseesaw is originally daveray-seesaw-1.0.7-281-g12248d4
 I have tried to run lein deps and the
  lein run -m seesaw.test.examples.kitchensink
 from the first seesaw, then the nest seesaw and ffinally examples. I can't
 get to run.







 - Original Message -

 C:\Users\jim.jim-PC\Downloads\daveray-seesaw-1.0.7-281-g12248d4.zip
 From: Dave Ray dave...@gmail.com
 To: clojure@googlegroups.com
 Sent: Saturday, November 12, 2011 5:13 AM
 Subject: Re: classpath on seesaw

 Good Morning,

 The easiest way to run the Seesaw examples is as describe in the wiki
 (https://github.com/daveray/seesaw/wiki):

 * Install leiningen
 * Clone or download the repo from github
 * then...

 $ cd seesaw
 $ lein deps
 $ lein run -m seesaw.test.examples.kitchensink

 Replace kitchensink with whichever example you want to run.

 Also, future questions like this might be better directed to the
 Seesaw mailing listhttps://groups.google.com/group/seesaw-clj

 Hope this helps,

 Dave

 On Sat, Nov 12, 2011 at 1:45 AM, jayvandal s...@ida.net wrote:
  I am trying to run the examples in seesaw.I must not have seeesaw
  installed correctly.
  any help please

  Microsoft Windows [Version 6.0.6000]
  Copyright (c) 2006 Microsoft Corporation. All rights reserved.

  C:\cd cljr

  C:\cljrjava -jar c:/clojure-1.3.0.jar c:/cljr/kitchensink.clj
  Error: Unable to access jarfile c:/clojure-1.3.0.jar

  C:\cljrjava -jar c:/clojure-1.3.0/clojure-1.3.0.jar c:/cljr/
  kitchensink.clj
  Exception in thread main java.lang.RuntimeException:
  java.io.FileNotFoundExcep
  tion: Could not locate seesaw/core__init.class or seesaw/core.clj on
  classpath:

  at clojure.lang.Util.runtimeException(Util.java:165)
  at clojure.lang.Compiler.eval(Compiler.java:6476)
  at clojure.lang.Compiler.eval(Compiler.java:6455)
  at clojure.lang.Compiler.load(Compiler.java:6902)
  at clojure.lang.Compiler.loadFile(Compiler.java:6863)
  at clojure.main$load_script.invoke(main.clj:282)
  at clojure.main$script_opt.invoke(main.clj:342)
  at clojure.main$main.doInvoke(main.clj:426)
  at clojure.lang.RestFn.invoke(RestFn.java:408)
  at clojure.lang.Var.invoke(Var.java:401)
  at clojure.lang.AFn.applyToHelper(AFn.java:161)
  at clojure.lang.Var.applyTo(Var.java:518)
  at clojure.main.main(main.java:37)
  Caused by: java.io.FileNotFoundException: Could not locate seesaw/
  core__init.cla
  ss or seesaw/core.clj on classpath:
  at clojure.lang.RT.load(RT.java:430)
  at clojure.lang.RT.load(RT.java:398)
  at clojure.core$load$fn__4610.invoke(core.clj:5386)
  at clojure.core$load.doInvoke(core.clj:5385)
  at clojure.lang.RestFn.invoke(RestFn.java:408)
  at clojure.core$load_one.invoke(core.clj:5200)
  at clojure.core$load_lib.doInvoke(core.clj:5237)
  at clojure.lang.RestFn.applyTo(RestFn.java:142)
  at clojure.core$apply.invoke(core.clj:602)
  at clojure.core$load_libs.doInvoke(core.clj:5271)
  at clojure.lang.RestFn.applyTo(RestFn.java:137)
  at clojure.core$apply.invoke(core.clj:604)
  at clojure.core$use.doInvoke(core.clj:5363)
  at clojure.lang.RestFn.invoke(RestFn.java:408)
  at seesaw.test.examples.kitchensink
  $eval3$loading__4505__auto4.invok
  e(kitchensink.clj:11)
  at seesaw.test.examples.kitchensink
  $eval3.invoke(kitchensink.clj:11)
  at clojure.lang.Compiler.eval(Compiler.java:6465)
  ... 11 more

  C:\cljr

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

Re: classpath on seesaw????

2011-11-12 Thread Dave Ray
Good Morning,

The easiest way to run the Seesaw examples is as describe in the wiki
(https://github.com/daveray/seesaw/wiki):

* Install leiningen
* Clone or download the repo from github
* then...

$ cd seesaw
$ lein deps
$ lein run -m seesaw.test.examples.kitchensink

Replace kitchensink with whichever example you want to run.

Also, future questions like this might be better directed to the
Seesaw mailing list https://groups.google.com/group/seesaw-clj

Hope this helps,

Dave

On Sat, Nov 12, 2011 at 1:45 AM, jayvandal s...@ida.net wrote:
 I am trying to run the examples in seesaw.I must not have seeesaw
 installed correctly.
 any help please

 Microsoft Windows [Version 6.0.6000]
 Copyright (c) 2006 Microsoft Corporation.  All rights reserved.


 C:\cd cljr

 C:\cljrjava -jar c:/clojure-1.3.0.jar c:/cljr/kitchensink.clj
 Error: Unable to access jarfile c:/clojure-1.3.0.jar

 C:\cljrjava -jar c:/clojure-1.3.0/clojure-1.3.0.jar c:/cljr/
 kitchensink.clj
 Exception in thread main java.lang.RuntimeException:
 java.io.FileNotFoundExcep
 tion: Could not locate seesaw/core__init.class or seesaw/core.clj on
 classpath:

        at clojure.lang.Util.runtimeException(Util.java:165)
        at clojure.lang.Compiler.eval(Compiler.java:6476)
        at clojure.lang.Compiler.eval(Compiler.java:6455)
        at clojure.lang.Compiler.load(Compiler.java:6902)
        at clojure.lang.Compiler.loadFile(Compiler.java:6863)
        at clojure.main$load_script.invoke(main.clj:282)
        at clojure.main$script_opt.invoke(main.clj:342)
        at clojure.main$main.doInvoke(main.clj:426)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.lang.Var.invoke(Var.java:401)
        at clojure.lang.AFn.applyToHelper(AFn.java:161)
        at clojure.lang.Var.applyTo(Var.java:518)
        at clojure.main.main(main.java:37)
 Caused by: java.io.FileNotFoundException: Could not locate seesaw/
 core__init.cla
 ss or seesaw/core.clj on classpath:
        at clojure.lang.RT.load(RT.java:430)
        at clojure.lang.RT.load(RT.java:398)
        at clojure.core$load$fn__4610.invoke(core.clj:5386)
        at clojure.core$load.doInvoke(core.clj:5385)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invoke(core.clj:5200)
        at clojure.core$load_lib.doInvoke(core.clj:5237)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invoke(core.clj:602)
        at clojure.core$load_libs.doInvoke(core.clj:5271)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invoke(core.clj:604)
        at clojure.core$use.doInvoke(core.clj:5363)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at seesaw.test.examples.kitchensink
 $eval3$loading__4505__auto4.invok
 e(kitchensink.clj:11)
        at seesaw.test.examples.kitchensink
 $eval3.invoke(kitchensink.clj:11)
        at clojure.lang.Compiler.eval(Compiler.java:6465)
        ... 11 more

 C:\cljr

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


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


Re: where to find clojure swing definitons

2011-11-07 Thread Dave Ray
Hi. In Swing, components are positioned with a layout manager. Here's
a guide to the ones that Swing provides out of the box:
http://download.oracle.com/javase/tutorial/uiswing/layout/visual.html.

If you're building a Swing app, you might find Seesaw
(https://github.com/daveray/seesaw), or another wrapper (GUIFTW,
Clarity, etc), to be a more pleasant experience than raw Swing.

Cheers,

Dave

On Mon, Nov 7, 2011 at 10:16 AM, jayvandal s...@ida.net wrote:
 I wonder where I can find swing definitions such as text field
 locations on a panel or frame?
 How do I put 2 panels side by side to show two different records?
 How do I put text fields across  the screen or down the screen??
 Any help I would appreciate.
 Thanks

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


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

2011-10-16 Thread Dave Ray
Yes, just change the grouping function passed to group-by:

   (group-by #(vector (% Type) (% Subtype)) coll)

The keys in the resulting map will be two-element vectors (e.g.
[TypeA SubTypeA]) so you'll need to adjust the body of the for a
bit in BG's example.

Cheers,

Dave

On Sun, Oct 16, 2011 at 5:55 AM, der derealme.derea...@gmail.com wrote:
 Thanks BG and all other responses for your help.

 I have a followup question, could the same approach be extended if I
 wanted to group-by multiple entries in the map? e.g. assuming the map
 now had Type and Subtype and I wanted to group-by the pair Type and
 Subtype, would the same approach work?

 On Oct 14, 9:45 pm, Baishampayan Ghose b.gh...@gmail.com wrote:
  I'm a Clojure newbie trying to the following simple task:

 Givenalistofmapsof the followign format: ({Type A, Value
  5} {Type B, Value 4} {Type A, Value 7.2} {Type
  A, Value 25.4} {Type B, Value 2.982})

  I want to compute alistofmapssuch that each type appears once in
  thelistand the value of the type is the sum of the values, so that
  in the example it would be:

  ({Type, A, Value, 37.6} {Type, B, Value, 6.982})

  Any ideas?

 I might write it like this -

 (defn sum-by-type [coll]
     (for [[k v] (group-by #(% Type) coll)]
         {Type k Value (apply + (map (comp #(Float/parseFloat %)
 #(% Value)) v))}))

 Regards,
 BG

 --
 Baishampayan Ghose
 b.ghose at gmail.com

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

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


Re: Sum on a list of maps

2011-10-14 Thread Dave Ray
Someone cleverer than me to post the built-in function that already
does exactly what you want, but here's one way:

(defn sum-by-type [in]
  (- in
(group-by #(get % Type))
(map
  (fn [[k vs]]
{Type k
 Value (reduce
(fn [acc v] (+ acc (Double/parseDouble (get v Value
0
vs)}

All the strings don't help much.

Cheers,

Dave

On Fri, Oct 14, 2011 at 1:25 PM, der derealme.derea...@gmail.com wrote:
 Hi,

 I'm a Clojure newbie trying to the following simple task:

 Given a list of maps of the followign format: ({Type A, Value
 5} {Type B, Value 4} {Type A, Value 7.2} {Type
 A, Value 25.4} {Type B, Value 2.982})

 I want to compute a list of maps such that each type appears once in
 the list and the value of the type is the sum of the values, so that
 in the example it would be:

 ({Type, A, Value, 37.6} {Type, B, Value, 6.982})

 Any ideas?

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

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


Re: Does macros evaluates its arguments before?

2011-09-26 Thread Dave Ray
The argument isn't being evaluated during macro expansion, it's being
evaluated when the expanded form is evaluated by the repl:

user= (macroexpand '(infix (5 + 4)))
(let* [vec__590 (5 + 4) x__574__auto__ (clojure.core/nth vec__590 0
nil) f__575__auto__ (clojure.core/nth vec__590 1 nil) y__576__auto__
(clojure.core/nth vec__590 2 nil)] (f__575__auto__ x__574__auto__
y__576__auto__))
user= (let* [vec__590 (5 + 4) x__574__auto__ (clojure.core/nth
vec__590 0 nil) f__575__auto__ (clojure.core/nth vec__590 1 nil)
y__576__auto__ (clojure.core/nth vec__590 2 nil)] (f__575__auto__
x__574__auto__ y__576__auto__))
java.lang.ClassCastException: java.lang.Integer cannot be cast to
clojure.lang.IFn (NO_SOURCE_FILE:0)

Make sense?

Dave

On Mon, Sep 26, 2011 at 10:26 AM, ru soro...@oogis.ru wrote:
 Timothy!

 Thank you for the explanation. I understand quite well about
 performance. I do'nt understand why it evaluates argument (5 + 4)
 during expansion in my case?

 Ru

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


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


Re: including sound or image files with Leiningen uberjar command

2011-09-17 Thread Dave Ray
Did you forget to set the name of the main class/namespace in project.clj?
that would cause the behavior you're seeing.

Dave

On Saturday, September 17, 2011, loonster tbur...@acm.org wrote:


 On Sep 16, 1:24 am, Joost jo...@zeekat.nl wrote:
 On Sep 16, 7:20 am, loonster tbur...@acm.org wrote:

  Sound or image files will show up in the resulting uberjar if they
  reside in a /resources subdirectory of a Leiningen home project
  directory.  I can't find any documentation for how to refer to and
  load such resource files within a project.clj and/or a source clj file
  so that that the resources can be used by a standalone jar.   Many
  thanks for any hints.   Tim

 You can refer to resources using

 (clojure.java.io/input-stream (clojure.java.io/resource path/to/
 image))

 See also ring.util.response/resource-response if you want to do this
 in a war/jar web app.

 Joost.

 Well, thanks all.  The most succinct code turned out to be
 (clojure.java.io/resource fileName) and so my test fragment now
 consists of:

 (ns depExp
  (:gen-class))

 (import '(java.applet Applet)
'(java.io File)
'(java.net URL))

 (defn -main [ args]
  (.play (Applet/newAudioClip (clojure.java.io/resource
 looncall.au

 ;;;BTW, the looncall.au is a small sound file;;;

 ...which works fine in the REPL and it also compiles but the resulting
 standalone jar file throws an error: main
 java.lang.NullPointerException.   Am using lein uberjar.   ???

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


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

Re: including sound or image files with Leiningen uberjar command

2011-09-17 Thread Dave Ray
Ah. I think there are issues with single-segment namespaces and AOT.
See comment on first answer here [1]. Maybe converting to depExp.core
would help.

Dave

[1] 
http://stackoverflow.com/questions/3390268/how-to-setup-the-classpath-when-running-the-jar-made-from-lein-uberjar

On Sat, Sep 17, 2011 at 10:57 AM, loonster tbur...@acm.org wrote:
 Nope.  The project.clj is:

 (defproject depExp 1.0.0-SNAPSHOT
  :description FIXME: write
  :dependencies [[org.clojure/clojure 1.2.1]
                 [org.clojure/clojure-contrib 1.2.0]]
  :main depExp)

 Tim

 On Sep 17, 5:05 am, Dave Ray dave...@gmail.com wrote:
 Did you forget to set the name of the main class/namespace in project.clj?
 that would cause the behavior you're seeing.

 Dave









 On Saturday, September 17, 2011, loonster tbur...@acm.org wrote:

  On Sep 16, 1:24 am, Joost jo...@zeekat.nl wrote:
  On Sep 16, 7:20 am, loonster tbur...@acm.org wrote:

   Sound or image files will show up in the resulting uberjar if they
   reside in a /resources subdirectory of a Leiningen home project
   directory.  I can't find any documentation for how to refer to and
   load such resource files within a project.clj and/or a source clj file
   so that that the resources can be used by a standalone jar.   Many
   thanks for any hints.   Tim

  You can refer to resources using

  (clojure.java.io/input-stream (clojure.java.io/resource path/to/
  image))

  See also ring.util.response/resource-response if you want to do this
  in a war/jar web app.

  Joost.

  Well, thanks all.  The most succinct code turned out to be
  (clojure.java.io/resource fileName) and so my test fragment now
  consists of:

  (ns depExp
   (:gen-class))

  (import '(java.applet Applet)
         '(java.io File)
         '(java.net URL))

  (defn -main [ args]
   (.play (Applet/newAudioClip (clojure.java.io/resource
  looncall.au

  ;;;BTW, the looncall.au is a small sound file;;;

  ...which works fine in the REPL and it also compiles but the resulting
  standalone jar file throws an error: main
  java.lang.NullPointerException.   Am using lein uberjar.   ???

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

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


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


Re: including sound or image files with Leiningen uberjar command

2011-09-16 Thread Dave Ray
Note that this implementation is the same as (clojure.java.io/resource) [1].

Dave


[1] 
https://github.com/clojure/clojure/blob/3a3374f714e5a755b7de2a761f37696f07a74e80/src/clj/clojure/java/io.clj#L422

On Fri, Sep 16, 2011 at 8:58 AM, willyh wheine...@gmail.com wrote:
 I use the following helper function:

 (defn getResource
  Load resource. This is guaranteed to work with JNLP'd jars.
  [resource-string]
  (.getResource (.getContextClassLoader (Thread/currentThread))
 resource-string))

 Note the comment. I had a lot of trouble loading resources when my
 uberjars were deployed via JNLP.

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

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


  1   2   >