www.digitalmars.com         C & C++   DMDScript  

D - throw - catch

reply "Matthew Wilson" <matthew stlsoft.org> writes:
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.
Oct 10 2003
parent J Anderson <anderson badmama.com.au.REMOVE> writes:
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.



  

-Anderson
Oct 14 2003