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
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
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
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
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
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
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:
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
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
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.
10 matches
Mail list logo