#clojure logs

2008-08-23

13:10fandahello everybody!
13:12fandai have been wondering about creating Clojure In Examples
13:13fandai just don't know where is an appropriate place to put it...
13:13fandawould it be ok to add to Clojure wiki?
13:13fandahttp://en.wikibooks.org/wiki/Clojure_Programming
13:13kotarak"Clojure In Examples"? You mean some kind of Cookbook? It think the wiki would be a good place. There are some examples already.
13:14fandaactually it could be 2 things
13:14fandaevery function => example of use
13:14fandaanother
13:15fandaevery common "use area" => cookbook example
13:15fandacookbook examples might fit into wiki
13:15kotarakAn example for every function should go to the reference docs, I think. clojure.org/API comes to mind.
13:15kotarakYep. The latter is a better candidate for the wiki.
13:16kotarakExamples could also go to the docstrings.
13:16fandayes, yes, that makes sense - put it into docstrings
13:17kotarakI think Parth Malwankar already started a great job in expanding the wiki with examples for the different areas of Clojure.
13:17fandaagreed :-)
13:17kotarakFeel free to add yours. :)
13:18fandai am learning the fastest from examples
13:19fandasince clojure.org/api is automatically generated from docstrings, we should extend them
13:19fandai wonder, what Rich's idea about that would be
13:19kotarakThe EXAMPLES section is the first thing I look for, when starting something new. If you still have problems after reading them, they are either too trivial or the API is bad.
13:20kotarakhmmm.. don't know. On the one hand it would be a perfect place, on the other having to scroll five screens up for a docstring. It's probably a point of discussion.
13:21fandai guess so
13:22kotarakI managed to combine docstrings with naturaldocs. I can live with it. :)
13:22fandai am comparing documentations of Clojure to newLISP
13:22fandasee for example:
13:22fandahttp://www.newlisp.org/downloads/newlisp_manual.html#first
13:23fandacurrent http://clojure.org/api
13:23fandais more like reference manual
13:23fandathan a real manual
13:23fandaI wouldn't mind help to extend it a little
13:24kotarakYes. Clojure/API is the reference doc. The rest of clojure.org is more of a manual, introducing different things and stuff.
13:38fanda.......
13:38fandai would like to ask about packaging clojure files
13:38fandai know that they can be included in jar files
13:39fandawhen developing commercial software it might be nice to include clojure files encrypted
13:39fandahas anyone tried that?
13:40fandaor second version is to compile clj files into binary data using clojure and save this binary data... ?
13:41fandaany experience with this?
13:48hoeckfanda: you could encrypt your clj files and decrypt them on the fly while loading
13:49fandahow would you do it? through clojure? or through Java (which gets generated into .class file)?
13:50fandai just wonder what would be safer...
13:51hoeckmhh, you need to obfuscate the decryption key somehow, maybe in a compiled java class
13:53hoeckor in a external library, but this is no *real* security, it just makes it more difficult
13:54fandai think it would be enough for my purposes
13:55fandaif somebody wants to get they usually do :-)
13:55fandaotherwise it works very well
13:55fandai am thinking about writing some bigger application
13:55fanda... or actually rewriting one, which I wrote years ago
13:55fandaClojure is a great candidate for this work
13:56fandajust have to finalize packaging and basic encryption
13:57fandathanks for ideas!
13:58hoecknp, at work we use a windows-dll for keeping database passwords
13:58fanda:-)
14:01hoeckyeah, :)
14:02kotarakIt's sometimes funny what people do to "hide" code. Some guy came to me because he had some VBA in his Excel to hide a certain worksheet. "The sheet cannot be seen or otherwise accessed by the user", claimed the VBA author. The guy had some info on the sheet he "secured", which he needed back. It took me 10 seconds to get the sheet back to normal user access. So much for "security"...
14:14hoeckyeah, sometimes, migrating data from a customers previous system is only possible due to forgotten default passwords or "uid=dbo;pwd=xxx" strings in the applications binary :)
14:15kotarakAnd then there is always the disassembler....
15:19arohnerare nested for loops supposed to work?
15:21arohnerI have (for [..] (let [..] (for [..]...)))
15:21arohnerand it appears that the inner for is not being evaluated
15:23arohnerah, for returns a lazy seq
15:23arohnerso to evaluate for side effects, I needed a dorun on the inner for loop
15:31Chouseryeah, "for" is lazy. If you want side-effects, you might look at "doseq"
15:33arohnerah
15:33arohnerone thing I found slightly weird is that (let) and (for) look sort of the same
15:33arohneri.e. (let [var definition]), (for [var list])
15:33arohnerbut let takes multiple expressions, and for does not
15:34arohnerand doseq doesn't look like either
15:34arohneri.e. I would expect (for) to take expressions
15:34arohnerand doseq to look the same as for, but be lazy
15:48arohneroh, for is meant to return values, so it doesn't make that much sense that it would take multiple expressions
15:49arohnerbut doseq should look like for and let IMO
15:49hoeckarohner: "do" always implies something imperative, non-lazy in clojure
16:12Chouserfor does take multiple expressions: (for [a (range 5) b (range 6 10)] [a b])
16:12arohnerfor binds multiple variables, but evaluates one expression
16:13Chouserah!
16:14ChouserHuh, I honestly hadn't noticed. I guess I've never felt the need for multiple expressions in the body of a for.
16:14arohnerI think that was user error on my par
16:15arohnerI wanted side effects, and I assumed for would give me that
16:15Chouserdoseq is for side-effects, so multiple expressions makes a lot of sense. let is used in both contexts.
16:15Chouseryeah, there's been some talk of renaming "for" since a lot of people seem surprised by its lazy behavior.
16:16arohnerwhile rich is changing things, doseq should take a vector for variable bindings
16:16arohnerso it looks like for and let
16:16Chouseryeah, it could even do comprehension like for