Re: [AD] C++ fix math

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 10 August 2002 19:26, Gillius wrote:
> I used to use no-throw exception specifiers, but check this out:
> http://www.boost.org/more/lib_guide.htm#Exception-specification

I'm afraid that it makes some unqualified statements. There is no 
concrete data. But I refer you to [1].

In my view, exception specifiers are a programmer's tool: I can say 
"this function can only throw exceptions of type X", and if it throws a 
Y, then the program aborts. Then I can look at it and say "oops, my 
design was wrong". It is an early warning that the design isn't going 
as planned.

In addition, some quick tests with g++ show that simple exception 
specifications (whether not specified, empty or specified) don't affect 
code generation.

> The bad thing about C++ is even if you declare "throw()" it doesn't
> mean a function throws nothing.  Any C++ code can throw any exception
> at any time. 

Not quite. You see, if I know that a block of C++ code can't throw an 
exception then I can put an empty exception specification on that. In 
the fix() example, we call a C function (which doesn't call other C++ 
functions in turn), so I know that no exceptions can be thrown, hence 
the specifier.

> The thing that the "throw()" does is run the bad
> exception type handler if you throw something, or if you throw a
> non-specified exception. 

That's correct, and that's why I think it is a good programming tool.

[snip]
> This has the benefit of allowing rad/fix conversions for const fix
> objects. The static function is not really related, but might be
> another useful addition.

Yup, that's cool. If we are going to add anything, we should add both 
(perhaps renaming mine convert_* and yours get_*). Eric/Peter, would 
you like a patch?

[1] The C++ Programming Language, 3rd edition, 14.6.1.
(yes, I know I always quote the same book, but it is written by Bjarne 
Stroustrup and I guess he knows what he's talking about... :-) )

Bye for now,
- -- 
Laurence Withers,  lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9VWbAUdhclgSmRuoRAoloAKCOKPLPmi9xI4js9GuXhDURYfVDjgCeIBes
WY7yDwLfejc3weBaY1WNjMM=
=yOsY
-----END PGP SIGNATURE-----



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/