Clojure for configuration files like with emacs

2009-01-06 Thread BerlinBrown

I want to build a clojure application that has config files like with
emacs (not that complex but close).  I am guessing I need to call the
eval  and load script to load a configuration file, but I was trying
to avoid having the configuration file effect the state of the main
running application.

Does anyone have any tips of example code I could use.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Creating classes/Sub classes in clojure

2009-01-09 Thread BerlinBrown

Is it better style to use the 'proxy'ing to create a class or to use
the gen-class approach.

-

(ns net.n01se.MyThread
  (:gen-class
:extends "java.lang.Thread"
:constructors {[] [String]}
:init my-init
:state myState
:exposes-methods {getId getIdSuper}))

(defn -my-init []
  (prn :init-my-thread)
  [["my derived class"] "this is my state"])

(defn -getId [this]
  (+ 123000 (.getIdSuper this)))

And I couldn't get this code to work, so I guess I will stick with
proxy
---

Here is some action listener code:

(defn create-shell [disp sh]
  ;; Note change in 'doto' call, dot needed.
  (let [layout (new GridLayout)]
(doto sh
  (. setText (. resources getString "Window_title"))
  (. setAccelerator (str SWT/MOD1 "O"))
  (. setLayout layout)
  (. addShellListener (proxy [ShellAdapter] []
 (shellClosed [evt]
  (exit)))

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



Strange 'new' constructor error

2009-01-09 Thread BerlinBrown

Does anyone see what I am doing here.  I am creating some SWT code.



(import '(org.eclipse.swt.widgets Display Shell Text Widget))
(import '(org.eclipse.swt.widgets Label Menu MenuItem Control))
(import '(org.eclipse.swt.widgets FileDialog MessageBox))



(defn create-menu-bar [sh]
  (let [bar (new Menu sh (. SWT BAR))]
(. sh setMenuBar bar)
(doto bar
  (. (new MenuItem (. SWT CASCADE)))
  (. setText (. resources getString "Window_title")

-

Here is some similar code that works,

(defn build-menu-bar [sh]
  (let [menu-bar (new Menu sh (. SWT BAR))]
(doto (new MenuItem menu-bar (. SWT CASCADE))
  (setText "&File"))
menu-bar))

But I keep getting this error.

java.lang.IllegalArgumentException: No matching method found: new for
class org.
eclipse.swt.widgets.Menu (octane_main.clj:0)
at clojure.lang.Compiler.eval(Compiler.java:4153)
at clojure.lang.Compiler.load(Compiler.java:4470)
at clojure.lang.Compiler.loadFile(Compiler.java:4437)
at clojure.lang.Repl.main(Repl.java:66)
Caused by: java.lang.IllegalArgumentException: No matching method
found: new for
 class org.eclipse.swt.widgets.Menu
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:
48)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:
28)
at user$create_menu_bar__50.invoke(octane_main.clj:71)
at user$simple_swt__68.invoke(octane_main.clj:99)
at user$main__72.invoke(octane_main.clj:116)
at user$eval__75.invoke(octane_main.clj:118)
at clojure.lang.Compiler.eval(Compiler.java:4142)
... 3 more
Clojure

Here is the constructor of the Super Class of Menu.
public Widget(Widget arg0, int arg1)


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



Example Java oriented SWT GUI application in Clojure

2009-01-12 Thread BerlinBrown

Here is an example SWT application.  It is a 'search' tool.  Open a
file and the search term is highlighted.  It has a java oriented
approach because I copied the java code verbatim.  This might be
useful if you are still used to imperative programming.

Main source:
http://jvmnotebook.googlecode.com/svn/trunk/clojure/swt/search/src/octane_main.clj

Additional Files (all you really need is what is in the lib directory)
http://jvmnotebook.googlecode.com/svn/trunk/clojure/swt/search

But, I am all ears for suggestions (I am sure there are very, very
many) and if you want, send me a patch file, I will be glad to update
it.

Might help for newbies like 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
To unsubscribe from 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: Strange 'new' constructor error

2009-01-12 Thread BerlinBrown

Just a bug in my code, sorry.

On Jan 9, 6:49 pm, BerlinBrown  wrote:
> Does anyone see what I am doing here.  I am creating someSWTcode.
>
> 
>
> (import '(org.eclipse.swt.widgets Display Shell Text Widget))
> (import '(org.eclipse.swt.widgets Label Menu MenuItem Control))
> (import '(org.eclipse.swt.widgets FileDialog MessageBox))
>
> (defn create-menu-bar [sh]
>   (let [bar (new Menu sh (.SWTBAR))]
> (. sh setMenuBar bar)
> (doto bar
>   (. (new MenuItem (.SWTCASCADE)))
>   (. setText (. resources getString "Window_title")
>
> -
>
> Here is some similar code that works,
>
> (defn build-menu-bar [sh]
>   (let [menu-bar (new Menu sh (.SWTBAR))]
> (doto (new MenuItem menu-bar (.SWTCASCADE))
>   (setText "&File"))
> menu-bar))
>
> But I keep getting this error.
>
> java.lang.IllegalArgumentException: No matching method found: new for
> class org.
> eclipse.swt.widgets.Menu (octane_main.clj:0)
> at clojure.lang.Compiler.eval(Compiler.java:4153)
> at clojure.lang.Compiler.load(Compiler.java:4470)
> at clojure.lang.Compiler.loadFile(Compiler.java:4437)
> at clojure.lang.Repl.main(Repl.java:66)
> Caused by: java.lang.IllegalArgumentException: No matching method
> found: new for
>  class org.eclipse.swt.widgets.Menu
> at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:
> 48)
> at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:
> 28)
> at user$create_menu_bar__50.invoke(octane_main.clj:71)
> at user$simple_swt__68.invoke(octane_main.clj:99)
> at user$main__72.invoke(octane_main.clj:116)
> at user$eval__75.invoke(octane_main.clj:118)
> at clojure.lang.Compiler.eval(Compiler.java:4142)
> ... 3 more
> Clojure
>
> Here is the constructor of the Super Class of Menu.
> public Widget(Widget arg0, int arg1)
>
> Strange.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Example Java oriented SWT GUI application in Clojure

2009-01-13 Thread BerlinBrown



On Jan 12, 9:58 pm, e  wrote:
> thanks.  I think this will be useful, but I have to figure out how to get it
> to build in enclojure.  Right now I get, "Exception in thread "main"
> java.util.MissingResourceException: Can't find bundle for base name
> octane_main, locale en_US (octane_main.clj:136)"
>
> On Mon, Jan 12, 2009 at 5:24 PM, BerlinBrown  wrote:
>
> > Here is an example SWT application.  It is a 'search' tool.  Open a
> > file and the search term is highlighted.  It has a java oriented
> > approach because I copied the java code verbatim.  This might be
> > useful if you are still used to imperative programming.
>
> > Main source:
>
> >http://jvmnotebook.googlecode.com/svn/trunk/clojure/swt/search/src/oc...
>
> > Additional Files (all you really need is what is in the lib directory)
> >http://jvmnotebook.googlecode.com/svn/trunk/clojure/swt/search
>
> > But, I am all ears for suggestions (I am sure there are very, very
> > many) and if you want, send me a patch file, I will be glad to update
> > it.
>
> > Might help for newbies like me.

Yea, if you see the parent folder, get the octane_main property file.
It is needed by the app.

http://jvmnotebook.googlecode.com/svn/trunk/clojure/swt/search
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Clojure style question, mutable global data structures using Java?

2009-01-16 Thread BerlinBrown

I am working on this GUI tool and want to keep 'global' data
structures in memory.  For example, lets say I have a checkbox and
want to be able to keep and access the state of that checkbox at any
time.  Right now, I am thinking the easiest thing to do is using a
Java hashmap and change the state when needed.

(def my-map (new HashMap))

(defn init-hash-map []
  (. my-map put "checkbox-state" "false"))

(defn get-checkbox-state []
   (. my-map get "checkbox-state"))

...
...

Is this bad clojure or lisp code (probably is), but what are some
other approaches?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 style question, mutable global data structures using Java?

2009-01-16 Thread BerlinBrown



On Jan 16, 11:10 am, BerlinBrown  wrote:
> I am working on this GUI tool and want to keep 'global' data
> structures in memory.  For example, lets say I have a checkbox and
> want to be able to keep and access the state of that checkbox at any
> time.  Right now, I am thinking the easiest thing to do is using a
> Java hashmap and change the state when needed.
>
> (def my-map (new HashMap))
>
> (defn init-hash-map []
>   (. my-map put "checkbox-state" "false"))
>
> (defn get-checkbox-state []
>(. my-map get "checkbox-state"))
>
> ...
> ...
>
> Is this bad clojure or lisp code (probably is), but what are some
> other approaches?

I hear that in Erlang, you can use processes to work with mutable
state.  And some say that Clojure has some similar functionality.
Should I use 'ref' or 'agent' to do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 style question, mutable global data structures using Java?

2009-01-16 Thread BerlinBrown



On Jan 16, 11:49 am, Christophe Grand  wrote:
> BerlinBrown a écrit :
>
> > On Jan 16, 11:10 am, BerlinBrown  wrote:
>
> >> I am working on this GUI tool and want to keep 'global' data
> >> structures in memory.  For example, lets say I have a checkbox and
> >> want to be able to keep and access the state of that checkbox at any
> >> time.  Right now, I am thinking the easiest thing to do is using a
> >> Java hashmap and change the state when needed.
>
> > Should I use 'ref' or 'agent' to do this?
>
> Yes!http://clojure.googlegroups.com/web/clojure-conc.pngsummarizes the
> differences between atoms, refs and agents.
> (and the fine doc tells you the details.)
>
> I think you need an atom or a ref:
>
> (def my-map (ref {:checkbox-state false}))
>
> (defn get-checkbox-state []
>(@my-map :checkbox-state))
>
> (defn set-checkbox-state [state]
>   (dosync (commute my-map assoc :checkbox-state state)))
>
> Christophe

Thanks all, this is what I ended up with:
For noobs like myself,  I am using this code to monitor files and
refresh it when the file gets modified.  I used 'ref' and 'agent'.

(def  file-monitor-agent (agent false))
(def  file-state (ref {:open-state false}))
(defn get-file-state [] (@file-state :open-state))
(defn set-file-state [state] (dosync (commute file-state assoc :open-
state state)))

(defn file-monitor-loop []
  (let [delay-t (prop-int resources-core-sys
"Octane_Sys_filemonitor_delay")
enable-file-mon (prop-bool resources-win-opts
"file_monitor_enabled")]
(send file-monitor-agent
  (fn [_]
  (when enable-file-mon
(loop []
  (when (not (. shell (isDisposed)))
(. Thread sleep delay-t)
(println "Woot!!!")
(recur
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 style question, mutable global data structures using Java?

2009-01-16 Thread BerlinBrown



On Jan 16, 12:47 pm, Christophe Grand  wrote:
> BerlinBrown a écrit :
>
> > Thanks all, this is what I ended up with:
> > For noobs like myself,  I am using this code to monitor files and
> > refresh it when the file gets modified.  I used 'ref' and 'agent'.
>
> > (def  file-monitor-agent (agent false))
> > (def  file-state (ref {:open-state false}))
> > (defn get-file-state [] (@file-state :open-state))
> > (defn set-file-state [state] (dosync (commute file-state assoc :open-
> > state state)))
>
> > (defn file-monitor-loop []
> >   (let [delay-t (prop-int resources-core-sys
> > "Octane_Sys_filemonitor_delay")
> > enable-file-mon (prop-bool resources-win-opts
> > "file_monitor_enabled")]
> > (send file-monitor-agent
> >   (fn [_]
> >   (when enable-file-mon
> > (loop []
> >   (when (not (. shell (isDisposed)))
> > (. Thread sleep delay-t)
> > (println "Woot!!!")
> > (recur
>
> Since the action you send to your agent doesn't end you should send it
> using send-off ('send-off will give your action its own thread while
> 'send use a fixed thread pool).
> But, given that you don't care about the agent value, it would be better
> to simply use a thread (clojure's fns are Runnables):
>
> (defn file-monitor-loop []
>   (let [delay-t (prop-int resources-core-sys
> "Octane_Sys_filemonitor_delay")
> enable-file-mon (prop-bool resources-win-opts
> "file_monitor_enabled")]
> (when enable-file-mon
>   (.start (Thread.
> #(while (not (.isDisposed shell))
>(Thread/sleep delay-t)
>(println "Woot!!!")))
>
> Christophe

What is the '#' in this example.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Not nil and 'true' with conditional functions

2009-01-23 Thread BerlinBrown

Here is some code, my question relates to '(not (nil?...':

 (if (not (nil? (regex-search-keyword (regex-get-text) line)))
(add-select-style styles-vec all-bold)
(add-select-style styles-vec light)))

Could I have done the following or is (not (nil? ... a better
approach.

 (if (regex-search-keyword (regex-get-text) line))) 

What are the differences between the two.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Simple lisp like idiom in clojure, call function and keep the result

2009-01-23 Thread BerlinBrown

What is an idiom to call a function and also retain the result.  For
example, I see myself doing this a lot, but it seems to more code than
would be needed.

(let [a (some-func)]
  (when a
(println (a dosomething

-

I wish I could avoid having to use the 'let' in this case

I guess in python/ruby, this is something like this.

print a.dosomething() ; if a


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



'ls.c'/csv fixed space style directory listing, figure out the formatting to issues

2009-01-26 Thread BerlinBrown

I want to output a directory with a similar listing (see below), but
only a fixed number of spaces.  Is there  a clojure approach to
already do this.

-rw 13290 1216183460872 LispExample_Flow.png
-rw 3211 1217537516267 PDFReport.java

I think in Common Lisp, the powerful 'format' could make this happen
probably in one line.  Anyone conjure a clojure approach?

Basically, I need output with a fixed number of columns, I guess I use
an 'array' of 20 spaces and then fill then fill the array with
content.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: 'ls.c'/csv fixed space style directory listing, figure out the formatting to issues

2009-01-26 Thread BerlinBrown



On Jan 26, 4:47 pm, "Stephen C. Gilardi"  wrote:
> On Jan 26, 2009, at 4:31 PM, BerlinBrown wrote:
>
> > I want to output a directory with a similar listing (see below), but
> > only a fixed number of spaces.  Is there  a clojure approach to
> > already do this.
>
> > -rw 13290 1216183460872 LispExample_Flow.png
> > -rw 3211 1217537516267 PDFReport.java
>
> > I think in Common Lisp, the powerful 'format' could make this happen
> > probably in one line.  Anyone conjure a clojure approach?
>
> Clojure provides easy access to Java's "format" method via
> clojure.core/format .
>
> Here's one way to produce fixed width fields:
>
> user> (def lines [["-rw" "13290" "1216183460872" "LispExample_Flow.png"]
> ["-rw" "3211" "1217537516267" "PDFReport.java"]])
> #'user/lines
>
> user> (doseq [line lines]
>  (println (apply format "%3s %5s %15s %s" line)))
> -rw 13290   1216183460872 LispExample_Flow.png
> -rw  3211   1217537516267 PDFReport.java
> nil
>
> user>
>
> You may also find clojure.core/printf helpful with this.
>
> --Steve
>
>  smime.p7s
> 3KViewDownload

Perfect, thanks.  Great community here.  The lispers would have just
shot me down.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Junit and Clojure and the new gen-class

2009-02-11 Thread BerlinBrown

I asked this on IRC yesterday.  I think Chouser had a good suggestion
but I forgot what it was.

I am trying to use Junit to generate tests with Clojure.  May not be
the best to use junit but I was going to try anyway.

main.clj:
(compile 'test.OctaneTestGen)


(ns test.OctaneTestGen
(:gen-class
 :extends junit.framework.TestCase
 :methods [[testDog [] void]]))

(defn -init [] ())

(defn -testDog []
  (println "Dog"))

I tried this and get the following error.  Regardless, I still don't
know the best way to ensure that those 'test' methods are available
for junit.  I am assuming the proxying done at the gen-class level is
not being liked by junit.

.E
Time: 0.015
There was 1 error:
1) testDog(test.OctaneTestGen)java.lang.IllegalArgumentException:
Wrong number o
f args passed to: OctaneTestGen$-testDog
at clojure.lang.AFn.throwArity(AFn.java:450)
at clojure.lang.AFn.invoke(AFn.java:53)
at test.OctaneTestGen.testDog(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
Source)
at test.OctaneTestGen.runTest(Unknown Source)
at test.OctaneTestGen.runBare(Unknown Source)
at test.OctaneTestGen.run(Unknown Source)

FAILURES!!!
Tests run: 1,  Failures: 0,  Errors: 1

Anyone havea  suggestion.

I am using junit-4.4

Thanks
-- Berlin Brown
http://berlinbrowndev.blogspot.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
To unsubscribe from 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: Junit and Clojure and the new gen-class

2009-02-11 Thread BerlinBrown



On Feb 11, 11:56 am, ".Bill Smith"  wrote:
> Is it fair to say you really want to use Junit rather than the test
> framework in clojure-contrib?   I can think of reasons why you might
> want to use Junit but I don't want to put words in your mouth.
>
> Bill

"I am trying to use Junit to generate tests with Clojure.  May not be
the best to use junit but I was going to try anyway. "
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Junit and Clojure and the new gen-class

2009-02-11 Thread BerlinBrown



On Feb 11, 12:21 pm, Stuart Sierra 
wrote:
> On Feb 11, 11:46 am, BerlinBrown  wrote:
>
> > (defn -init [] ())
>
> > (defn -testDog []
> >   (println "Dog"))
>
> There's your problem: Java methods always need an extra first
> argument, the object on which the method was called.  It's like the
> "this" keyword in Java.
>
> -Stuart Sierra

Thanks.  This is what I ended up with for others that want to do the
same thing.  Junit 4.4 with Clojure 12/2008 version:

(compile 'test.OctaneTestGen)

(ns test.OctaneTestGen
(:import (junit.framework Assert))
(:gen-class
 :extends junit.framework.TestCase))

(defn -init [_] ())

(defn -testDog [_]
  (println "Dog")
  (Assert/fail "Test not implemented"))

(defn -testDog2 [_]
  (println "Dog"))

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Junit and Clojure and the new gen-class

2009-02-11 Thread BerlinBrown



On Feb 11, 12:39 pm, BerlinBrown  wrote:
> On Feb 11, 12:21 pm, Stuart Sierra 
> wrote:
>
> > On Feb 11, 11:46 am, BerlinBrown  wrote:
>
> > > (defn -init [] ())
>
> > > (defn -testDog []
> > >   (println "Dog"))
>
> > There's your problem: Java methods always need an extra first
> > argument, the object on which the method was called.  It's like the
> > "this" keyword in Java.
>
> > -Stuart Sierra
>
> Thanks.  This is what I ended up with for others that want to do the
> same thing.  Junit 4.4 with Clojure 12/2008 version:
>
> (compile 'test.OctaneTestGen)
>
> (ns test.OctaneTestGen
> (:import (junit.framework Assert))
> (:gen-class
>  :extends junit.framework.TestCase))
>
> (defn -init [_] ())
>
> (defn -testDog [_]
>   (println "Dog")
>   (Assert/fail "Test not implemented"))
>
> (defn -testDog2 [_]
>   (println "Dog"))


And it doesn't like the 'lisp' style names.


(defn -test-dog [_]
  (println "Dog")
  (Assert/fail "Test not implemented"))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Junit and Clojure and the new gen-class

2009-02-11 Thread BerlinBrown



On Feb 11, 12:58 pm, Stuart Halloway 
wrote:
> Hi Berlin,
>
> Your testDog needs a 'this' argument:
>
> (defn -testDog [this]
>   (println "Dog called on " this))
>
> I played with generating JUnit classes when I started writing the
> book, and unless you have a specific need I would recommend using
> something like test-is for Clojure testing.
>
> Cheers,
> Stuart
>
>
>
> > I asked this on IRC yesterday.  I think Chouser had a good suggestion
> > but I forgot what it was.
>
> > I am trying to use Junit to generate tests with Clojure.  May not be
> > the best to use junit but I was going to try anyway.
>
> > main.clj:
> > (compile 'test.OctaneTestGen)
>
> > (ns test.OctaneTestGen
> >(:gen-class
> > :extends junit.framework.TestCase
> > :methods [[testDog [] void]]))
>
> > (defn -init [] ())
>
> > (defn -testDog []
> >  (println "Dog"))
>
> > I tried this and get the following error.  Regardless, I still don't
> > know the best way to ensure that those 'test' methods are available
> > for junit.  I am assuming the proxying done at the gen-class level is
> > not being liked by junit.
>
> > .E
> > Time: 0.015
> > There was 1 error:
> > 1) testDog(test.OctaneTestGen)java.lang.IllegalArgumentException:
> > Wrong number o
> > f args passed to: OctaneTestGen$-testDog
> >at clojure.lang.AFn.throwArity(AFn.java:450)
> >at clojure.lang.AFn.invoke(AFn.java:53)
> >at test.OctaneTestGen.testDog(Unknown Source)
> >at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> >at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > Source)
> >at test.OctaneTestGen.runTest(Unknown Source)
> >at test.OctaneTestGen.runBare(Unknown Source)
> >at test.OctaneTestGen.run(Unknown Source)
>
> > FAILURES!!!
> > Tests run: 1,  Failures: 0,  Errors: 1
>
> > Anyone havea  suggestion.
>
> > I am using junit-4.4
>
> > Thanks
> > -- Berlin Brown
> >http://berlinbrowndev.blogspot.com

I also had to add the following.

the 'methods' argument.

(ns test.OctaneTestGen
(:import (junit.framework Assert))
(:gen-class
 :methods [[testDog [] void]]
 :extends junit.framework.TestCase))


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



Possible bug, NullPointerException for undefined proxy interface or super-class

2009-02-15 Thread BerlinBrown

I don't know if this is expected, but I get  a Nullpointerexception
when I implement a proxy function and the 'interface' isn't
'imported'.  For example, I was refactoring some code and didn't carry
over the import and get this nullpointerexception error. Obviously, I
should just add the import, but I wish the error message were more
descriptive.

Copied this code:

Note: I didn't define the import 'ShellAdapter'

(defn shell-close-adapter
  " Create a proxy used with a SWT widget 'addShellListener'"
  [cur-shell]
  ;
  (proxy [ShellAdapter][]
 (shellClosed [event]
  (set! (. event doit) false)
  (. cur-shell setVisible false


---


java.lang.NullPointerException (octane_utils.clj:131)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4113)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.analyze(Compiler.java:3908)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3613)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3456)
at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:3335)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2921)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4104)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.access$100(Compiler.java:38)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:366)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4094)
at clojure.lang.Compiler.analyze(Compiler.java:3935)
at clojure.lang.Compiler.analyze(Compiler.java:3908)
at clojure.lang.Compiler.eval(Compiler.java:4146)
at clojure.lang.Compiler.load(Compiler.java:4470)
at clojure.lang.RT.loadResourceScript(RT.java:327)
at clojure.lang.RT.loadResourceScript(RT.java:316)
at clojure.lang.RT.load(RT.java:406)
at clojure.lang.RT.load(RT.java:376)
at clojure.core$load__4557$fn__4559.invoke(core.clj:3427)
at clojure.core$load__4557.doInvoke(core.clj:3426)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.core$load_one__4520.invoke(core.clj:3271)
at clojure.core$load_lib__4540.doInvoke(core.clj:3308)
at clojure.lang.RestFn.applyTo(RestFn.java:147)
at clojure.core$apply__2869.doInvoke(core.clj:374)
at clojure.lang.RestFn.invoke(RestFn.java:443)
at clojure.core$load_libs__4544.doInvoke(core.clj:3334)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply__2869.doInvoke(core.clj:374)
at clojure.lang.RestFn.invoke(RestFn.java:460)
at clojure.core$use__4551.doInvoke(core.clj:3404)
at clojure.lang.RestFn.invoke(RestFn.java:938)
at user$eval__1.invoke(octane_main_window.clj:28)
at clojure.lang.Compiler.eval(Compiler.java:4142)
at clojure.lang.Compiler.load(Compiler.java:4470)
at clojure.lang.Compiler.loadFile(Compiler.java:4437)
at clojure.lang.Repl.main(Repl.java:66)
Caused by: java.lang.NullPointerException
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26)
at clojure.core$get_super_and_interfaces__4708.invoke(core_proxy.clj:
195)
at clojure.core$proxy__4729.doInvoke(core_proxy.clj:270)
at clojure.lang.RestFn.invoke(RestFn.java:445)
at clojure.lang.Var.invoke(Var.java:335)
at clojure.lang.AFn.applyToHelper(AFn.java:180)
at clojure.lang.Var.applyTo(Var.java:444)
at clojure.lang.Compiler.macroexpand1(Compiler.java:4025)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4092)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 Off-topic IRC channel

2009-02-17 Thread BerlinBrown



On Feb 17, 8:23 am, Rayne  wrote:
> A week or 2 ago, Lau_Of_DK asked me very nicely to stop talking so off-
> topic in #Clojure. I mentioned that we should have an Off-topic
> channel for people who would just like to talk, because just about
> every other language's channel on freenode has an off topic channel
> (#haskell-blah for instance). He said it has been discussed and
> because of the low volume of #clojure (which isn't so low if you think
> about it), it would not be a good idea. I just went along with that.
> But today I thought about it, and I haven't seen it discussed and if
> it has been discussed here before I'm sorry, but I'd like other
> peoples input on this. I feel that making an off topic channel for
> Clojurists would not effect the volume of #Clojure in any way. In fact
> I feel that it would remove any current, or future extensive off topic
> chatter in #Clojure and help to keep things on tract. If people want
> to talk off topic they can come to the off topic channel, and if they
> don't want to talk about #Clojure, they probably wouldn't be there in
> the first place. How would it effect #Clojure's volume? I personally
> think having an off topic channel is a great idea, but it's not my
> language and #Clojure isn't my channel.
>
> I have made a channel on freenode called #Clojure-Offtopic for now it
> is explicitly marked as unofficial and waiting for Rich Hickey's
> approval. If for some reason, you guys /really/ don't want an off
> topic channel, I have respect enough to remove the channel for you
> guys. I will not announce this channel in #Clojure until I have the
> communities approval. It seems I've attracted durka to the channel
> somehow though :p.
>
> I'm sorry if this topic isn't right for this group, but I'm not sure
> where else I should discuss it.
>
> -Rayne

The IRC nazis are just that.  IRC is on the internet.  IRC is not some
CIA/FBI stream of information.  I think off-topic should be allowed in
most IRC channels and in most it is.  It is a virtual community.
Community implies communal discussions.  That sometimes veer from the
core topic.  I started out on freenode on #java and they were liberal
about off-topic and it was a great way to interact with cool people.
The more stand-offish channels are easily forgettable.

There are really only two ways to run IRC, no off-topic or off-topic.
The no off-topic channels suck.

With that, I think it is silly to create a clojure-offtopic, offtopic
should be OK sometimes in #clojure.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Static member and classes

2009-02-18 Thread BerlinBrown

I was trying to access a public inner class and a field within that
field.  For example:


 fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);

public abstract class FileChannel

public static class MapMode {

public static final MapMode READ_ONLY
= new MapMode("READ_ONLY");


.

This is what I tried and got the following error.

  mm  (. java.nio.channels.FileChannel MapMode)
bb  (. fc map (. mm READ_ONLY) 0 sz)

Caused by: java.lang.NoSuchFieldException: MapMode
at java.lang.Class.getField(Unknown Source)
at clojure.lang.Compiler$StaticFieldExpr.(Compiler.java:
962)
at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:
746)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:4106)
... 60 more
Clojure
user=>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Example use of agent with macro

2009-02-19 Thread BerlinBrown

I am working with this SWT application.  For most calls with SWT, if
you want to request data from a widget, then you must do so through
the  syncExec or asynExec.  These methods require an implementation of
runnable as an argument.

This works fine for 'setting' a value, but I have trouble when I need
to get a value from a widget, like a Textarea.  This is the macro that
I created and it runs, but I don't think it is working properly.  Does
anyone have suggestions?

Usage:
term(get-sync-call disp (. box getText))

(defmacro get-sync-call
  "Synchronous execute call.  Create a proxy Runnable object and then
execute the
 body code"
  [disp & body]
  ;;
  `(let [val-res# (agent nil)]
 ;;(. ~disp syncExec
 (. ~disp syncExec (proxy [Runnable] [] (run [] (send val-res# (fn
[_#] ~...@body)
 @val-res#))
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: how to learn clojure ?

2009-02-19 Thread BerlinBrown



On Feb 19, 11:39 am, Stuart Halloway 
wrote:
> Thanks for the kind words, David. I hope many people will like
> Programming Clojure and find it useful.
>
> Clojure has a *ton* of goodness in it. I think many of the chapters in
> Programming Clojure book could usefully be followed with an entire
> book. Here is a partial list of recommendations for companion reading:
>
> For Java Interop:
> * The JVM spec (free online). Know your platform. :-)
>
> For Functional Programming:
> * Real World Haskell (free online)
>
> For Concurrency:
> * Java Concurrency in Practice
>
> For Macros:
> * On Lisp (free online)
>
> For Lisp in General:
> * Practical Common Lisp (free online)
> * Paradigms of AI Programming
>
> For Multimethods:
> * The Art of the Metaobject Protocol
>
> Just Because:
> * Structure and Interpretation of Computer Programs
>
> Cheers,
> Stuart
>
> > Of course I beg to differ.  The Stuart Halloway's book is fantastic
> > of course, I have it myself.  It's absolutely required reading.
> > Stuart does his best to describe the ins and outs of the language
> > while giving a crash course on the Lisp philosophy.  And yes Clojure
> > is syntactically different from Scheme and Common Lisp, however many
> > of the non-Clojure texts suggested do a better job explaining the
> > deeper why's of Lisp programming, concepts that go beyond the
> > particular implementation.  In fact I would probably recommend the
> > Structure and Interpretation of Computer Programs as the
> > indispensable Lisp text above all others.
>
> > But thats just MHO.
>
> > David
>
> > On Thu, Feb 19, 2009 at 8:46 AM, Rayne 
> > wrote:
>
> > Telling someone to read a book that isn't even focused on the language
> > he's trying to learn isn't a great way to help them. Tell him to read
> > Programming Clojure or something, anything but Common Lisp and Scheme
> > books, he isn't learning those languages he's learning Clojure. There
> > is enough information around on Clojure that someone shouldn't be
> > forced to read a book on a completely different language.
>
> > No offense guys.



Another good way to learn clojure is to convert Java code to clojure
code and compare and contrast.  I assume you know Java, I have found,
I can take a any piece of Java code and rewrite it in Clojure.  On the
first try, it might look call for call like the Java code.  On the
refactoring, I will clean it up to make it more lisp like.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Example use of agent with macro

2009-02-19 Thread BerlinBrown



On Feb 19, 11:58 am, BerlinBrown  wrote:
> I am working with this SWT application.  For most calls with SWT, if
> you want to request data from a widget, then you must do so through
> the  syncExec or asynExec.  These methods require an implementation of
> runnable as an argument.
>
> This works fine for 'setting' a value, but I have trouble when I need
> to get a value from a widget, like a Textarea.  This is the macro that
> I created and it runs, but I don't think it is working properly.  Does
> anyone have suggestions?
>
> Usage:
> term(get-sync-call disp (. box getText))
>
> (defmacro get-sync-call
>   "Synchronous execute call.  Create a proxy Runnable object and then
> execute the
>  body code"
>   [disp & body]
>   ;;
>   `(let [val-res# (agent nil)]
>  ;;(. ~disp syncExec
>  (. ~disp syncExec (proxy [Runnable] [] (run [] (send val-res# (fn
> [_#] ~...@body)
>  @val-res#))


(defmacro get-sync-call
  "Synchronous execute call.  Create a proxy Runnable object and then
execute the
 body code"
  [disp & body]
  ;;
  `(let [val-res# (ref nil)]
 ;;(. ~disp syncExec (proxy [Runnable] [] (run [] (send val-res#
(fn [_#] ~...@body)
 (. ~disp syncExec (proxy [Runnable] [] (run [] (dosync (ref-set
val-res# ~...@body)
 (. Thread sleep 50)
 (deref val-res#)))

OK, I added this, don't know why I added Thread.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



General Question Clojure(Lisp) Idiom, cross cutting? What is the terminology

2009-02-20 Thread BerlinBrown

This is a general termingology question.  What is this idiom, called
where you pass a function as an argument to another function and then
use that function with in a loop.  I thought it reminded me of that
aspect oriented programming?  cross cutting of concerns?

For example, I do that a lot, where I loop through a file and then
want to call a function on one particular line string.

(defn my-func [line no]
  ...
  ...

---

(defun something
(loop [srch-res? (. lm find) line-no 0]
  (when srch-res?
   
(my-func (. lm group) line-no)
  ***

(recur (. lm find) (+ line-no 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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Example JUnit 4.4 use with Clojure

2009-02-28 Thread BerlinBrown

If you want to use junit with clojure, this is what I ended up doing.
Yes, I know there are many clojure test frameworks.  But if you are
stuck with a junit mind, then here is an example approach.

http://clojure.googlegroups.com/web/junit_example_clojure.clj?gsc=rSQdQgsBq71IhmeUYhS87PjFY2mX

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



First Clojure Application, Light Text Editor in Clojure/SWT

2009-03-05 Thread BerlinBrown

http://code.google.com/p/lighttexteditor/

* Simple text editor.
* Simple File Manager for accessing important files quickly.
* Search tools using Linux or Win32 applications (unxutils).
* Built on Java 1.5 and the Clojure programming language.

It is a simple text editor and one critical feature is missing, can't
save files.  I am working on that, should be available by the weekend.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Clojure in Atlanta, Meetup event on

2009-03-10 Thread BerlinBrown

http://leafhopper.github.com/clojure.html

   1. Step through the Programming Clojure book.
   2. Reinforce above by creating a draft of an online course
mimicking the style of Ruby Learning.
  * read material
  * review a list of important points
  * do (create) a few exercises related to the material and
discuss in a forum
  * take (create) a multiple choice test

  RubyLearning.com online courses provide a fun & simple way to
learn something new.
  So the next best thing to taking a fun & simple course for
clojure would be to create one.
  Please note that I have little experience in Clojure and am
using this method to learn it.
  You are welcome to join in.

I got the following email today, related to a Clojure group in
Atlanta.

I guess this is only relevant for those that are close to Atlanta.
But Clojure groups by locale are always a good thing.  There is a very
strong J2EE/Ruby community in Atlanta.  Hopefully that can also
include some Clojure.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Clojure Web Framework, what I want to add

2009-03-16 Thread BerlinBrown

After many years (decade) of web development, here are the things that
I want in a framework, mostly based in clojure:

What do you think and what you add.  This is ambitious and just a
"ideas" of what I would add.  What would you want from your ideal
framework?

1. Based on Spring Framework for middleware:
Reason: there are years and years and years of development spent on
spring and there are many things done right.  If I were integrating
with any other third party libraries, I would use spring.  Spring is
added to my framework.

2. Based on Hibernate for ORM mapping:
Reason: the defacto standard for ORM mapping with Java.  And also used
by NHibernate.  There is a lot of support for most popular databases.

3. Clojure/Lisp based configuration AND default XML configurations.
This has become the standard way to configure a J2EE web application
including spring and hibernate.  But I would like a lisp oriented
configuration.

4. Easy mapping to URLs.  I like python's approach for URL mapping

5. Clojure based, framework based server pages AND JSPs.  I have
always hated some aspects of JSP and ASPs, etc, etc.  They are just
too complicated.  I would want to use Clojure code within the
framework oriented server page and other predefined tags.

5. Lift like reusable server pages.  Lift has an interesting approach
for resuing the same page.  E.g. you have an if-else statement within
the page.

If request == GET
...render this
if request == POST
 ...render this.
if URL == 'abc.html'
 .. render this.

I want to embed this in my framework.  You only touch one page, but
you get different outputs depending on the request method or URL, etc,
etc.

6. Use of Clojure syntactic sugar -- TO BE DETERMINED.   There is the
ability to use powerful Clojure constructs  with this framework but I
haven't figured out how yet.

7. Better integration of CSS, Javascript, HTML.   A lot of a web
application still resides with the client side.   I have yet to see an
web framework that addresses client development (besides GWT).   Maybe
something as simple as server page tags for CSS?  Javascript?

8.  Additional third party libraries:

Lucene, iText, jFreeChart, optional Terracotta integration


Other optional/additional thoughts.

9. Clear separation between back-end and front-end layers


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



Suggestion for Java Clojure code, use of checkstyle or code formatter

2009-03-23 Thread BerlinBrown

I was curious about how some of the clojure code worked and observed
that the coding style is a little bit non idiomatic from typical Java
coding conventions.  E.g. there aren't any javadoc comments on methods
or classes, non standard indents.

Something like checkstyle might prove useful.

http://checkstyle.sourceforge.net/

While, every programmer balks at conventions, I am sure there is a
mountain of evidence for increased overall maintenance and other
benefits.

I know, I will get suggestions for clojure/lisp coding style.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Running multiple scripts from the Java realm

2009-03-25 Thread BerlinBrown

I know it isn't advised but I have my various reasons.

What are some of the best ways to invoke clojure scripts from Java but
still maintain the state of the current session.

For example, if I run a script from Java, is there a way to ensure
that script has already been run...say if I run another script.
I was doing the following.

--

package test.toolkit.clojure;


import clojure.lang.Namespace;
import clojure.lang.RT;
import clojure.lang.Symbol;
import clojure.lang.Var;

public class TestSpringLoadClojure  {

final static private Symbol CLOJURE_MAIN = Symbol.create
("clojure.main");
final static private Namespace CLOJURE_MAIN_NS =
Namespace.findOrCreate(CLOJURE_MAIN);
final static private Var REQUIRE = Var.intern(RT.CLOJURE_NS,
Symbol.create("require"));
final static private Var LEGACY_REPL = Var.intern(CLOJURE_MAIN_NS,
Symbol.create("legacy-repl"));
final static private Var LEGACY_SCRIPT = Var.intern(CLOJURE_MAIN_NS,
Symbol.create("legacy-script"));
final static private Var MAIN = Var.intern(CLOJURE_MAIN_NS,
Symbol.create("main"));

private static void legacy_script(String[] args) throws Exception {
REQUIRE.invoke(CLOJURE_MAIN);
LEGACY_SCRIPT.invoke(RT.seq(args));
}

private static void invoke_script(String[] args) throws Exception {
LEGACY_SCRIPT.invoke(RT.seq(args));
}

public static void main(final String [] args) throws Exception {

final String [] scripts  = {  };
final String [] scripts2 = { "clj/utils/test_use_utils.clj" };
legacy_script(scripts);
Var.intern(Namespace.findOrCreate(Symbol.create("clojure")),
Symbol.create("*console*"), "abc");
invoke_script(scripts2);

}
}

But I get an error message:

 [java] java.lang.Exception: Unable to resolve symbol: *console*
in this context (test_use_utils.clj:45)
 [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute
(ExecuteJava.java:194)


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



Java code example for loading clojure code

2009-03-29 Thread BerlinBrown

Here is an example for loading clojure code.  I had trouble with this
before.  I believe that once the script is loaded, it is loaded per
JVM instance.

http://clojure.googlegroups.com/web/TestLoadClojureFromJava.java?gsc=PMri4QsAAABqmMyUtnF_kwfBAZY6oRfS

Also, any suggestions are welcome.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Every function is a thread in Clojure?

2009-04-03 Thread BerlinBrown

Someone correct me if I go wrong here.  But, from my understanding,
every defined function in Clojure is an implementation of a thread?

What is the goal in implementing in this fashion?  For example, if I
am writing in imperative style:

(println "First line")
(println "Second line")
(println "Third line")

...

The operations have to occur synchronously.  What does adding Java
threading add to the mix?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Olabani says google testing Clojure for appengine

2009-04-07 Thread BerlinBrown

http://olabini.com/blog/tag/gae/


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



Simple idiom in clojure, mutate a value

2009-06-11 Thread BerlinBrown

I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I
am using some pseudo code because I don't have a clojure solution yet.

SET UPDATEABLE_VALUE = 0
 (loop [line (.readLine reader)]
  (if (or (empty? line) (> line-num max-num))
   SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC)
(recur (.readLine reader

--

basically I want to have access to some value UPDATEABLE_VALUE outside
of the loop but also have the ability to update the
value.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Lazy load of imports

2009-06-11 Thread BerlinBrown

I have a Clojure applications with different files, different
namespaces and I have imports of classes within those files/
namespaces.

lets say

(import java.io File)
(import thepackage SomeClass)

Is it possible to lazy load the imports of the class.  For example, if
I start my app, I will get an error if thepackage.SomeClass is
unavailable.  Even though I haven't instantiated an Object of
SomeClass type.

Is it possible to dynamically set a referance to SomeClass and then do
the import.  E.g.

1. Launch Clojure application

2. Do: Class.forName("thepackage.SomeClass")

...
...
3. and then do the lazy import of (import thepackage SomeClass)

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



Memory usage in Clojure, hprof

2009-06-19 Thread BerlinBrown

This may be a throw a comment, but I was running hprof against this
SWT gui application that I have.  I have about 10,000 lines of clojure
code, so I don't know where to reduce my memory.  But I thought these
stats were interesting on the number of Clojure objects created.
Right now, the apps is eating 20MB of heap memory and here are the top
objects created:

Does anyone know when a LeafNode would be created?  Or some of those
other objects.

26625 instances of class clojure.lang.PersistentHashMap$LeafNode
8938 instances of class clojure.lang.PersistentHashMap$INode[]
8898 instances of class clojure.lang.PersistentHashMap
$BitmapIndexedNode
6009 instances of class clojure.lang.Symbol
2081 instances of class clojure.lang.PersistentArrayMap
2021 instances of class clojure.lang.PersistentList
1487 instances of class clojure.lang.Var
1426 instances of class org.eclipse.swt.graphics.TextLayout$StyleItem
1350 instances of class org.eclipse.swt.internal.win32.SCRIPT_ANALYSIS
1350 instances of class org.eclipse.swt.internal.win32.SCRIPT_STATE
960 instances of class clojure.lang.LazilyPersistentVector
574 instances of class clojure.lang.DynamicClassLoader
495 instances of class clojure.lang.PersistentVector
481 instances of class clojure.lang.APersistentVector$Seq
169 instances of class clojure.lang.Keyword
147 instances of class javax.management.MBeanAttributeInfo
120 instances of class clojure.lang.PersistentHashMap
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Type hints on primities

2009-06-19 Thread BerlinBrown

What are the type hints on primitives.
For example,

long abc = 3

is the type hint

#^long

or

#^Long

I also saw use of the java assembly? syntax before:

#^[[L?

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



Solving memory problems with Clojure code

2009-06-22 Thread BerlinBrown

I want to make it clear, that it probably isn't Clojure's memory
problem but something with my code.

Anyway, I was trying to figure out my heap memory goes up so much on
various operations in my application.  Sure, it could be anything but
I know I am doing something wrong.

Here is the application, a text editor in SWT.  When I open files, the
heap memory goes up 10 times the size of the file.  So, if I open a
3MB file, that is 30MB of heap memory used.

http://code.google.com/p/lighttexteditor/


There are also some bad designs I am using, still wouldn't explain a
10 fold increase in memory.

http://lighttexteditor.googlecode.com/svn/trunk/light_edit/src/clojure/light/toolkit/

So far, I have done a couple of things.

1. Turned on warn on reflection and reduced some of the reflection
calls by adding type hints.

2. Tried to reduce the number of calls to deref and not use "global?"
defines.

Here is the code that I think is the worst offender.  Basically, a
java oriented approach for opening a file.

(defn open-file-util [file file-path]
  #^{:doc "Use java oriented approach for loading a file into
memory" }
  ;; Java oriented approach for opening file
  (let [stream (new FileInputStream file-path)
instr (new LineNumberReader (new InputStreamReader stream))
;; Use type hints to ensure a character type.
readBuffer #^"[C" (make-array (. Character TYPE) 2048)
buf (new StringBuffer)]
(loop [n (. instr read readBuffer)]
  (when (> n 0)
(. buf append readBuffer 0 n)
(recur (. instr read readBuffer
;; File info data has been collected, set some of the file
properties
(set-file-info (. file getName)
   (. file getAbsolutePath)
   (. file lastModified)
   (. instr getLineNumber)
   (. file getParent)
   (. file canWrite)
   (. file exists)
   (. file length))
(. instr close)
(. buf toString)))

http://lighttexteditor.googlecode.com/svn/trunk/light_edit/src/clojure/light/toolkit/light_file_utils.clj


Here are some notes from my early analysis, also a google doc on the
functions that are called.
"memory profiling clojure"
http://groups.google.com/group/clojure/browse_thread/thread/b44e25f23d36b08b/296e95f743651949?lnk=gst&q=berlin+brown#296e95f743651949
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Differences between 'compiled', 'clojure interpreted', 'clojure in a jar in classpath' and 'load'

2009-06-25 Thread BerlinBrown

I have a clojure application where each file has its own namespace (ns
blah)...I generally let the files sit in a classpath directory, so I
am assuming the clojure code is loaded at startup time.

What are the differences between clojure code which is:

1. Compiled
2. Clojure code that is interpreted (that just sits in the classpath)
3. Clojure code that loads from a jar file
4. Clojure code that gets load with the 'load' function.

Just from experience, I can't tell any speed differences between any
of them except for number 4, because I normally don't use the 'load'
function.

Are there any differences are an approach you recommend.  I was a
little wary in earlier releases in uses the 'compiled' clojure code, I
seem to notice more issues with compiled code, but in Clojure 1.0 I
can't reproduce those errors.


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



General Lisp Comment: side effects with Lisp oriented languages

2009-06-26 Thread BerlinBrown

One small issue I see with Lisp languages over something like Haskell
where side effects are greatly minimized.  I tend to write code in
this style:

-
(when-let [seco-files (.getMergeFilesPrimary *main-global-state*)]
   (merge-memory-handler-primary prim-files))

Or something similar, you don't have to understand what is going on
with my logic, but if you notice 'seco-files' may return or may return
something else.  Also, getMergeFilesPrimary may throw an exception.

If I remember, some languages like Haskell give you a little bit more
power to detect what will go wrong.

How do you deal with with this in Clojure?  What is your coding style
to prevent this.  I guess I could write every function such that it
returns a value, but I normally don't.

And clojure code is certainly better than Java.

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



NoClassDef Issue, possibly my fault with the classloaders

2009-06-30 Thread BerlinBrown

Pre Notes: I put most of the code for my unit testing here:

http://groups.google.com/group/clojure/web/MostCodeIssue.java
http://groups.google.com/group/clojure/web/NoClassDefIssue.zip
http://clojure.googlegroups.com/web/MostCodeIssue.java?gsc=XGm71ws6-FUP8n2vUln2lQc9yyLJ



This is the strange no classdef not found error. Here is the scenario
which is a little different by 90% of my code works. Please ignore
that I am using Clojure, I have also done this with regular java code
and still get the same error.

Ideally, I was hoping for some help on custom classloader. My initial
thought was that I could create the classloader, add the filepath/url
of the jars to the classloader and I could launch my code. But
apparently there is some strangeness going on.

   1.   I have ONE jar file that dynamically loads 4-5 auxillary jar
files. It is built on a simple URLClassLoader. I want to do this
because I can have a user click on one jar file and launch the
application. So there is one item that the user has to worry about.
   2. By clicking on this jar file, the application loads jar files
from the filesystem. E.g. the application loads swt.jar (Eclipse's
widget toolkit) and some other jars.

3 (but don't worry about it), my application is built on Clojure (the
dynamic programming language), the first application to launch is this
Clojure script. Most of my application is within the clojure script.
4. Everything up to 1-3 works fine. The application loads and clojure
script runs, the SWT GUI application runs, etc.

   1. Here is the part that doesn't work.
   2. I have an existing java library, call it my-swt-gui.jar. That is
also a swt application. It is basically another gui application is
already built. I am trying to load the window from my current clojure/
swt application. For some reason, the JAVA oriented library won't
recognize SWT and I get noclassdef errors.

Here is the strangeness. And I will identify where I think there might
be oddities.

Entitis: A. The java oriented classloader. In the java classloader, I
launch the clojure application. SWT and other jar files are loaded
with this classloader. B. The Clojure oriented code that gets invoked
by section entity a. The clojure code is a swt based GUI application.
B works fine. C. Java code that contains another GUI window. For some
reason, this library wont load and I am getting the error, noclassdef.

NOTE: I KNOW FOR A FACT THAT the SWT class is actually in the
classpath or I would get a NoClassFound exception. I am not getting
that exception. Something else is going on.

Note: could it also be an issue with the fact that SWT includes win32
dlls? Maybe accessing the win32 dll jar the first time works but with
the java code it doesn't work? But that is strange. Why would SWT work
and then not work?
I can't show you all the code, I hope I can show you the relevant
pieces.

Here is the main classloader code:

 public static final String [] JAVA_LIBRARIES = {
"lib\\log4j-1.2.15.jar",
"lib\\octane_commons.jar",
"lib\\clojure.jar",
"lib\\swt\\win32\\swt.jar",
"lib\\jfreechart\\jcommon-1.0.15.jar",
"lib\\jfreechart\\jfreechart-1.0.12.jar",
"lib\\jfreechart\\jfreechart-1.0.12-swt.jar",
"lib\\pdf\\minium.jar",
"lib\\pdf\\tagsoup-1.2.jar",
"lib\\pdf\\core-renderer.jar",
"lib",
"conf",
"src"
};

My classloader code is based on jetty's classloader and it works OK
but I keep get ting classnotdef errors.  Strange ones.  I can see a
clear distinction between classnotfound errors.  If the file path to
the jar is invalid then I get classnotfound, easy to detect and fix.

Here is essentially the classloader code for future reference.

Classpath classpath = new Classpath();

boolean res = classpath.addComponent(libFilePath);

/// Classloader

private class Loader extends URLClassLoader {
String name;
Loader(URL[] urls, ClassLoader parent) {
super(urls, parent);
name = "StartLoader" + Arrays.asList(urls);
}

public String toString() {
return name;
}
}

 Then set the classloader
 where the URLs are the JAR libraries:
   URL [] urls = new URL[NUMBER_OF_JARS];
   for (x in urls) {
  urls[i] = new URL("THE JAR PATH");
   }

ClassLoader parent = Thread.currentThread().getContextClassLoader
();
if (parent == null) {
parent = Classpath.class.getClassLoader();
}
if (parent == null) {

parent = ClassLoader.getSystemClassLoader();
}
return new Loader(urls, parent);

/

And this is how I tried to load the java swt window. I tried to print
out as much about the classloader and change to different classloader.

public static final void createPDFWindowShell(IStartService service,
final Object shell, final Object globalClassLoader) throws Exception {

if ((service != null) && (shell != null)) {
   

Return nil/null or empty object

2009-07-02 Thread BerlinBrown

I posted a thread about side-effects.  Some one replied that your
clojure functions should return a value.  This is good advice, but I
have code that sometimes return nil.  Is it better to return 'nil' or
an object with no data.  I guess a simple example, if you have a
function that returns a string. Should you return a valid string or a
zero length string for all of your functions.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Text log viewer in clojure updates

2009-07-17 Thread BerlinBrown

Here is an update to my log viewer in clojure.  It mostly works on
win32 and I hope to get it past an alpha release., but if you are
interested in gui applications in clojure, all source is provided.

http://code.google.com/p/lighttexteditor/wiki/LightLogViewer

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



Function overriding? Way to do it, similar to in Java

2009-07-24 Thread BerlinBrown

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



Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread BerlinBrown

I was coming up with some performance tests for Clojure, going back
and forth between different JVM languages (JRuby, Scala) and mainly
looking at pure Java code.  So far I have found that clojure is about
5-10 times as slow as comparable code in Clojure.  Of course this is
before any optimizations.

Here is my question, do you have any code both Clojure and Java where
there is a one to one match between code where Clojure runs as fast as
Java.  It could be anything.

Here is one example:
This is code from clojure/contrib to convert a list of data into a
frequency count map.  Pretty standard stuff.

(defn frequencies
  "Returns a map from distinct items in coll to the number of times
  they appear."
  [coll]
  ;
  (reduce (fn [counts x]
  (assoc counts x (inc (get counts x 0
  {} coll))

  (dotimes [x 4]
  (println "i: " (int (Math/pow 10.0 x)))
(time
 (dotimes [_ (int (Math/pow 10.0 x))]
 (let [a (for [_ (range 1000)] (random-string 3))]
   (frequencies a)

--

public static Map frequencies(final List list) {
final Map map = new HashMap();
// Simple Box and then unbox the count as the value for this
map //
for (Iterator it = list.iterator(); it.hasNext(); ) {
final Object o = it.next();
final String s = o.toString();
Integer prev = (Integer) map.get(s);
if (prev == null) {
// Put a new value on th map
final Integer count = ONE;
map.put(s, count);
} else {
final Integer inc = new Integer(prev.intValue() + 1);
map.put(s, inc);
} // End of the if - else //
}
return map;
}
--

Clojure Results (same machine 1.5 JDK)

i:  1
"Elapsed time: 51.657859 msecs"
i:  10
"Elapsed time: 212.568221 msecs"
i:  100
"Elapsed time: 1623.107702 msecs"
i:  1000
"Elapsed time: 16356.185166 msecs"
(used:2M/0M [2M,63M ])
Done
Performing simple garbage collection cooldown
(used:2M/0M [2M,63M ])
(used:2M/0M [2M,63M ])

-

Here are the Java results.

14.6316069 ms
4.8283429 ms
i: 10
Elapsed time: 9.803628 msecs
i: 100
Elapsed time: 97.562451 msecs
i: 1000
Elapsed time: 972.775771 msecs
(used:1M/0M [1M,63M ])
(used:1M/0M [1M,63M ])
(used:1M/0M [1M,63M ])

NOTE:!!! This is just one example.  All my other examples, ended up
the same way.  I hope you don't nitpick this one.

I know we should take performance tests with a grain a salt.  But at
the same time, I feel we should at least try to measure the speed of
some of our code.  I haven't found many speed tests out there on
clojure.


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



Clojure to PDF gui application, alpha

2010-05-27 Thread BerlinBrown
I created/updated a small GUI based on clojure that I am using to
create PDF reports.  It is still alpha state but I think you can click
on and generate PDF documents with it

http://code.google.com/p/lighttexteditor/wiki/LightReportsEditor

In the future, I will be adding a batch/templating mode so you can
batch generate reports and may add database connectivity.

I went through many versions of this tool so there is a lot of junk
that is not necessarily related to the pdf conversion.

If you are interested in the clojure code, you might do a find and
just browse around.  I come from a Java background, so I still use
imperative programming idioms.

find . -name '*.clj'

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-27 Thread BerlinBrown
There are really only two mainstream options SWT and Swing.  Both will
suffice.

I preferred SWT just because I like the Eclipse project. As you know
SWT is the core GUI library behind SWT.  I just feel that SWT has more
large applications developed, Eclipse, azureus

Swing can be frustrating for the most basic things like working with
the layout manager and non-blocking calls.

SWT provides mature widgets like the Web Browser widget, the text
editor (JFaces), the calendar widget.

But yea, Swing does work out of the box, cross platform.

I am not really a GUI desktop developer, I like SWT slightly more but
I do some quick apps with Swing.

On May 27, 11:42 am, Stuart Halloway 
wrote:
> +1 Swing.
>
> > +1 Swing.  There's a ton of documentation out there, and it got some
> > serious love from Sun between java 5 and 6.
>
> > On May 27, 11:27 am, Laurent PETIT  wrote:
> >> Although I work with SWT at work, I would say Swing for 2 reasons :
>
> >>   * no additional dependency for users of your lib, and *no need* for users
> >> of your lib to deliver different final apps binaries for different 
> >> platforms
> >>   * may be easier to work with in your implementation (?)
>
> >> 2010/5/27 Luke VanderHart 
>
> >>> 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
> >>> Programming wherever it's convenient to do so.
>
> >>> What you all must help me decide is what GUI framework to use as the
> >>> underpinnings of it. It's genuinely hard to decide. I have at least
> >>> some experience with all of them, so I have no strong preference, but
> >>> I'd like to get your input. I did consider trying to make it abstract
> >>> enough that you could plug in *any* of them under the hood, but
> >>> there's enough differences between the frameworks that that would get
> >>> very ugly very fast.
>
> >>> Possibilities are:
>
> >>> AWT
> >>> Pros: native widgets, bundled with Java, low-level
> >>> Cons: few widgets, considered somewhat obselete
>
> >>> Swing
> >>> Pros: bundled with Java, good widget selection
> >>> Cons: non-native widgets
>
> >>> SWT
> >>> Pros: native widgets, widely used
> >>> Cons: requires platform-specific libs
>
> >>> QT Jambi
> >>> Pros: native widgets, huge widget selection, highly-regarded framework
> >>> Cons: requires platform-specific libs, writing custom widgets is
> >>> hairy, momentum and support seem to be lagging since Nokia dropped
> >>> official support.
>
> >>> Remember, the actual API won't matter - that will be completely
> >>> abstracted away. So try to focus on the framework's look and feel.
> >>> Also let me know if I've missed any of the framework's key
> >>> characteristics.
>
> >>> Thanks!
>
> >>> -Luke
>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Clojure" group.
> >>> To post to this group, send email to clojure@googlegroups.com
> >>> Note that posts from new members are moderated - please be patient with
> >>> your first post.
> >>> To unsubscribe from 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


Any issues with launching in clojure, calling Java code, Java code calling clojure

2010-05-27 Thread BerlinBrown
I enjoy clojure and I think I am breaking all the rules.  I have an
app that I originally created in clojure.  It has been a year off and
on.  And I merged that code with some existing java database code.

The clojure code invokes the java code.  Now, I want to have a script
environment where users can invoke their own clojure code.  But I was
think the clojure code should run in a completely new, separate
environment, via a thread.

Basically.

1. Clojure is invokved (clojure.main)
2. I have clojure code that invokes code originally written in Java
3. That java code creates another separate clojure instance, parsing a
clojure script. (an embedded dsl)

It isn't that confusing.  It is almost akin to invoking a JSP page
from a running web server.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-27 Thread BerlinBrown
Swing seems like a proof of concept UI toolkit.

SWT just seems a bit more polished and easier to develop, working
apps.

That is just an opinion and I like that Swing is built-in.

On May 27, 8:13 pm, Antony Blakey  wrote:
> On 28/05/2010, at 9:21 AM, Armando Blancas wrote:
>
> >> Remember, the actual API won't matter - that will be completely
> >> abstracted away. So try to focus on the framework's look and feel.
> >> Thanks!
> >> -Luke
>
> > SWT, because of the native look and feel. I really don't like the
> > looks of Swing. As a user of some Swing app, I don't find solace from
> > thinking how convenient it was for the programmers to deliver that
> > thing to me. As a developer, dealing with the packaging/deployment
> > just comes with the job and the results, I think, are well worth the
> > effort.
>
> +1 SWT. I think arguments that focus on the ease of deployment are misguided 
> because an app is *used* far more times than it is deployed, so one really 
> should focus on the quality of the end application. In any case, deployment 
> and packaging for different platforms is easy to automate.
>
> Antony Blakey
> --
> CTO, Linkuistics Pty Ltd
> Ph: 0438 840 787
>
> The trouble with the world is that the stupid are cocksure and the 
> intelligent are full of doubt.
>   -- Bertrand Russell

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

2010-05-28 Thread BerlinBrown
So a lot of Clojure variables are set at the JVM/Class level

Hmm...

On May 27, 10:29 pm, Jason Smith  wrote:
> The issue that you'll run into is that there is one lexical scope that
> is shared by all calls toClojure.  The only ways around this are (1)
> run it in another process, and (2) load theClojureJARs into a
> ClassLoader at runtime, and throw the ClassLoader away after every
> call.
>
> The overhead for option 2 is between 0.5 and 1 second per call,
> becauseClojurehas to be re-inited.  For option 1, it's even more
> because you are starting Java, then initing Java.
>
> Threads have nothing to do with theClojurelexical scoping.  If you
> run 100 threads, they normally all share the same variables,
> namespaces, and functions.
>
> For more info, you can check 
> outhttp://sandflea.googlecode.com/svn/site/maven-clojure-plugin/1.1.0/cl...
> (http://code.google.com/p/sandflea/source/browse/maven-clojure-plugin/
> trunk/clojure-commons/src/main/java/sandflea/clojure/scripting/
> ClojureScripting.java).
>
> On May 27, 3:46 pm, BerlinBrown  wrote:
>
> > I enjoyclojureand I think I am breaking all the rules.  I have an
> > app that I originally created inclojure.  It has been a year off and
> > on.  And I merged that code with some existing java database code.
>
> > Theclojurecode invokes the java code.  Now, I want to have a script
> > environment where users can invoke their ownclojurecode.  But I was
> > think theclojurecode should run in a completely new, separate
> > environment, via a thread.
>
> > Basically.
>
> > 1.Clojureis invokved (clojure.main)
> > 2. I haveclojurecode that invokes code originally written in Java
> > 3. That java code creates another separateclojureinstance, parsing a
> >clojurescript. (an embedded dsl)
>
> > It isn't that confusing.  It is almost akin to invoking a JSP page
> > from a running web server.

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

2010-05-28 Thread BerlinBrown
I don't think option 2 would take that long.  Even my clojure startup
is not half a second on a modern machine.

On May 27, 10:29 pm, Jason Smith  wrote:
> The issue that you'll run into is that there is one lexical scope that
> is shared by all calls toClojure.  The only ways around this are (1)
> run it in another process, and (2) load theClojureJARs into a
> ClassLoader at runtime, and throw the ClassLoader away after every
> call.
>
> The overhead for option 2 is between 0.5 and 1 second per call,
> becauseClojurehas to be re-inited.  For option 1, it's even more
> because you are starting Java, then initing Java.
>
> Threads have nothing to do with theClojurelexical scoping.  If you
> run 100 threads, they normally all share the same variables,
> namespaces, and functions.
>
> For more info, you can check 
> outhttp://sandflea.googlecode.com/svn/site/maven-clojure-plugin/1.1.0/cl...
> (http://code.google.com/p/sandflea/source/browse/maven-clojure-plugin/
> trunk/clojure-commons/src/main/java/sandflea/clojure/scripting/
> ClojureScripting.java).
>
> On May 27, 3:46 pm, BerlinBrown  wrote:
>
> > I enjoyclojureand I think I am breaking all the rules.  I have an
> > app that I originally created inclojure.  It has been a year off and
> > on.  And I merged that code with some existing java database code.
>
> > Theclojurecode invokes the java code.  Now, I want to have a script
> > environment where users can invoke their ownclojurecode.  But I was
> > think theclojurecode should run in a completely new, separate
> > environment, via a thread.
>
> > Basically.
>
> > 1.Clojureis invokved (clojure.main)
> > 2. I haveclojurecode that invokes code originally written in Java
> > 3. That java code creates another separateclojureinstance, parsing a
> >clojurescript. (an embedded dsl)
>
> > It isn't that confusing.  It is almost akin to invoking a JSP page
> > from a running web server.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-30 Thread BerlinBrown
I am not knocking all of these +1 Swing posts.  But I would love to
see one good public application built in Swing (besides Netbeans)

On May 28, 9:10 am, laseray  wrote:
> +1 Swing
>
> If I had my druthers I would go with QtJambi, but since Nokia dropped
> development for that it has not been able to keep pace with Qt. So
> that would be immediately out of sync. Plus the need for platform
> native compiled code is a minus. Fine for the main three (Linux, Mac,
> Windows) with precompiled libs, but separate compile for anything else
> equals ongoing maintenance effort. This defeats the point of having a
> cross-platform language. Java and Clojure will work (.e.g, on FreeBSD,
> OpenSolaris, AIX), but the GUI won't unless you make extra C/C++
> coding effort?
>
> SWT is a minus due to native code needs, too much XML configuration,
> and the fact that it does not look nearly as good as some people think
> when used cross-platform. Looks fine on Windows, the Mac side is
> getting better now that they are starting to use Cocoa underneath,
> Linux side is questionable with varying appearance across different
> window managers. Other OS? This is the same as for QtJambi, extra C/C+
> + coding effort needed to be really cross-platform.
>
> No reason to go with AWT exclusively. A lot of Swing wraps parts of or
> needs AWT anyway. You can't really get away from it and will be
> cutting off a limb, so to speak, if you go with it rather than Swing
> first.
>
> A lot of the misgivings about Swing look and feel across platform
> boils down to bad GUI development efforts. I have seen this many
> times. Many developers just do not understand the specific interface
> needs across different platforms and just leave parameters at the
> default settings, which only by luck will be near optimal. I have
> developed a number of Swing applications that look pretty close to
> native (at least on Linux, Mac, Windows, Solaris) so I can say that it
> takes some attention to platform specific details to make this happen
> (and access to multiple OS).  That is what it takes to develop a
> serious professional cross-platform desktop application, no way around
> it (you would even have to do this if going with QtJambi or SWT).
>
> Overall, I would go with Swing. The main reason is that it will
> already be cross-platform on any Java compliant OS that can run
> Clojure. I think that is the most important thing if you want a GUI to
> go along with the language. Nothing additional is needed to complicate
> matters, besides the GUI layer/framework on top of Clojure.
>
> Nonetheless, the best idea would be to ensure you have enough
> abstraction in your implementation so that other GUI toolkits could be
> "almost" dropped in place later on. That is, it should not close out
> other toolkits, but going with what will work now or sooner than later
> is better. Going with Swing is a way to get something out soon without
> having to spend additional effort worrying about C/C++ libraries,
> packaging and so on. Get something to work, then the additional
> toolkits can come.

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


Clojure on the tiobe index

2010-06-04 Thread BerlinBrown
Nice.

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

It is number 16.

...combined with Lisp and Scheme.

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

2010-06-04 Thread BerlinBrown
I don't think tiobe is all accurate index of anything.  But when you
look at the actual rankings, they seem to line up, especially for the
mainstream languages.

I could see where Delphi ranks high on the list.  "Go" is a little
odd.

But I was glad to see Clojure get a little recognition.

And I am still one of those guys that still considers Clojure as a JVM
language.

On Jun 4, 1:51 pm, lprefonta...@softaddicts.ca wrote:
> I read the explanation on how they compute their charts.
>
> I do not see why a Cobol or Fortran programmer would query the Web for
> references on a regular basis.
> What can be the significance of computing references on the Web about older
> languages that do not evolve too much but that have a large application base ?
>
> There's still a few hundred millions of Cobol lines out there in all these
> bank processing centers and surely they are maintained somehow by human 
> brains.
> Seeing Cobol at the 24th rank does not make sense to me.
>
> The popularity they say they measure here must be taken in the same way
> as gossip tabloids... ephemeral and by no way reflecting real life :)))
>
> It's not because the sales of cokes, chips and alike are blooming that it 
> makes
> them the best choice health wise. Beurk...
>
> Luc P.
>
> Luke VanderHart  wrote ..
>
> > Tiobes rankings always seems a little dubious to me.
>
> > Delphi more popular than Javascript? Really? Google Go more popular
> > than Lisp/Scheme/Clojure?
>
> > Ranking those three together is an atrocity, by the way. Just because
> > they all have paren's doesn't make them the same.
>
> > Anyway, I'm sure Tiobe measures something. But I'm not sure it's
> > anything useful.
>
> > On Jun 4, 10:11 am, BerlinBrown  wrote:
> > > Nice.
>
> > >http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
>
> > > It is number 16.
>
> > > ...combined with Lisp and Scheme.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first
> > post.
> > To unsubscribe from 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


Embedded Clojure

2010-06-04 Thread BerlinBrown
I am working on a simple DSL and wanted to some form of embedded
Clojure to where I can invoke Clojure scripts and have those scripts
not effect the bootloader/my main application code.

It seems there are two approaches that sound doable.

(A) - With the dynamically loaded clojure scripts, the DSL code, I
could load these in its own specific clojure namespace and then clean-
up the namespace once it is done.

This is discussed in this thread:

http://groups.google.com/group/clojure/browse_thread/thread/d98cedb860f16a34/21704fda80aaf067?q=embedded+clojure#21704fda80aaf067

Here is my question, how would I delete the namespace.  I may use Java
code to run the embedded DSL clojure scripts.

(B) - Run new instances of clojure in a completely separate
classloader.  Option B is OK except writing custom classloaders and
dynamically load the clojure jar instance may be too much work for
what I am trying to do.


What do you think about option A or B, do you have any code that does
this?

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


Re: Game development in Clojure

2010-08-13 Thread BerlinBrown
I played it, it was pretty fun.

I have UI recommendations. I couldn't tell the difference between the
enemy and my units.

I wish maybe you had some quick tips and recommended next actions so I
could get used to how the game works.

On Aug 13, 9:51 am, Mike Anderson 
wrote:
> Hello all,
>
> I've recently been working on a game development project in Clojure
> which is now starting to bear fruit. I thought people here might be
> interested, and that it would be worthwhile to share some experiences
> and perspectives.
>
> The project is a steampunk-themed strategy game, and a playable in-
> development version is available here:
>
>    http://mikera.net/ironclad/
>
> Overall, I think Clojure is a fantastic language for game development.
> Some thought on what makes it really compelling:
>
> 1. Immutable data structures work surprisingly well for games. I
> represent the entire game state with a big defrecord, and the main
> engine loop is basically:
>   a) Get commands from player / AI (e.g. "Move unit from A to B")
>   b) Convert each command into set of atomic updates ("Remove unit
> from A", "Add unit to B")
>   c) Apply updates sequentially to the game state
>   d) Trigger any feedback to player e.g. animations, sounds
>
> 2. Concurrency support has been very helpful. With immutable game
> state, it has been trivial to separate the game engine from the
> renderer from the AI calculations - each effectively gets to operate
> on its own "snapshot" of the entire game state. This can be a big
> headache in many game engines that have to mediate access to a single,
> mutable game state. I can also see even greater benefits when I
> finally start adding some multi-player features.
>
> 3. High level, functional programming works great for rapid, iterative
> and dynamic development. Of all the languages I've used, Clojure has
> probably been quickest in terms of time required to add a given new
> piece of functionality. For example, the map generator code probably
> only took about 30 minutes to write, pretty good for a fractal
> landscape generation system!
>
> 4. The Java interoperability support is fantastic - definitely counts
> as one of the "killer features" of Clojure. I've been able to reuse a
> lot of Java code libraries, both my own and standard libraries such as
> Swing. As an example, I have a well optimised immutable persistent 2D
> grid data structure in Java (basically a very efficient, spatially
> partitioned map from (int,int) to Object) that I have been able to use
> pretty much seamlessly in Clojure thanks to extend-protocol and
> similar.
>
> Some interesting observations / discoveries / surprises in the
> process:
>
> 1. The game worked first time on Mac and Linux, despite having been
> tested exclusively on Windows. Great kudos to to both the Java
> platform and the Clojure libraries!
>
> 2. Reflection is *really slow*. After getting 20-100x speedups from
> eliminating reflection warnings in the AI code, I now treat any
> reflection warning in code other than one-time setup code as a bug to
> be fixed immediately.
>
> Finally, here are some things I think could be great improvements to
> Clojure in the future from a game developer's perspective:
>
> 1. Better support for primitive parameters / return values / unchecked
> arithmetic - in performance sensitive code, these are pretty much
> essential. In a few cases in the graphics and AI code, I've had to
> drop back to Java to get the performance I need.
>
> 2. It would be great to reduce the amount of memory allocations. Yes,
> I know memory is plentiful and GC is very cheap, but it's still not as
> cheap as stack allocation and any noticeable GC pauses are not good
> for the player experience in interactive games. For this reason, I
> find myself using reduce and indexed loops a lot more than I guess
> would normally be idiomatic, and conversely tend to avoid some of the
> lazy constructs and functions that generate sequences. While Clojure
> is great for a strategy game, I'd probably hesitate to use it for a
> real-time 3D game.
>
> 3. I think it would be great to have better support for circular
> references - perhaps a two-pass compile? The reason this is
> particularly acute in game development is that different subsystems
> have quite a lot of inter-dependencies. AI evaluation system needs to
> understand game state/engine so it can evaluate a position. Game state/
> engine needs to understand units so it can manipulate them. Units need
> to understand AI evaluation system so they can decide which actions to
> take.. obviously it's possible to work around all this, but it's a
> major pain, adds complexity and means that you need to structure code
> to manage dependencies rather than in logical modules (which would be
> easier to manage and maintain!)
>
> Would love to hear thoughts, and particularly any other experiences
> people have had in using Clojure for game development!
>
>   Mike.

-- 
You received this message because yo

Re: Funding Clojure 2010

2009-12-14 Thread BerlinBrown


On Dec 14, 9:33 am, Rich Hickey  wrote:
> Funding Clojure 2010
>
> Background
> --
>
> It is important when using open source software that you consider who
> is paying for it, because someone is. There is no such thing as free
> software.
>
> Sometimes open source software is developed under a license with
> undesirable properties (e.g. the GPL), such that people are willing to
> pay for a (proprietary) version of it that is not subject to that
> license. Both Monty Widenius [1] and Richard Stallman [2] have argued
> for the necessity of such a mechanism to fund open source software,
> lest there be insufficient resources for its development. Clojure
> doesn't use the GPL, thus conveying more freedom to its users, but
> precluding me from funding it via dual licensing.
>
> Some companies develop technology as a component of a proprietary
> product or service, absorbing it as a necessary expense, only to
> decide that it is not a core, unique, or advantage-bearing business
> function. They can reduce their costs in ongoing development by open
> sourcing it, deriving benefit from community contributions and letting
> them focus on their core business [3]. It is important to note that
> the bulk of the costs are often in the original development, and are
> paid for by the proprietary product or service. That is not the case
> for Clojure.
>
> Some open source is the product of academic research, and is funded by
> the academic institution and/or research grants [4]. That is not the
> case for Clojure.
>
> Some open source software is (partially) funded by proprietary
> support. It is important to note that often the support income does
> not in fact make it to the people who create the software. Such income
> models work best for support sold to conservative enterprises [5].
> That is not the case for Clojure.
>
> Some companies 'fund' open source software by dedicating some of their
> employees' time, or making investments, in its development. There must
> be some business value to the company for doing so (e.g. it helps them
> sell hardware [6]), and thus is ultimately paid for by their
> proprietary products/services. That is not the case for Clojure.
>
> There *are* companies that make software themselves, whose consumers
> see a value in it and willingly pay to obtain that value. The money
> produced by this process pays the salaries of the people who are
> dedicated to making it, and some profit besides. It's called
> "proprietary software". People pay for proprietary software because
> they have to, but otherwise the scenario is very similar to open
> source - people make software, consumers get value from it. In fact,
> we often get a lot less with proprietary software - vendor lock-in, no
> source etc. Most alarmingly, this is the only model that associates
> value with software itself, and therefore with the people who make it.
>
> Why don't people pay for open source software? Primarily, because they
> don't *have to*. I think also, partially, it is because open source
> software often doesn't have a price tag. I think it should. I'd like
> to pay for open source, and know the money is going to those who
> create it. I'd like companies to *expect* to pay for it. I'd like to
> see people make a living (and even profit!) directly making open
> source, not as a side effect of some other proprietary process, to
> dedicate themselves to it, and not have it be hobby/side work.
>
> Unfortunately, there seems to be no way to convey the full benefits of
> open source software while *forcing* people to pay for it. Only in the
> proprietary (including dual-license) model is there a direct
> connection between the consumers of software and the funding of those
> that produce it. This is having the effect of driving open source
> software towards having zero apparent cost, becoming a free bounty of
> someone else's other profitable endeavors, and is severely
> compromising our profession.
>
> Foreground
> --
>
> As should be obvious, Clojure is a labor of love on my part. Started
> as a self-funded sabbatical project, Clojure has come to occupy me far
> more than full-time. However, Clojure does not have institutional or
> corporate sponsorship, and was not, and is not, the by-product of
> another profitable endeavor. I have borne the costs of developing
> Clojure myself, but 2009 is the last year I, or my family, can bear
> that.
>
> Many generous people have made donations (thanks all!), but many more
> have not, and, unfortunately, donations are not adding up to enough
> money to pay the bills. So far, less than 1% of the time I've spent on
> Clojure has been compensated.
>
> Right now, it is economically irrational for me to work on Clojure,
> yet, I want to continue working on Clojure, and people are clearly
> deriving benefit from my work. How can we rectify this? Barring the
> arrival of some white knight, I'm asking the users of Clojure to fund
> its core development (i.e. my effort) 

Clojure and introspection/reflection analysis?

2008-10-23 Thread BerlinBrown

I asked this on common lisp thread but I want to work with clojure as
well:

With clojure and I am assuming the introspection properties.  How
can I add code to clojure code that will tell me when a function
is called and when has finished executing.  I want to take any lisp
code and this particular modification to the code.  I figure with
lisp's AST analysis, this should be possible.

For example, pseudo code in common lisp, hello_world.lisp:

(defun hello-world ()
  (format t "Hello World"))

(hello-world)

 And then I have a utility to load hello_world.lisp and execute
the hello-world call.

At the command line:
#Inspect: hello-world function was called
#Hello World
#Inspect: hello-world has finished executing.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure and introspection/reflection analysis?

2008-10-23 Thread BerlinBrown



On Oct 23, 6:42 pm, BerlinBrown <[EMAIL PROTECTED]> wrote:
> I asked this on common lisp thread but I want to work with clojure as
> well:
>
> With clojure and I am assuming the introspection properties.  How
> can I add code to clojure code that will tell me when a function
> is called and when has finished executing.  I want to take any lisp
> code and this particular modification to the code.  I figure with
> lisp's AST analysis, this should be possible.
>
> For example, pseudo code in common lisp, hello_world.lisp:
>
> (defun hello-world ()
>   (format t "Hello World"))
>
> (hello-world)
>
>  And then I have a utility to load hello_world.lisp and execute
> the hello-world call.
>
> At the command line:
> #Inspect: hello-world function was called
> #Hello World
> #Inspect: hello-world has finished executing.


Another similar question (second question):

If you have used ASM, I can do a lot of this "trace" type
functionality with the bytecode manipulator ASM (and obviously
reflection) but I was also looking for the clojure way.  
http://asm.objectweb.org/).
Or maybe even reflection.  Is there something in clojure that might
allow me to see when a function is called.

For example, with ASM, I can get the following information of a
method:

  protected (Ljava/lang/String;)V
ALOAD 0
INVOKESPECIAL java/lang/Object.()V
ALOAD 0
ALOAD 1
PUTFIELD org/objectweb/asm/Attribute.type : Ljava/lang/String;
RETURN
MAXSTACK = 2
MAXLOCALS = 2


What is put on the stack and when methods are invoked.

Does something similar exist for ASM?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure and introspection/reflection analysis?

2008-10-24 Thread BerlinBrown



On Oct 24, 2:34 am, mritun <[EMAIL PROTECTED]> wrote:
> Hi
>
> Take a look at btrace. It is DTrace like dynamic instrumentation tool
> for JVM (DTrace : System :: btrace : JVM, though DTrace is superset of
> btrace).
>
> It allows you to instrument JVM at bytecode level with no changes in
> code.
>
> It might also help going forward to enhance clojure to insert btrace
> probes. These probes can help expose higher level details to
> instrumentation tools like btrace and would help professional
> developers immensely.
>
> - Akhilesh
>
> On Oct 24, 5:03 am, BerlinBrown <[EMAIL PROTECTED]> wrote:
>
> > On Oct 23, 6:42 pm, BerlinBrown <[EMAIL PROTECTED]> wrote:
>
> > > I asked this on common lisp thread but I want to work with clojure as
> > > well:
>
> > > With clojure and I am assuming the introspection properties.  How
> > > can I add code to clojure code that will tell me when a function
> > > is called and when has finished executing.  I want to take any lisp
> > > code and this particular modification to the code.  I figure with
> > > lisp's AST analysis, this should be possible.
>
> > > For example, pseudo code in common lisp, hello_world.lisp:
>
> > > (defun hello-world ()
> > >   (format t "Hello World"))
>
> > > (hello-world)
>
> > >  And then I have a utility to load hello_world.lisp and execute
> > > the hello-world call.
>
> > > At the command line:
> > > #Inspect: hello-world function was called
> > > #Hello World
> > > #Inspect: hello-world has finished executing.
>
> > Another similar question (second question):
>
> > If you have used ASM, I can do a lot of this "trace" type
> > functionality with the bytecode manipulator ASM (and obviously
> > reflection) but I was also looking for the clojure way.  
> > http://asm.objectweb.org/).
> > Or maybe even reflection.  Is there something in clojure that might
> > allow me to see when a function is called.
>
> > For example, with ASM, I can get the following information of a
> > method:
>
> >   protected (Ljava/lang/String;)V
> > ALOAD 0
> > INVOKESPECIAL java/lang/Object.()V
> > ALOAD 0
> > ALOAD 1
> > PUTFIELD org/objectweb/asm/Attribute.type : Ljava/lang/String;
> > RETURN
> > MAXSTACK = 2
> > MAXLOCALS = 2
>
> > 
> > What is put on the stack and when methods are invoked.
>
> > Does something similar exist for ASM?

http://clojure.org/other_libraries

Zipper may also be something that I could use.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure and introspection/reflection analysis?

2008-10-24 Thread BerlinBrown



On Oct 24, 5:36 pm, BerlinBrown <[EMAIL PROTECTED]> wrote:
> On Oct 24, 2:34 am, mritun <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi
>
> > Take a look at btrace. It is DTrace like dynamic instrumentation tool
> > for JVM (DTrace : System :: btrace : JVM, though DTrace is superset of
> > btrace).
>
> > It allows you to instrument JVM at bytecode level with no changes in
> > code.
>
> > It might also help going forward to enhance clojure to insert btrace
> > probes. These probes can help expose higher level details to
> > instrumentation tools like btrace and would help professional
> > developers immensely.
>
> > - Akhilesh
>
> > On Oct 24, 5:03 am, BerlinBrown <[EMAIL PROTECTED]> wrote:
>
> > > On Oct 23, 6:42 pm, BerlinBrown <[EMAIL PROTECTED]> wrote:
>
> > > > I asked this on common lisp thread but I want to work with clojure as
> > > > well:
>
> > > > With clojure and I am assuming the introspection properties.  How
> > > > can I add code to clojure code that will tell me when a function
> > > > is called and when has finished executing.  I want to take any lisp
> > > > code and this particular modification to the code.  I figure with
> > > > lisp's AST analysis, this should be possible.
>
> > > > For example, pseudo code in common lisp, hello_world.lisp:
>
> > > > (defun hello-world ()
> > > >   (format t "Hello World"))
>
> > > > (hello-world)
>
> > > >  And then I have a utility to load hello_world.lisp and execute
> > > > the hello-world call.
>
> > > > At the command line:
> > > > #Inspect: hello-world function was called
> > > > #Hello World
> > > > #Inspect: hello-world has finished executing.
>
> > > Another similar question (second question):
>
> > > If you have used ASM, I can do a lot of this "trace" type
> > > functionality with the bytecode manipulator ASM (and obviously
> > > reflection) but I was also looking for the clojure way.  
> > > http://asm.objectweb.org/).
> > > Or maybe even reflection.  Is there something in clojure that might
> > > allow me to see when a function is called.
>
> > > For example, with ASM, I can get the following information of a
> > > method:
>
> > >   protected (Ljava/lang/String;)V
> > > ALOAD 0
> > > INVOKESPECIAL java/lang/Object.()V
> > > ALOAD 0
> > > ALOAD 1
> > > PUTFIELD org/objectweb/asm/Attribute.type : Ljava/lang/String;
> > > RETURN
> > > MAXSTACK = 2
> > > MAXLOCALS = 2
>
> > > 
> > > What is put on the stack and when methods are invoked.
>
> > > Does something similar exist for ASM?
>
> http://clojure.org/other_libraries
>
> Zipper may also be something that I could use.

Is the zipper library still available?

http://groups.google.com/group/clojure/browse_thread/thread/a0c84046d3f31c88/f612a67cd0c4af15?lnk=gst&q=zipper#f612a67cd0c4af15

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



General question, what are using for clojure?

2008-11-18 Thread BerlinBrown

What projects have you used clojure for?  Have you completed them? Are
they one-off projects.  Small big?  Is it web based, a GUI?

I am working on this, haven't made much progress but at least I
started.

http://code.google.com/p/botnodetoolkit/

And if you are interested, post your project here.  I am the
maintainer.

http://www.reddit.com/r/codeprojects/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---