From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: "NULL" returned by a function Date: Fri, 08 Aug 2014 14:19:13 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 8 Aug 2014 21:19:14 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="a0c81a81d1281113b3831cf0c04e791a"; logging-data="14491"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Xd59Du+AHfdoMg4x16U7+ghILc+LZ054=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: Cancel-Lock: sha1:x1nOhQyAQA6fBAwcovS1ja669KM= Xref: news.eternal-september.org comp.lang.ada:21585 Date: 2014-08-08T14:19:13-07:00 List-Id: On 08/08/2014 02:10 PM, Victor Porton wrote: > What if I want to make a function which returns either a value of type T or > a value signifying "nothing" (like null pointer)? Typically one should use a variant record with one variant for "nothing" and another for the value: type Result (Has_Value : Boolean := False) is record case Has_Value is when False => null; when True => Value : T; end case; end record; -- Jeff Carter "We call your door-opening request a silly thing." Monty Python & the Holy Grail 17