Re: Miscellaneous noob questions

2010-06-20 Thread Moritz Ulrich
The -main method is for java interop. Together with :gen-class in the ns-operation, it generates a method with the following layout: public static void main(String [ ] args); which correspondents to the java naming convention for the main method. This generates a .class file and finally a .jar

Re: Miscellaneous noob questions

2010-06-20 Thread Adrian Cuthbertson
The do form (see http://clojure.org/special_forms#do) only encapsulates forms and returns the value of the last form evaluated. The forms generally perform some side effect (otherwise they would be superfluous). An example of where it's useful is with an if... (if some-pred return-something (do

Re: Miscellaneous noob questions

2010-06-18 Thread Baishampayan Ghose
Jared wrote: I'm a little confused over when to use a var vs. a ref vs. an agent vs. an atom. For writing small (200 lines) single-threaded programs when do I want to use each one? ref - When you need to mutate multiple things together synchronously. atom - When you need to mutate a single

Re: Miscellaneous noob questions

2010-06-18 Thread Meikel Brandmeyer
Hi, On Jun 18, 9:01 am, Baishampayan Ghose b.gh...@ocricket.com wrote: ref - When you need to mutate multiple things together synchronously. I'd like to add: When you need to mutate one thing several times synchronously. Sincerely Meikel -- You received this message because you are

Re: Miscellaneous noob questions

2010-06-18 Thread Meikel Brandmeyer
Hi, On Jun 18, 12:12 pm, Baishampayan Ghose b.gh...@ocricket.com wrote: Yep. Thanks for the correction, Meikel. I would say addition, not correction. What you said is was absolutely correct. :) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups

Re: Miscellaneous noob questions

2010-06-18 Thread Baishampayan Ghose
Meikel Brandmeyer wrote: ref - When you need to mutate multiple things together synchronously. I'd like to add: When you need to mutate one thing several times synchronously. Yep. Thanks for the correction, Meikel. Regards, BG -- Baishampayan Ghose b.gh...@ocricket.com oCricket.com -- You

Re: Miscellaneous noob questions

2010-06-18 Thread Craig Andera
I'm a little confused over when to use a var vs. a ref vs. an agent vs. an atom. For writing small (200 lines) single-threaded programs when do I want to use each one? In addition to the great answers you got here, you could have a look at my screencast series on vars, refs, agents, and atoms:

Miscellaneous noob questions

2010-06-17 Thread Jared
I'm a little confused over when to use a var vs. a ref vs. an agent vs. an atom. For writing small (200 lines) single-threaded programs when do I want to use each one? Also, since you can use def to change a binding how do I know for sure that some function is not generating side-effects? I mean

Re: Miscellaneous noob questions

2010-06-17 Thread .Bill Smith
Regarding your def question, it never makes sense to use def inside of a function. In Javascript, you might do this: { var a = 1; var b = 2; ...some statements that might use a and b... } Nothing outside of the curly braces can use those definitions of a and b. The let form is a

Re: Miscellaneous noob questions

2010-06-17 Thread Peter Schuller
I'm a little confused over when to use a var vs. a ref vs. an agent vs. an atom. For writing small (200 lines) single-threaded programs when do I want to use each one? Vars are intended for global data that is not normally modified, except that they can be re-bound thread-locally.