[linux-l] RS-232 oder USB lesen mit (Schauder...) Java Os-unabhaengig

Oliver Bandel oliver at first.in-berlin.de
Do Sep 29 17:13:16 CEST 2005


On Tue, Sep 27, 2005 at 04:59:52PM +0200, Jan-Benedict Glaw wrote:
> On Tue, 2005-09-27 14:50:13 +0200, Oliver Bandel <oliver at first.in-berlin.de> wrote:
> > On Tue, Sep 27, 2005 at 02:18:14PM +0200, olafBuddenhagen at gmx.net wrote:
> > Gib doch mal ein Beispiel; bitte auch mit Compiler-Parametern,
> > zum nachvollziehen.
> jbglaw at bixie:~$ cat foo.c 
> #include <stdio.h>
> 
[...]
> jbglaw at bixie:~$ gcc -Wall -W -pedantic foo.c -c
> foo.c: In function ???check_this???:
> foo.c:8: warning: enumeration value ???BAZ??? not handled in switch


OK, diese Trivialität, wie Du sie nanntest, ist damit abgegessen.

Was aber, wenn zur Laufzeit ein Fall auftritt, der nicht
abgefragt wird in dem Code?
 (weder explizit, noch mit Wildcard-match?!)


Beipiel:

========================================================
# type my_type = Blah | Blih | Blubb | Untested_case;;
type my_type = Blah | Blih | Blubb | Untested_case
# let say_something x = match x with
    Blah -> "Blah"
   |Blih -> "Dies ist der Blih"
   |Blubb -> "Blubber-Hannes";;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Untested_case
val say_something : my_type -> string = <fun>
# say_something Blih;;
- : string = "Dies ist der Blih"
# say_something Untested_case;;
Exception: Match_failure ("", 1, 22).
# 
========================================================


Welche Exception wirft C bzw. gcc in dem Falle?

Wenn "default" vergessen wurde, fliegt Dir der C-Code
möglicherweise um die Ohren!

Gruß,
   Oliver



Mehr Informationen über die Mailingliste linux-l