October 11, 2003 throw - catch | ||||
---|---|---|---|---|
| ||||
Any reason why we can't borrow some nice parts from a couple of other languages, and allow the following Enumerator Enumerate() { hrecls_t hSrch; recls_rc_t rc = Search_Create(m_searchRoot, m_pattern, m_flags, hSrch); try { return new Enumerator(hSrch, rc); } catch { Search_Close(hSrch); throw; } } which would translate to Enumerator Enumerate() { hrecls_t hSrch; recls_rc_t rc = Search_Create(m_searchRoot, m_pattern, m_flags, hSrch); try { return new Enumerator(hSrch, rc); } catch(Exception x) { Search_Close(hSrch); throw x; } } It's a nice sugar. |
October 14, 2003 Re: throw - catch | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Matthew Wilson wrote:
>Any reason why we can't borrow some nice parts from a couple of other
>languages, and allow the following
>
> Enumerator Enumerate()
> {
> hrecls_t hSrch;
> recls_rc_t rc = Search_Create(m_searchRoot, m_pattern,
>m_flags, hSrch);
>
> try
> {
> return new Enumerator(hSrch, rc);
> }
> catch
> {
> Search_Close(hSrch);
>
> throw;
> }
> }
>
>
>which would translate to
>
> Enumerator Enumerate()
> {
> hrecls_t hSrch;
> recls_rc_t rc = Search_Create(m_searchRoot, m_pattern,
>m_flags, hSrch);
>
> try
> {
> return new Enumerator(hSrch, rc);
> }
> catch(Exception x)
> {
> Search_Close(hSrch);
>
> throw x;
> }
> }
>
>It's a nice sugar.
>
>
>
>
>
I like it.
-Anderson
|
Copyright © 1999-2021 by the D Language Foundation