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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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!feeder.eternal-september.org!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx05.iad.POSTED!not-for-mail From: Shark8 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:30.0) Gecko/20100101 Thunderbird/30.0a1 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: "NULL" returned by a function References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Fri, 08 Aug 2014 21:25:32 UTC Organization: TeraNews.com Date: Fri, 08 Aug 2014 15:25:30 -0600 X-Received-Bytes: 1318 X-Received-Body-CRC: 2407547508 Xref: news.eternal-september.org comp.lang.ada:21587 Date: 2014-08-08T15:25:30-06:00 List-Id: On 08-Aug-14 15:10, 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)? What's wrong with discriminated records? Type Some_Container( Empty : Boolean ) is case Empty is When True => Null; When False => Item : T; end case; end record; > To make things worse, T is a controlled type, so if we return just "access > T" the finalization of the object of type T may be easily overlooked. It seems that you're trying to program C/C++ in Ada, don't, that way lies only pain.