comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com (Robert Dewar)
Subject: Re: what means the " ' " in use with a record type?
Date: 24 Aug 2002 06:19:04 -0700
Date: 2002-08-24T13:19:04+00:00	[thread overview]
Message-ID: <5ee5b646.0208240519.9e2a872@posting.google.com> (raw)
In-Reply-To: hKw99.5354$jD1.434739270@newssvr13.news.prodigy.com

tmoran@acm.org wrote in message news:<hKw99.5354$jD1.434739270@newssvr13.news.prodigy.com>...
> > return new node'(value => x, to => l);

> > what means the apostrophe between node and (value => ......?

>   It means you want to allocate a new object of type "node" and
> give it an initial value of (x,l).

This is highly misleading, The questioner asked about the apostrophe, and
Tom is answering about the whole construct.

The quote has nothing whatever to do with allocation.

The expression node'(....)

is called a qualified expression. In some contexts you can simply write
the aggregate (in this case (value => x, to => 1)) and it is obvious what
you are talking about. For example

   N : node := (value => x, to => 1);

is just fine because we obviously expect a node here. But if I just write

    x := new (value => x, to => 1);

then the allocator has no idea what you are talking about, since there is
nothing to say that this is a node. The qualified expression fixes this
a'b in general says, I have something of type a with the value computed by
the expression b.

So to fix the allocator we need

   x := new node'(value => x, to => 1);

and now the allocator knows what type of thing you are trying to allocate.



  reply	other threads:[~2002-08-24 13:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <c923f575.0208231040.301add2@posting.google.com>
2002-08-23 20:16 ` what means the " ' " in use with a record type? tmoran
2002-08-24 13:19   ` Robert Dewar [this message]
2002-08-25  6:15     ` tmoran
2002-08-25 15:42       ` Ben Brosgol
2002-08-25 23:29         ` Steven Deller
2002-08-26  1:20           ` tmoran
2002-08-26 20:43             ` Robert Dewar
2002-08-26 20:41       ` Robert Dewar
2002-08-26 21:37         ` tmoran
2002-08-25  5:00 ` R. Tim Coslet
replies disabled

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