Non Dev Builds

2011-11-16 Thread Andres Gomez
Inspired by Hickey's keynote at the conj, I built a proof of concept
for a program to make non dev builds (remove comments, docstrings,
line breaks)

https://github.com/fractalmedia/prod-build

It is very simple, its most important function is: (defn read-file
[name] (eval (read-string (str '( (slurp name) )
Which strips comments and line breaks.

I'm sharing this for peer reviewing, once it is confirmed that it
works nice (or modified accordingly) i will wrap it as a lein plugin.

I have 2 questions regarding this:
1. is it more efficient to leave anonymous functions on the form of:
#(something %)
or:
(fn* [p1__69#] (something p1__69#))
(because read-file leaves them on the second form.

Also, can somebody confirm if the drop-doc is missing something?


Cheers

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

2011-11-16 Thread Meikel Brandmeyer
Hi,

Am 16.11.2011 um 17:17 schrieb Andres Gomez:

 It is very simple, its most important function is: (defn read-file
 [name] (eval (read-string (str '( (slurp name) )

As a minor nitpick to promote robust code… Please use something like this for 
reading:

(let [eof (Object.)] (take-while (complement #{eof}) (repeatedly #(read 
file-reader false eof

(str ( ...) is so ugly and fragile. There are many files which do not end in 
a newline. And if the last line is a comment…

Sincerely
Meikel


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

2011-11-16 Thread Andres Gomez
Thanks for the robustness tip, Meikel.

Just a question, i dont understand what you state, i dont think it
needs to end in a newline in order to work.

On Nov 16, 5:17 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 16.11.2011 um 17:17 schrieb Andres Gomez:

  It is very simple, its most important function is: (defn read-file
  [name] (eval (read-string (str '( (slurp name) )

 As a minor nitpick to promote robust code… Please use something like this for 
 reading:

 (let [eof (Object.)] (take-while (complement #{eof}) (repeatedly #(read 
 file-reader false eof

 (str ( ...) is so ugly and fragile. There are many files which do not end 
 in a newline. And if the last line is a comment…

 Sincerely
 Meikel

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

2011-11-16 Thread Ben Smith-Mannschott
== FILE ==
(def x 1) NEWLINE
; my comment
==

(str '( (slurp FILE) ) )

produces:

==
'((def x 1) NEWLINE
; my comment)
==

oops.


On Thu, Nov 17, 2011 at 05:32, Andres Gomez and...@fractalmedia.mx wrote:
 Thanks for the robustness tip, Meikel.

 Just a question, i dont understand what you state, i dont think it
 needs to end in a newline in order to work.

 On Nov 16, 5:17 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 16.11.2011 um 17:17 schrieb Andres Gomez:

  It is very simple, its most important function is: (defn read-file
  [name] (eval (read-string (str '( (slurp name) )

 As a minor nitpick to promote robust code… Please use something like this 
 for reading:

 (let [eof (Object.)] (take-while (complement #{eof}) (repeatedly #(read 
 file-reader false eof

 (str ( ...) is so ugly and fragile. There are many files which do not end 
 in a newline. And if the last line is a comment…

 Sincerely
 Meikel

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

2011-11-16 Thread Meikel Brandmeyer (kotarak)
Hi,

Consider this file. The * marks the not there \n.

Foo
; Bar*

And slurp and the str call, you get a string which looks like this 
(Foo\n;Bar). And this gives an error because the closing ) is in the 
comment.

Here you see the effect:

user= (with-open [w (writer x)] (binding [*out* w] (print Foo\n;Bar) 
(flush)))
nil
user= (read-string (str ( (slurp x) )))
RuntimeException EOF while reading  clojure.lang.Util.runtimeException 
(Util.java:156)
user= (with-open [r (LineNumberingPushbackReader. (reader x))]
 (let [eof (Object.)]
   (- #(read r false eof)
 repeatedly
 (take-while (complement #{eof}))
 doall)))
(Foo)
user=

Sincerely
Meikel

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