comp.lang.ada
 help / color / mirror / Atom feed
* Re: Problems with 'class, help anyone?
@ 2002-11-11 15:12 Alexandre E. Kopilovitch
  2002-11-12 12:20 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 34+ messages in thread
From: Alexandre E. Kopilovitch @ 2002-11-11 15:12 UTC (permalink / raw)


>> There is another way, with perhaps even less incompatibility: let's introduce
>> third mode for a formal parameter - "return" mode (in addition to conventional
>> "in" and "out"). That "return" may be applied to the procedure's first parameter
>> only, and it means the same as "out" mode, with single exception: if the first
>> parameter of a procedure is in "return" mode then the procedure *may* be called
>> without the corresponding (first) argument, and in such a case it returns value.
>> For example:
>> 
>> procedure Two_Fold(Result : return Boolean; Something : in Integer);
>> 
>> X : Boolean;
>> Two_Fold(X, 0);  -- "return" as "out", procedure does not return value
>> 
>> if Two_Fold(0) then  -- first argument omitted, procedure returns value
>>   ...
>> end if;
>
>But an out parameter and a return value are not the same, i.e. they cannot 
>generally be interchanged!
>
>Consider e.g.
>     function F return String;
>vs.
>     procedure P (S: out String);
>The former has no idea how long the object is that will get the result (if any), 
>the latter takes the length from the parameter.

Well, I was not writing an AI (perhaps, I should?), therefore I did not look
at the details. Surely, you are right - there must be a limitation for a
parameter in "return" mode: if one is of indefinite type then the currently
undefined attributes (Length, First, etc.) cannot be used for that parameter.
  Did you notice any other hole in that proposal?


Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia




^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: Problems with 'class, help anyone?
@ 2002-11-11  9:03 Grein, Christoph
  0 siblings, 0 replies; 34+ messages in thread
From: Grein, Christoph @ 2002-11-11  9:03 UTC (permalink / raw)


> There is another way, with perhaps even less incompatibility: let's introduce
> third mode for a formal parameter - "return" mode (in addition to conventional
> "in" and "out"). That "return" may be applied to the procedure's first 
parameter
> only, and it means the same as "out" mode, with single exception: if the first
> parameter of a procedure is in "return" mode then the procedure *may* be 
called
> without the corresponding (first) argument, and in such a case it returns 
value.
> For example:
> 
> procedure Two_Fold(Result : return Boolean; Something : in Integer);
> 
> X : Boolean;
> Two_Fold(X, 0);  -- "return" as "out", procedure does not return value
> 
> if Two_Fold(0) then  -- first argument omitted, procedure returns value
>   ...
> end if;

But an out parameter and a return value are not the same, i.e. they cannot 
generally be interchanged!

Consider e.g.
     function F return String;
vs.
     procedure P (S: out String);
The former has no idea how long the object is that will get the result (if any), 
the 
latter takes the length from the parameter.



^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: Problems with 'class, help anyone?
@ 2002-11-09  0:11 Alexandre E. Kopilovitch
  0 siblings, 0 replies; 34+ messages in thread
From: Alexandre E. Kopilovitch @ 2002-11-09  0:11 UTC (permalink / raw)


Robert A Duff (bobduff@shell01.TheWorld.com) wrote:
>"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
[skip]
>> just allow procedures with results:
>>
>>    procedure Foo (...) return Bar;
>
>Yeah, and then eliminate the "function Foo..." syntax.
>That would solve the problem!
>
>Slight incompatibility...  ;-)

There is another way, with perhaps even less incompatibility: let's introduce
third mode for a formal parameter - "return" mode (in addition to conventional
"in" and "out"). That "return" may be applied to the procedure's first parameter
only, and it means the same as "out" mode, with single exception: if the first
parameter of a procedure is in "return" mode then the procedure *may* be called
without the corresponding (first) argument, and in such a case it returns value.
For example:

procedure Two_Fold(Result : return Boolean; Something : in Integer);

X : Boolean;
Two_Fold(X, 0);  -- "return" as "out", procedure does not return value

if Two_Fold(0) then  -- first argument omitted, procedure returns value
  ...
end if;



Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia




^ permalink raw reply	[flat|nested] 34+ messages in thread
* Problems with 'class, help anyone?
@ 2002-10-29  4:48 
  2002-10-29  6:08 ` Jim Rogers
  0 siblings, 1 reply; 34+ messages in thread
From:  @ 2002-10-29  4:48 UTC (permalink / raw)


I'm trying to use 'class
here in a way I hope works :)
apparently it doesn't tough..

I'm using example code from:
http://www.ankh-morpork.com/Simon/adabook/x6.htm

Abit old I guess but it's supposed to be for Ada95

I've done almost exactly as this but now I get:
bash-2.03$ gnatmake  main
gcc -c main.adb
main.adb:13:24: no selector "Humanoid" for private type "Instance" defined at mob.ads:7
main.adb:15:27: no selector "Instance" for private type "Instance" defined at mob.ads:7
main.adb:23:18: type of object cannot be abstract
main.adb:28:12: expected type "Pointer" defined at line 8
main.adb:28:12: found private type "Instance" defined at mob-humanoid.ads:11
main.adb:29:12: expected type "Pointer" defined at line 8
main.adb:29:12: found private type "Instance" defined at mob.ads:7
gnatmake: "main.adb" compilation error


According to the webpage above this should work (If I understood it
correctly).

/M�rten Woxberg




^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2002-11-12 12:20 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-11 15:12 Problems with 'class, help anyone? Alexandre E. Kopilovitch
2002-11-12 12:20 ` Dmitry A. Kazakov
  -- strict thread matches above, loose matches on Subject: below --
2002-11-11  9:03 Grein, Christoph
2002-11-09  0:11 Alexandre E. Kopilovitch
2002-10-29  4:48 
2002-10-29  6:08 ` Jim Rogers
2002-10-29 19:10   ` 
2002-10-30  5:27   ` 
2002-10-30  7:49     ` Simon Wright
2002-10-30  8:13     ` Jim Rogers
2002-11-02  4:02       ` 
2002-11-05  2:40       ` 
2002-11-05  4:56         ` Jim Rogers
2002-11-05 17:25           ` Stephen Leake
2002-11-05 22:29             ` Robert A Duff
2002-11-06  8:54               ` Pascal Obry
2002-11-06 15:00                 ` Georg Bauhaus
2002-11-06 17:18                   ` Stephen Leake
2002-11-07 14:14                     ` Georg Bauhaus
2002-11-06 15:19                 ` Ted Dennison
2002-11-06 17:22                   ` Stephen Leake
2002-11-07 10:32                     ` Preben Randhol
2002-11-07 15:53                       ` Stephen Leake
2002-11-06 13:48               ` John English
2002-11-07 15:07                 ` Robert A Duff
2002-11-08  9:48                   ` Dmitry A. Kazakov
2002-11-08 13:44                     ` Robert A Duff
2002-11-08 14:27                       ` Jean-Pierre Rosen
2002-11-09 18:40                       ` Dmitry A. Kazakov
2002-11-11  9:51                         ` Lutz Donnerhacke
2002-11-11 13:24                           ` Dmitry A. Kazakov
2002-11-11 13:55                             ` Lutz Donnerhacke
2002-11-09 19:02                       ` Robert A Duff
2002-11-10 17:13                         ` Dmitry A. Kazakov

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