TrapC is an extension of the C programming language that removes the keywords goto
and union
, adds the keywords trap
and alias
, and adopts a few features from C++ that improve safety such as constructors and destructors, said Rowe. It also provides a couple of new features not in C or C++. Despite being a minimalist programming language with the same number of keywords as C, TrapC has a surprising amount of C++ code compatibility, he said.
Rowe presented TrapC at an ISO C meeting this week. Developers can download a TrapC whitepaper and offer Rowe feedback. According to the whitepaper, TrapC’s memory management is automatic and cannot leak memory. Pointers are lifetime-managed, not garbage-collected. Also, TrapC reuses a few code safety features from C++, notably member functions, constructors, destructors, and the new
keyword.
TrapC is not the only attempt to deal with memory safety in C or C++. The C++ Partnership worked on its Safe C++ Extensions project to remedy C++memory safety. Rowe said that other proposals do not offer the comprehensive memory safety offered by TrapC.