Bart said:
In my opinion, that is already possible, with the C language as it is
currently defined.
I don't see those as a necessary part of a 'normal software
engineering environment'.
Some of them might be useful in some circumstances, but I can live
without them if I must.
If you must, you can program in assembler.
If I must I can do without a debugger, using edlin for editing,
etc.
But why must you?
This is the point!
All of them are useful, and once you have them it is obvious that they
give you more development possibilities:
o fixed point numbers
o bound checked arrays
o container access to abstract data types.
They allow you to do things that in most environments
are considered normal. Why must C remain at this
level? There is NO REASON.
Can you explain then why there are so few compilers for embedded
targets that provide an exception-handling extension? I have never
encountered or heard of one, while I work in that segment of
engineering.
And those compilers typically have plenty of extensions.
1) Some Real Time OSes provide facilities of their own.
2) The first requirement when I ported lcc-win to an
embedded system was try/catch.
3) Extensions do exist. Look at
http://www.on-time.com/ddj0011.htm
for an example
4) There are hundreds of different packages providing try/catch
using different syntax mist of them based in setjmp/longjmp
or assembly. This points to a HOLE in the language.
5) Microsoft provides this facilities. You may have heard of
this small company.
6) Some research papers like
Abnormal Events Handling for Dependable Embedded Systems
http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?tp=&arnumber=4020866&isnumber=4020846
where (another) extension for C is proposed.
7) Ideals symposium for embedded software. One research paper:
http://www.embeddedsystems.nl/site/frames.html?/site/projects/ideals/symposia.asp
Discovering faults in exception handling as an example of recurring
code; Magiel Bruntink (CWI)
Exception handling is a key component of any reliable software system.
This allows the system to detect errors, and react to them
correspondingly. Despite its importance exception handling is often
the least well understood, documented and tested part of the system.
An approach and analysis tool will be presented to reduce the number
of implementation faults related to exception handling.
And I could go on and on. Google reports 1 840 000 hits.
If you have never even heard about a compiler like that this is because
progress in embedded software is SLOW, and in C is even slower!
This doesn't mean that reasearch people do not see this as a problem, or
that people aren't trying to fix this problem. It means that there is
a big penalty for not having a lightweight try/catch IN THE LANGUAGE.
And how does exception handling here?
To me, exception handling is a mechanism to do "long-range" error
*reporting*.
No. It allows you to establish nested RECOVERY POINTS in your
software, where errors can be handled and then, the program is
allowed to continue!
The advantage is that intermediate code does not have to be aware of
which error occured, at most it must know to do cleanup.
Yes.
Exception handling does not help in any way in detecting problems (you
still have to test various contidions and throw an exception if
needed) or in handling the problems.
Nobody said that exception handling will handle
the errors. This is a strawman argument, excuse me. It helps
in programming for handling errors but it doesn't SOLVE the
problems OF COURSE!
Exception handling does not magically stop the application from
crashing if you perform an illegal operation.
The Microsoft exception handling yes, it stops that.