comp.lang.ada
 help / color / mirror / Atom feed
From: synoptik@home.com (A. Logue)
Subject: Re: Problem with function return
Date: 2000/04/03
Date: 2000-04-03T00:00:00+00:00	[thread overview]
Message-ID: <8F0AB9788synoptikdamudderfuck@news> (raw)
In-Reply-To: 38e7a0c8$0$17676@businessnews.de.uu.net

PhyrePhox@firemail.de (Amgarp) wrote in 
<38e7a0c8$0$17676@businessnews.de.uu.net>:

>Hi,
>
>please help me with the following Problem:
>
>Main programm:
>
>type color is (red,gree,blue);
>
>col:color;
>
>col:=some_function(parameter);
>
>Now, "some_function" returns of course a color type,
>but when the parameter is bad(e.g. an empty string), an exception will be
>raised.
>
>What should the function return then?

At work we have an informal standard to declare a "Nil" kind as the first
kind for all enumerated types.  For example 

type color_kind is (nil, red, green, blue);

This works great in many cases where the return type cannot be determined 
(for whatever reason), simply return a nil kind and let the function's 
clients deal with the result.  i.e.  ignore and carry on, delay and retry, 
etc.  







  parent reply	other threads:[~2000-04-03  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-02  0:00 Problem with function return Amgarp
2000-04-02  0:00 ` David Starner
2000-04-03  0:00 ` A. Logue [this message]
2000-04-02  0:00   ` Ray Blaak
2000-04-03  0:00     ` Robert Dewar
2000-04-03  0:00   ` Robert Dewar
2000-04-03  0:00     ` Mats Weber
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox