comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Problem With Self-Referential Access-to-Subprogram Type
Date: Tue, 04 Nov 2003 15:24:58 +0100
Date: 2003-11-04T15:24:58+01:00	[thread overview]
Message-ID: <s6cfqvc415sh3312knehvpd9bic80pmdia@4ax.com> (raw)
In-Reply-To: c8f570aa.0311040552.79e3ba7c@posting.google.com

On 4 Nov 2003 05:52:01 -0800, taashlo@cyberdude.com (Tad Ashlock)
wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<80teqv099lspc5d4osf2gmu7cld46i0lvb@4ax.com>...
>> On 3 Nov 2003 08:58:45 -0800, taashlo@cyberdude.com (Tad Ashlock)
>> wrote:
>
>[snip]
>
>> >   --  An access-to-procedure type that doesn't work:
>> >   type State2;
>> >   type State2 is access procedure (Tester : in out Test_Type'Class;
>> >                                    Resultant_State : out State2);
>> >   --                premature use of "State2" right here ^
>> 
>>    type State2 is access procedure (Tester : in out Test_Type'Class;
>>                                     Resultant_State : access State2);
>
>Sure, but why should I have to?  What is the difference between a
>function return value and an "out" parameter that makes what I'm
>trying to do an error for one but not the other?

[...]

>But my question above still stands.  It appears that there is
>something special about a function return value that can't be replaced
>with a procedure "out" parameter.

Yes, there is a difference. Technically, for an out parameter the
compiler should still know the object constraints. Consider a case
when the object be passed by value on the stack. State2 is being
declared, so the compiler has no clue. Differently to an out
parameter, a return value is unconstrained. For example you can:

declare
   X : String := Get_Whatever_Length_I_Need;

This does not work with out parameters. Because the compiler should
anyway treat return values in a special way it is no matter whether
its type is fully known. So the difference in general between outs and
returns is.

Though in your case there might actually be no difference (for types
like access-to-subprogram). So theoretically one could drop this
restriction for scalar, access types and some other types, but this
would make the language too complex and its rules more difficult to
understand.

If Ada allowed 'Class for all types, as it IMO should, then you could
write:

    type State2 is access procedure (Tester : in out Test_Type'Class;
                         Resultant_State : in out State2'Class);

with the desired effect. Unfortunately it does not allow this.

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



  reply	other threads:[~2003-11-04 14:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-03 16:58 Problem With Self-Referential Access-to-Subprogram Type Tad Ashlock
2003-11-04 10:04 ` Dmitry A. Kazakov
2003-11-04 13:52   ` Tad Ashlock
2003-11-04 14:24     ` Dmitry A. Kazakov [this message]
2003-11-04 14:52       ` Marius Amado Alves
2003-11-05  8:31         ` Dmitry A. Kazakov
2003-11-05 11:27           ` Marius Amado Alves
2003-11-05 13:33             ` Dmitry A. Kazakov
2003-11-05 14:02               ` Marius Amado Alves
2003-11-05 17:49             ` Adam Beneschan
2003-11-05 18:55               ` Marius Amado Alves
2003-11-05 22:54                 ` Tad Ashlock
2003-11-06 17:45                   ` Warren W. Gay VE3WWG
  -- strict thread matches above, loose matches on Subject: below --
2003-11-03 17:32 amado.alves
2003-11-04 14:02 ` Tad Ashlock
replies disabled

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