comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Discriminant name must be alone
Date: Tue, 24 Dec 2002 12:16:50 +0100
Date: 2002-12-24T12:16:50+01:00	[thread overview]
Message-ID: <au9fmc$5kta0$2@ID-77047.news.dfncis.de> (raw)
In-Reply-To: wccel88hm2w.fsf@shell01.TheWorld.com

Robert A Duff wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> There is a third answer: "user-defined constructors".
> 
> What do you mean by "user-defined constructors"?  How do they differ
> from functions?

A function returns some object. To use it you must have an assignment. This 
would not work for limited types. A constructor returns nothing. For

type Buffer (Length : Positive) is ...;

Buffer (*) could be viewed as a "call to constructor". Constructor works 
even if Buffer is limited:

X : Buffer (12);

> And how do they allow nested constraints to depend
> upon arbitrary expressions involving discriminants?

Presently we have only predefined "constructors" with the parameters = 
discriminats. Let we have an ability to define a constructor with other 
parameters. Then it would evaluate the discriminants from that parameters. 
Further, a discriminated type could be declared with <> as the discriminant 
to hide the true disriminants in the private part making them an 
implementation detail.

I have a vague idea how to provide constructors for Ada, but I rather start 
a separate thread for it.

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2002-12-24 11:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-21 19:22 Discriminant name must be alone Michal Nowak
2002-12-21 23:08 ` Robert A Duff
2002-12-23 11:21   ` Dmitry A. Kazakov
2002-12-23 14:00     ` Robert A Duff
2002-12-24 11:16       ` Dmitry A. Kazakov [this message]
2002-12-25 14:29   ` Michal Nowak
replies disabled

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