From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Pondering what rationale behind record type
Date: Tue, 10 May 2011 14:08:33 +0200
Date: 2011-05-10T14:08:33+02:00 [thread overview]
Message-ID: <11dlfbvj00hru$.7zkw6im0a7gj$.dlg@40tude.net> (raw)
In-Reply-To: 4dc90f7a$0$7659$9b4e6d93@newsspool1.arcor-online.net
On Tue, 10 May 2011 12:12:10 +0200, Georg Bauhaus wrote:
> On 10.05.11 09:45, Dmitry A. Kazakov wrote:
>> On Tue, 10 May 2011 00:03:37 +0200, Georg Bauhaus wrote:
>>
>>> First, in the phrase "end X", the "X" part can usually be omitted.
>>
>> That is another fix to do: a default profile which would forbid omitting
>> the name. I saw no Ada program in my life which omitted names in the ends.
>>
>>> So whenever we put "record" (or "case", or "if", etc) after an "end",
>>
>> These are anonymous constructs.
>
> Though a loop can have a name.
>
> Anything wrong with (i.e. makes you shudder)
>
> Label_A: loop
> ...
> end loop Label_A;
>
> ?
loop A do
...
end A;
>> The only reason why record bracket should
>> not contain its name is when there is no name, e.g. as Randy has pointed
>> out, in an anonymous record type. They are illegal in Ada, but an imaginary
>> example could be:
>>
>> function Get_Token (File : File_Type) return
>> (Matched : Boolean; Length : Positive) record
>> ...
>
> In order to be competitive in the current discussion,
> pro "end [X]", the example would have to be
>
> type Get_Token is function (File : File_Type) return
> ((Matched : Boolean; Length : Positive) record
> case Matched is
> when True => Token : String (1..Length);
> when False => null;
> end case;
> end record)
> end Get_Token;
No, Get_Token would be a function-type. E.g.
type Func is function (X : Float) return Float;
Then
function Integrate (...; What : Func) return Float;
Which could be be anonymous as well:
function Integrate (...; What : function (X : Float) return Float)
return Float;
Or the example with Get_Token:
procedure Parse
( File : File_Type;
Get_Token : function (File : File_Type) return
((Matched : Boolean; Length : Positive) record
case Matched is
when True => Token : String (1..Length);
when False => null;
end case;
end record
);
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2011-05-10 12:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-09 17:47 Pondering what rationale behind record type Anh Vo
2011-05-09 18:59 ` Adam Beneschan
2011-05-09 19:51 ` Niklas Holsti
2011-05-09 20:02 ` Dmitry A. Kazakov
2011-05-09 20:12 ` Anh Vo
2011-05-09 22:03 ` Georg Bauhaus
2011-05-10 7:45 ` Dmitry A. Kazakov
2011-05-10 10:12 ` Georg Bauhaus
2011-05-10 12:08 ` Dmitry A. Kazakov [this message]
2011-05-10 12:18 ` Georg Bauhaus
2011-05-10 12:50 ` Dmitry A. Kazakov
2011-05-10 14:20 ` Martin
2011-05-11 7:32 ` Dmitry A. Kazakov
2011-05-11 2:28 ` Shark8
2011-05-11 7:32 ` Dmitry A. Kazakov
2011-05-18 22:55 ` Shark8
2011-05-19 8:12 ` Dmitry A. Kazakov
2011-05-09 20:49 ` Randy Brukardt
2011-05-19 9:50 ` J-P. Rosen
2011-05-20 6:10 ` anon
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox