Hi Russel - On 9/3/16, 6:57 AM, "Russel Winder" <[email protected]> wrote:
>Has Chapel got a specific RAII construct? > >Like D, Chapel puts structs (aka records) on the stack and classes on >the heap. So as long as the struct/record destructor tidies things up, >RAII is automated. > >but what about class objects, file handles, database connections? >Python provides with/context manager to handle this sort of RAII. Has >Chapel got something similar? We've talked about having a 'with' construct in the context of the improvements to error handling. I don't remember anybody being opposed to it but I'd expect Chapel to get better error handling first. Right now, one of my least favorite Chapel language features is the 'let' keyword. Perhaps that could be used/abused to implement such a context. (But I don't personally see anything wrong with the "with" syntax). Generally though for now I'd expect to wrap class object, file handles, etc in records. We've been talking about how we can create generic records to enable that wrapping. That will put is in a similar place to C++'s std::unique_ptr and std::shared_ptr. I think it's reasonable to consider ways the Chapel language can help make such ideas easy to use, but I'd personally try to start with the equivalents to the C++ mechanisms. Cheers, -michael ------------------------------------------------------------------------------ _______________________________________________ Chapel-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/chapel-users
