[fpc-devel]a 'rises' keyword proposal

Michael Van Canneyt michael.vancanneyt at wisa.be
Wed Jan 23 17:47:47 CET 2002


On Wed, 23 Jan 2002, Aleksey V. Vaneev wrote:

> Hello,
>
>   Maybe my suggestion is outdated, but is it possible to add some
>   keyword like 'rises' to function/method/procedure declarations?
>
>   This way sources will become more self-documenting and much more
>   predictable. In fact in C++ something like that (although, in a not
>   very useful manner) already presents and I've always used it when
>   programmed in C++.
>
>   So, by default when 'rises' keyword is not declared in
>   function declaration, no exception drops are allowed in that function.

I don't see how this can be useful in practice:

1. This would mean that 99,99 % of all functions need it:
   The memory manager can raise an exception, so almost all functions can
   implicitly raise an exception, expecially if they use ansistrings.

   Function A uses function B; Function B MAY use ansistrings (depending
   on $H+), but function A is not aware of this. So, A can give rise to
   an exception, but has no way of knowing this.

2. As pointed out: If a function uses a string, it depends on the
   setting of the $H+ flag.

3. If you don't use the sysutils unit, no exceptions will be generated
   for system errors. If you do, then they are generated. It is hard to
   predict the usage of this unit.

So, while the idea is good in theory, I think that this would be very
impractical. You should always expect ANY function to be able to raise
an exception.

Michael.





More information about the fpc-devel mailing list