On Wed, Apr 21, 2010 at 9:06 AM, ka <[email protected]> wrote:

> Connection1 conn1 = null;
> Connection2 conn2 = null;
> try {
>  conn1 = API1.getConnection ..;
>  conn2 = API2.getConnection ..;
>  ...
> }


You can't do that without using atoms or something, because you're assigning
to conn1 and conn2 twice.  That's not legal in Clojure because what "let"
gives you aren't variables, but local constants.

One solution would be to add a new construct to the language:

(try-let [bindings] (body) (catch...) (finally...))

where any exception during evaluation of the [bindings] would be caught just
as if it happened inside the body, and of course the bound variables would
be visible to both the catch blocks and the finally block.

It could be implemented as a macro that duplicated the catch/finally blocks
within and outside a let...

-- 
Mark J. Reed <[email protected]>

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

Reply via email to