Re: [ANN] analyze 0.1

2012-01-03 Thread Ambrose Bonnaire-Sergeant
Yes, that will fix it, but I'm not sure of the implications or why exactly
it's necessary.

I'll push it to master.

Thanks,
Ambrose

On Tue, Jan 3, 2012 at 3:55 PM, Jonas jonas.enl...@gmail.com wrote:



 On Tuesday, January 3, 2012 9:45:04 AM UTC+2, Ambrose Bonnaire-Sergeant
 wrote:

 It seems if the namespace is not already loaded, then there are issues.


 That's it! It's simple to fix. Just require the namespaces in the ns form.
 I can send you a pull request if you want to?

 /Jonas

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


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

[ANN] analyze 0.1

2012-01-02 Thread Ambrose Bonnaire-Sergeant
Inspired by the ClojureScript compiler, analyze is an interface to the
Clojure analysis phase.

Check the README for some cool things you can do.

https://clojars.org/analyze
https://github.com/frenchy64/analyze

I've barely tested the library but it manages to analyze a good part of the
core Clojure library.
This is work in progress.

If you heard Rich Hickey talking about leveraging the analysis phase at
the Conj, this is a step in that direction.

Have fun :)
Ambrose

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

Re: [ANN] analyze 0.1

2012-01-02 Thread Scott Jaderholm
Very cool. If you think of other potential example errors this would be
capable of detecting it might be nice to include them in a TODO list in the
README. This might motivate someone to implement them or develop a nice
emacs UI for displaying these errors.

Scott


On Mon, Jan 2, 2012 at 4:14 AM, Ambrose Bonnaire-Sergeant 
abonnaireserge...@gmail.com wrote:

 Inspired by the ClojureScript compiler, analyze is an interface to the
 Clojure analysis phase.

 Check the README for some cool things you can do.

 https://clojars.org/analyze
 https://github.com/frenchy64/analyze

 I've barely tested the library but it manages to analyze a good part of
 the core Clojure library.
 This is work in progress.

 If you heard Rich Hickey talking about leveraging the analysis phase at
 the Conj, this is a step in that direction.

 Have fun :)
 Ambrose

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

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

Re: [ANN] analyze 0.1

2012-01-02 Thread Alex Baranosky
Very cool stuff Ambrose!

On Mon, Jan 2, 2012 at 1:11 PM, Scott Jaderholm jaderh...@gmail.com wrote:

 Very cool. If you think of other potential example errors this would be
 capable of detecting it might be nice to include them in a TODO list in the
 README. This might motivate someone to implement them or develop a nice
 emacs UI for displaying these errors.

 Scott


 On Mon, Jan 2, 2012 at 4:14 AM, Ambrose Bonnaire-Sergeant 
 abonnaireserge...@gmail.com wrote:

 Inspired by the ClojureScript compiler, analyze is an interface to the
 Clojure analysis phase.

 Check the README for some cool things you can do.

 https://clojars.org/analyze
 https://github.com/frenchy64/analyze

 I've barely tested the library but it manages to analyze a good part of
 the core Clojure library.
 This is work in progress.

 If you heard Rich Hickey talking about leveraging the analysis phase at
 the Conj, this is a step in that direction.

 Have fun :)
 Ambrose

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

 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com

 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


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

 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com

 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

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

Re: [ANN] analyze 0.1

2012-01-02 Thread Jonas
Hi Ambrose

I’ve been playing around with your library and find it very intresting. A 
couple of questions:

1. In order to be able to run your examples I have to comment out the 
clojure.test, clojure.stacktrace and clojure.template namespaces. Otherwise 
I get a NullPointerException[1] which I’m unable to track down. It seems to 
originate from the wall-hack function. What does this function do?

2. Is it possible to do some analysis before macroexpansion? For example, 
If I want to look for the pattern

(if (some-test? …)
(some-expr …)
nil)

and print the following: “WARNING: consider using (when …) instead of (if 
test then nil)”. Is this possible since (when test expr) expands to (if 
test (do expr)). Maybe this kind of code analysis is outside the scope of 
your library?

[1]: https://gist.github.com/1553808

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

Re: [ANN] analyze 0.1

2012-01-02 Thread Ambrose Bonnaire-Sergeant
Hi Jonas

On Tue, Jan 3, 2012 at 2:43 PM, Jonas jonas.enl...@gmail.com wrote:

 1. In order to be able to run your examples I have to comment out the
 clojure.test, clojure.stacktrace and clojure.template namespaces. Otherwise
 I get a NullPointerException[1] which I’m unable to track down. It seems to
 originate from the wall-hack function. What does this function do?


wall-hack allows me to access method/fields of private classes via
reflection. If there's a better way I'm all ears, but if I'm using
wall-hack it usually means the Class is private.

That being said, the stacktrace you're getting originates in the Compiler's
analysis phase. The call to wall-hack is a call to
clojure.lang.Compiler/analyze.

Be ready for some very cryptic errors :) It also helps to have a clone of
the clojure source to follow the stacktrace.

How are you running the code? Could you pull the latest master and try
again? Possibly track down exactly which namespace is causing the Exception.

(I just realized there's a public method of clojure.lang.Compiler/analyze,
so wall-hack is not necessary for calling clojure.lang.Compiler/analyze.
Just pushed the change.)


 2. Is it possible to do some analysis before macroexpansion? For example,
 If I want to look for the pattern

 (if (some-test? …)
 (some-expr …)
 nil)

 and print the following: “WARNING: consider using (when …) instead of (if
 test then nil)”. Is this possible since (when test expr) expands to (if
 test (do expr)). Maybe this kind of code analysis is outside the scope of
 your library?


This would be easy if the analyzer was more like ClojureScript's analyzer.
ie. written in Clojure with multimethods.

But I'm not sure how to do this otherwise. You'd basically want to add a
new special form that tells the analyzer to stop macroexpanding.

Basically, yes, this is outside the scope of what I hope to achieve right
now.

Thanks,
Ambrose

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

Re: [ANN] analyze 0.1

2012-01-02 Thread Ambrose Bonnaire-Sergeant
Actually, it's my environment which is the issue. Vimclojure seems to load
lots of extra libs.

It seems to be barfing at the `ns` forms.

Ambrose

On Tue, Jan 3, 2012 at 3:13 PM, Ambrose Bonnaire-Sergeant 
abonnaireserge...@gmail.com wrote:

 Hi Jonas

 On Tue, Jan 3, 2012 at 2:43 PM, Jonas jonas.enl...@gmail.com wrote:

 1. In order to be able to run your examples I have to comment out the
 clojure.test, clojure.stacktrace and clojure.template namespaces. Otherwise
 I get a NullPointerException[1] which I’m unable to track down. It seems to
 originate from the wall-hack function. What does this function do?


 wall-hack allows me to access method/fields of private classes via
 reflection. If there's a better way I'm all ears, but if I'm using
 wall-hack it usually means the Class is private.

 That being said, the stacktrace you're getting originates in the
 Compiler's analysis phase. The call to wall-hack is a call to
 clojure.lang.Compiler/analyze.

 Be ready for some very cryptic errors :) It also helps to have a clone of
 the clojure source to follow the stacktrace.

 How are you running the code? Could you pull the latest master and try
 again? Possibly track down exactly which namespace is causing the Exception.

 (I just realized there's a public method of clojure.lang.Compiler/analyze,
 so wall-hack is not necessary for calling clojure.lang.Compiler/analyze.
 Just pushed the change.)


 2. Is it possible to do some analysis before macroexpansion? For example,
 If I want to look for the pattern

 (if (some-test? …)
 (some-expr …)
 nil)

 and print the following: “WARNING: consider using (when …) instead of (if
 test then nil)”. Is this possible since (when test expr) expands to (if
 test (do expr)). Maybe this kind of code analysis is outside the scope of
 your library?


 This would be easy if the analyzer was more like ClojureScript's analyzer.
 ie. written in Clojure with multimethods.

 But I'm not sure how to do this otherwise. You'd basically want to add a
 new special form that tells the analyzer to stop macroexpanding.

 Basically, yes, this is outside the scope of what I hope to achieve right
 now.

 Thanks,
 Ambrose


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

Re: [ANN] analyze 0.1

2012-01-02 Thread Jonas
Hi,

I pulled the latest version.

 How are you running the code? Could you pull the latest master and try 
again?

Nothing fancy:
- clone the repo
- lein deps
- start emacs, clojure-jack-in,
- compile e.g., examples/docstring - NullPointerException
- comment out the three namespaces I mentioned - It works perfectly :)
 
 Possibly track down exactly which namespace is causing the Exception.

The following works

(def analyzed
  (map #(apply analyze/analyze-path %) 
   '[#_[clojure/test.clj clojure.test]
 [clojure/set.clj clojure.set]
 [clojure/java/io.clj clojure.java.io]
 #_[clojure/stacktrace.clj clojure.stacktrace]
 [clojure/pprint.clj clojure.pprint]
 [clojure/walk.clj clojure.walk]
 [clojure/string.clj clojure.string]
 [clojure/repl.clj clojure.repl]
 [clojure/core/protocols.clj clojure.core.protocols]
 #_[clojure/template.clj clojure.template]]))

Uncommenting any of the three lines above results in a NullPointerException.

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

Re: [ANN] analyze 0.1

2012-01-02 Thread Ambrose Bonnaire-Sergeant
Thanks for that. It seems if the namespace is not already loaded, then
there are issues. I already suspected this, and to be honest I don't know
the Compiler well enough to fully appreciate the problem.

Looking into it.

Ambrose

On Tue, Jan 3, 2012 at 3:37 PM, Jonas jonas.enl...@gmail.com wrote:

 Hi,

 I pulled the latest version.

  How are you running the code? Could you pull the latest master and try
 again?

 Nothing fancy:
 - clone the repo
 - lein deps
 - start emacs, clojure-jack-in,
 - compile e.g., examples/docstring - NullPointerException
 - comment out the three namespaces I mentioned - It works perfectly :)

  Possibly track down exactly which namespace is causing the Exception.

 The following works

 (def analyzed
   (map #(apply analyze/analyze-path %)
'[#_[clojure/test.clj clojure.test]
  [clojure/set.clj clojure.set]
  [clojure/java/io.clj clojure.java.io]
  #_[clojure/stacktrace.clj clojure.stacktrace]
  [clojure/pprint.clj clojure.pprint]
  [clojure/walk.clj clojure.walk]
  [clojure/string.clj clojure.string]
  [clojure/repl.clj clojure.repl]
  [clojure/core/protocols.clj clojure.core.protocols]
  #_[clojure/template.clj clojure.template]]))

 Uncommenting any of the three lines above results in a
 NullPointerException.

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


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

Re: [ANN] analyze 0.1

2012-01-02 Thread Jonas


On Tuesday, January 3, 2012 9:45:04 AM UTC+2, Ambrose Bonnaire-Sergeant 
wrote:

 It seems if the namespace is not already loaded, then there are issues. 


That's it! It's simple to fix. Just require the namespaces in the ns form. 
I can send you a pull request if you want to?

/Jonas 

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