From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Pondering what rationale behind record type
Date: Tue, 10 May 2011 09:45:24 +0200
Date: 2011-05-10T09:45:24+02:00 [thread overview]
Message-ID: <srmjrvuvt6co.1salemwyup26.dlg@40tude.net> (raw)
In-Reply-To: 4dc864b9$0$6890$9b4e6d93@newsspool2.arcor-online.net
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. 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
case Matched is
when True => Token : String (1..Length);
when False => null;
end case;
end record;
The result is this anonymous record:
type <anonymous> (Matched : Boolean; Length : Positive) is record
case Matched is
when True => Token : String (1..Length);
when False => null;
end case;
end record;
We could continue the exercise with other types:
function Get_Handle (...) return
new Ada.Finalization.Controlled with record ... end record;
function Get_List (...) return
array (Positive range <>) of Element;
Do you like it? (:-))
> Consequently, how about this addition to the syntax of record
> declarations:
>
> type R is
> record
> ...
> end record R;
>
> ?
Shudder.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2011-05-10 7:45 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 [this message]
2011-05-10 10:12 ` Georg Bauhaus
2011-05-10 12:08 ` Dmitry A. Kazakov
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