when to use io! macro?

202 views
Skip to first unread message

Alex Baranosky

unread,
Nov 29, 2010, 11:06:10 PM11/29/10
to clo...@googlegroups.com
Hi guys,

I've recently discovered the io! macro.  Is this something to try to use all the time.. or only in certain situations?

Alex

ka

unread,
Dec 3, 2010, 9:59:06 PM12/3/10
to Clojure
This is a good question and I'm not sure of the right answer or if
there is one. Personally, if I were exposing an API I would use the
io! macro for sure. Even otherwise its a good convention to follow.

On Nov 30, 9:06 am, Alex Baranosky <alexander.barano...@gmail.com>
wrote:

Sunil S Nandihalli

unread,
Dec 3, 2010, 10:10:54 PM12/3/10
to clo...@googlegroups.com
It gives a convenience macro which checks if there is a transaction running when the following code block is called. The idea is that since the code in a transaction could be called a multiple times, you should not do things like sending things on to the network or writing to a file during a transaction. So what you should do is wrap any network/ InputOutput operation in a io! macro. If you did that .. if you call this function inside a transaction it would throw an exception.


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Sunil S Nandihalli

unread,
Dec 3, 2010, 10:12:07 PM12/3/10
to clo...@googlegroups.com
What I said is purely from reading the documentation .. I have never ever used it. Take it with a pinch of salt!

Baishampayan Ghose

unread,
Dec 4, 2010, 6:09:36 AM12/4/10
to clo...@googlegroups.com
> I've recently discovered the io! macro.  Is this something to try to use all
> the time.. or only in certain situations?

It's useful when you are exposing some sort of an API (internal &
external) and want to prohibit the use of certain functions inside
transactions.

Regards,
BG

--
Baishampayan Ghose
b.ghose at gmail.com

Reply all
Reply to author
Forward
0 new messages