* pointers and protected objects
@ 2014-10-17 12:51 tonyg
2014-10-17 13:20 ` Simon Wright
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: tonyg @ 2014-10-17 12:51 UTC (permalink / raw)
I can create pointers to protected objects, but how do I initialise the protected object as it is a limited type and the syntax
po_ptr := new Po_Type'(Po_Type_Instance) would not be allowed
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pointers and protected objects
2014-10-17 12:51 pointers and protected objects tonyg
@ 2014-10-17 13:20 ` Simon Wright
2014-10-17 14:51 ` tonyg
2014-10-17 15:42 ` Adam Beneschan
2014-10-23 8:54 ` tonyg
2 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 2014-10-17 13:20 UTC (permalink / raw)
tonyg <tonythegair@gmail.com> writes:
> I can create pointers to protected objects, but how do I initialise
> the protected object as it is a limited type and the syntax
>
> po_ptr := new Po_Type'(Po_Type_Instance) would not be allowed
So far as I am aware, you can't; the PO needs to be self-initializing
(you can give the protected type discriminants, which may help)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pointers and protected objects
2014-10-17 13:20 ` Simon Wright
@ 2014-10-17 14:51 ` tonyg
2014-10-17 15:36 ` Simon Wright
0 siblings, 1 reply; 7+ messages in thread
From: tonyg @ 2014-10-17 14:51 UTC (permalink / raw)
ah well shame. Thanks anyway. I am going to implement each object in an array then, that should do the job,
do you know if I separate the body of the protected object in a different compilation file and what how I name the file in gnat ?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pointers and protected objects
2014-10-17 14:51 ` tonyg
@ 2014-10-17 15:36 ` Simon Wright
2014-10-17 17:21 ` AdaMagica
0 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 2014-10-17 15:36 UTC (permalink / raw)
tonyg <tonythegair@gmail.com> writes:
> do you know if I separate the body of the protected object in a
> different compilation file and what how I name the file in gnat ?
Yes.
-- pak.ads
package pak is
protected type p is
...
end p;
end pak;
-- pak.adb
package body pak is
protected body p is separate;
end pak;
-- pak-p.adb
separate (pak)
protected body p is
...
end p;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pointers and protected objects
2014-10-17 12:51 pointers and protected objects tonyg
2014-10-17 13:20 ` Simon Wright
@ 2014-10-17 15:42 ` Adam Beneschan
2014-10-23 8:54 ` tonyg
2 siblings, 0 replies; 7+ messages in thread
From: Adam Beneschan @ 2014-10-17 15:42 UTC (permalink / raw)
On Friday, October 17, 2014 5:51:43 AM UTC-7, tonyg wrote:
> I can create pointers to protected objects, but how do I initialise the protected object as it is a limited type and the syntax
>
> po_ptr := new Po_Type'(Po_Type_Instance) would not be allowed
That syntax would mean that a new protected object would be created and Po_Type_Instance would be copied to it. But you can't copy protected objects.
You can, however, say
po_ptr := new Po_Type;
or
po_ptr := new Po_Type'(Some_Function(...));
where Some_Function is a function that returns a Po_Type.
-- Adam
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pointers and protected objects
2014-10-17 15:36 ` Simon Wright
@ 2014-10-17 17:21 ` AdaMagica
0 siblings, 0 replies; 7+ messages in thread
From: AdaMagica @ 2014-10-17 17:21 UTC (permalink / raw)
Am Freitag, 17. Oktober 2014 17:36:54 UTC+2 schrieb Simon Wright:
Note: this naming scheme is GNAT's standard. Other compilers use different schemes.
> -- pak.ads
> package pak is
> end pak;
>
> -- pak.adb
> package body pak is
> protected body p is separate;
> end pak;
>
> -- pak-p.adb
> separate (pak)
> protected body p is
> end p;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: pointers and protected objects
2014-10-17 12:51 pointers and protected objects tonyg
2014-10-17 13:20 ` Simon Wright
2014-10-17 15:42 ` Adam Beneschan
@ 2014-10-23 8:54 ` tonyg
2 siblings, 0 replies; 7+ messages in thread
From: tonyg @ 2014-10-23 8:54 UTC (permalink / raw)
Thanks for your help all :)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-23 8:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-17 12:51 pointers and protected objects tonyg
2014-10-17 13:20 ` Simon Wright
2014-10-17 14:51 ` tonyg
2014-10-17 15:36 ` Simon Wright
2014-10-17 17:21 ` AdaMagica
2014-10-17 15:42 ` Adam Beneschan
2014-10-23 8:54 ` tonyg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox