Nothrow, pure in druntime

Michel Fortin michel.fortin at michelf.com
Mon Jan 26 04:20:18 PST 2009


On 2009-01-25 14:39:52 -0500, Walter Bright <newshound1 at digitalmars.com> said:

> I did think of making all functions that are extern(C) automatically 
> nothrow, but was concerned that it would result in a lot of bugs and 
> broken code from ones that did throw.

It's better that way, because it allows you to write proper wrappers 
for C++ functions that may throw exceptions. Like this:

	extern "C"
	int _doSomething_wrapper(int value)
	{
		try
		{
			return doSomething(value);
		}
		catch (const std::exception & e)
		{
			_d_throw_exception(e.what());
		}
	}

with _d_throw_exception written in D and throwing an exception.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list