comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <OneWingedShark@gmail.com>
Subject: Re: "NULL" returned by a function
Date: Fri, 08 Aug 2014 15:25:30 -0600
Date: 2014-08-08T15:25:30-06:00	[thread overview]
Message-ID: <gfbFv.200574$DV4.141453@fx05.iad> (raw)
In-Reply-To: <ls3ec1$v3q$1@speranza.aioe.org>

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.

  parent reply	other threads:[~2014-08-08 21:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-08 21:10 "NULL" returned by a function Victor Porton
2014-08-08 21:19 ` Jeffrey Carter
2014-08-08 22:04   ` Victor Porton
2014-08-08 22:50     ` Jeffrey Carter
2014-08-09 12:45   ` Victor Porton
2014-08-09 15:13     ` Jeffrey Carter
2014-08-08 21:25 ` Shark8 [this message]
2014-08-09 16:15 ` Maciej Sobczak
replies disabled

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