comp.lang.ada
 help / color / mirror / Atom feed
From: "Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr>
Subject: Re: Abstract null value
Date: Thu, 8 Feb 2001 19:24:23 +0100
Date: 2001-02-08T19:24:23+01:00	[thread overview]
Message-ID: <hgou59.f7v1.ln@skymaster.axlog.fr> (raw)
In-Reply-To: 95uda1$pq6$1@nnrp1.deja.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]

"Ted Dennison" <dennison@telepath.com> a �crit dans le message news: 95uda1$pq6$1@nnrp1.deja.com...
> In article <95sgl4$3c8$2@wanadoo.fr>,
>   "Jean-Pierre Rosen" <rosen.adalog@wanadoo.fr> wrote:
>
> > Sometimes, the constructor is not able to perform the job, and you
> > want to return some "null value" (I know, you can also raise an
> ...
> > package Abstract_Type is
> >    type Root_Type is abstract tagged null record;
> >    procedure Oper (X : Root_Type) is abstract;
> >
> >    Null_Value : constant Root_Type'Class;
>
> For this system to work, all your "constructors" would have to be
> functions returning something like Root_Type'Class, and their targets
> would all have to be class-wide initializations or allocators, right? Or
> is that some kind of unwritten standard of which I'm unaware? A slim
> majority of the time when I'm "constructing" a tagged type object
> there's a specific type the expression is expecting. If I were to do
> that with the above system, then I'd just get Constraint_Error.

The kind of constructor I was thinking about is one that, for example, reads a file and returns various objects (widgets...). If you
have a syntax error, or the end of file, you may want to return a null value. I'm not saying it's applicable to everything, just
that it can be useful in some cases.

--
---------------------------------------------------------
           J-P. Rosen (Rosen.Adalog@wanadoo.fr)
Visit Adalog's web site at http://pro.wanadoo.fr/adalog





      reply	other threads:[~2001-02-08 18:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-07 18:56 Abstract null value Jean-Pierre Rosen
2001-02-08 15:17 ` Ted Dennison
2001-02-08 18:24   ` Jean-Pierre Rosen [this message]
replies disabled

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