This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: try-with-resources
- From: Per Bothner <per at bothner dot com>
- To: Helmut Eller <eller dot helmut at gmail dot com>
- Cc: kawa at sources dot redhat dot com
- Date: Sat, 07 Jan 2012 13:13:01 -0800
- Subject: Re: try-with-resources
- References: <m2r4zb98qo.fsf@gmail.com>
On 01/07/2012 01:12 AM, Helmut Eller wrote:
Just wondering, does Kawa already have somehing like the extened try in
Java7?
Not yet - though it seems a reasonable thing to add.
A possible syntax:
(try-with-resources
((VAR [:TYPE] INIT) ...)
BODY)
(The Java "extended" try-with-resources with a catch-clause
or a finally-clause is just a basic try-with-resources
inside of a traditional try statement, so no need to support
that in the Kawa try-with-resources syntax, IMO.)
I haven't looked at the specification closely enough to see if
it can be implemented using a macro only.
I don't know if there is any SRFI or other Scheme that has
something similar, in which case we should consider that as well.
And would that work on Java6 too?
try-with-resources is defined in terms of java.lang.AutoCloseable,
which is specific to Java7. It would be plausible for Java6 to
implement a restricted version that uses java.io.Closeable.
Or one could just accept any class with a close method - I don't
know if that would cause problems.
try-with-resources also assumes Throwable#addSuppressed, which
is new in java7, though a java6 "backport" could skip that.
--
--Per Bothner
per@bothner.com http://per.bothner.com/