DMD 1.027 and 2.011 releases
Georg Wrede
georg at nospam.org
Mon Mar 3 14:30:27 PST 2008
Walter Bright wrote:
> Graham St Jack wrote:
>
>> It will be a good trick if you can pull it off. I don't see how it can
>> be done without examining the source code of all the called functions,
>> leaving us back where we started with throw specs.
>>
>> The C++ approach of a runtime check isn't perfect, but at least it can
>> be done, and provides a more definite form of documentation than
>> comments.
>
>
> Are you sure it does a runtime check for nothrow?
>
>> If the static checks aren't done well enough and runtime checks aren't
>> done at all, I would prefer to rely on comments.
IMHO, it would behoove the compiler to keep track of possible/potential
exceptions a function can throw. (Just as well as (again, IMHO) it would
behoove the compiler to keep track of functions that /potentially/ have
side effects.)
The workload for doing either defines a pattern, and doing the other is
simply a repetition of the pattern. Therefore, doing both is not much
more work than doing only one of these.
In the optimal future, entering a function would give you information
(not necessarily runtime, but definitely info when browsing the docs) on
whether it potentially generates an exception/changes data. A year after
this info is standard in the docs, several new ideas about Functional
Programming will emerge, in D. (Ermmmm, new to D, anyway.)
-----
Keeping track of these two things may be considered superfluous
drudgery, but the potential benefits well outweigh the invested effort.
More information about the Digitalmars-d-announce
mailing list