comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: "NULL" returned by a function
Date: Sat, 09 Aug 2014 00:10:28 +0300
Date: 2014-08-09T00:10:28+03:00	[thread overview]
Message-ID: <ls3ec1$v3q$1@speranza.aioe.org> (raw)

What if I want to make a function which returns either a value of type T or 
a value signifying "nothing" (like null pointer)?

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.

What is the best way to implement this? variant record? whatever?

Or maybe should I modify the type T to allow it contain "null" state? (In 
fact the particular T which I use can be easily modified to allow storing 
there null and checking whether it's state is null. But I think on the way 
not to be dependent on the ability to change the definition of T.)

-- 
Victor Porton - http://portonvictor.org

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

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-08 21:10 Victor Porton [this message]
2014-08-08 21:19 ` "NULL" returned by a function 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
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