* Access types - what's happening here?
@ 2010-05-25 22:27 KK6GM
2010-05-25 22:38 ` Yannick Duchêne (Hibou57)
0 siblings, 1 reply; 5+ messages in thread
From: KK6GM @ 2010-05-25 22:27 UTC (permalink / raw)
Looking at Cohen's "Ada as a 2nd Language" I see in chapter 8 (Access
Types), p.319, this construct which I do not understand. But first,
the construct I do understand:
Old_Serial_Number := Serial_Number("Lovelace, Ada").all;
No confusion about that whatsoever. However, that is followed by
this:
"More interestingly, the assignment
Serial_Number( "Lovelace, Ada").all := New_Serial_Number;
copies the contenst of the integer variable into the variable
pointed to by the result of the function call."
Huh? Where does the New_Serial_Number value end up here?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Access types - what's happening here?
2010-05-25 22:27 Access types - what's happening here? KK6GM
@ 2010-05-25 22:38 ` Yannick Duchêne (Hibou57)
2010-05-25 22:39 ` Yannick Duchêne (Hibou57)
0 siblings, 1 reply; 5+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2010-05-25 22:38 UTC (permalink / raw)
Le Wed, 26 May 2010 00:27:39 +0200, KK6GM <kk6gm@att.net> a écrit:
> Looking at Cohen's "Ada as a 2nd Language" I see in chapter 8 (Access
> Types), p.319, this construct which I do not understand. But first,
> the construct I do understand:
>
> Old_Serial_Number := Serial_Number("Lovelace, Ada").all;
>
> No confusion about that whatsoever. However, that is followed by
> this:
>
> "More interestingly, the assignment
> Serial_Number( "Lovelace, Ada").all := New_Serial_Number;
> copies the contenst of the integer variable into the variable
> pointed to by the result of the function call."
>
> Huh? Where does the New_Serial_Number value end up here?
As I don't see any trouble here, I'm not sure I've understood the
question. However, here is the answer I give to it as I can understand it :
If you do
Serial_Number( "Lovelace, Ada").all := New_Serial_Number;
You get the same thing as if you do
Old_Serial_Number := Serial_Number("Lovelace, Ada").all;
Old_Serial_Number.all := New_Serial_Number;
Can you give a link to the page you are reading ?
--
There is even better than a pragma Assert: a SPARK --# check.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Access types - what's happening here?
2010-05-25 22:38 ` Yannick Duchêne (Hibou57)
@ 2010-05-25 22:39 ` Yannick Duchêne (Hibou57)
2010-05-25 22:47 ` KK6GM
0 siblings, 1 reply; 5+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2010-05-25 22:39 UTC (permalink / raw)
Le Wed, 26 May 2010 00:38:03 +0200, Yannick Duchêne (Hibou57)
<yannick_duchene@yahoo.fr> a écrit:
> You get the same thing as if you do
>
> Old_Serial_Number := Serial_Number("Lovelace, Ada").all;
> Old_Serial_Number.all := New_Serial_Number;
Typo error, sorry. You should read:
Old_Serial_Number := Serial_Number("Lovelace, Ada");
Old_Serial_Number.all := New_Serial_Number;
instead.
--
There is even better than a pragma Assert: a SPARK --# check.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Access types - what's happening here?
2010-05-25 22:39 ` Yannick Duchêne (Hibou57)
@ 2010-05-25 22:47 ` KK6GM
2010-05-25 23:33 ` Yannick Duchêne (Hibou57)
0 siblings, 1 reply; 5+ messages in thread
From: KK6GM @ 2010-05-25 22:47 UTC (permalink / raw)
On May 25, 3:39 pm, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> Le Wed, 26 May 2010 00:38:03 +0200, Yannick Duchêne (Hibou57)
> Old_Serial_Number := Serial_Number("Lovelace, Ada");
> Old_Serial_Number.all := New_Serial_Number;
Yes, after a few more minutes thinking about it I see what's
happening. The value of New_Serial_Number is being stored via the
unnamed access value returned by Serial_Number().
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Access types - what's happening here?
2010-05-25 22:47 ` KK6GM
@ 2010-05-25 23:33 ` Yannick Duchêne (Hibou57)
0 siblings, 0 replies; 5+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2010-05-25 23:33 UTC (permalink / raw)
Le Wed, 26 May 2010 00:47:24 +0200, KK6GM <mjsilva@scriptoriumdesigns.com>
a écrit:
> On May 25, 3:39 pm, Yannick Duchêne (Hibou57)
> <yannick_duch...@yahoo.fr> wrote:
>> Le Wed, 26 May 2010 00:38:03 +0200, Yannick Duchêne (Hibou57)
>
>> Old_Serial_Number := Serial_Number("Lovelace, Ada");
>> Old_Serial_Number.all := New_Serial_Number;
>
> Yes, after a few more minutes thinking about it I see what's
> happening. The value of New_Serial_Number is being stored via the
> unnamed access value returned by Serial_Number().
You got it!
And welcome to/aboard Ada
--
There is even better than a pragma Assert: a SPARK --# check.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-25 23:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-25 22:27 Access types - what's happening here? KK6GM
2010-05-25 22:38 ` Yannick Duchêne (Hibou57)
2010-05-25 22:39 ` Yannick Duchêne (Hibou57)
2010-05-25 22:47 ` KK6GM
2010-05-25 23:33 ` Yannick Duchêne (Hibou57)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox