From: anon@att.net
Subject: Re: Why constant components are not permitted ?
Date: Sat, 26 Nov 2011 00:23:28 +0000 (UTC)
Date: 2011-11-26T00:23:28+00:00 [thread overview]
Message-ID: <japbhv$o1o$1@speranza.aioe.org> (raw)
In-Reply-To: 9ja2aiFla6U1@mid.individual.net
--
-- To use constant with "record" define record then create an object
-- with preset value that contains the key word "constant"
--
procedure a is
type test_type is record
a : integer ;
b : string ( 1 .. 4 ) := "this" ; -- default
c : string ( 1 .. 10 ) ;
end record ;
-- tst is a constant record with all values are unchangable
tst : constant test_type := test_type ' ( 16#FFFF# ,
"that",
"0123456789" ) ;
begin
null ;
end ;
In <9ja2aiFla6U1@mid.individual.net>, Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
>On 11-11-25 11:06 , AdaMagica wrote:
>> Useful applications for constant components could be (this is what you
>> can have in C++):
>>
>> record -- *not* Ada
>> Name: constant String := "James Bond";
>> Id : constant Positive := 007; -- e.g employee number of a company
>> other variable components
>> end record;
>
>The original poster specified the constant value in the declaration of
>the record *type*, not separately for each record *object*. This is what
>I do not understand: what is the use of a value that is the same for all
>objects in which it can appear?
>
>The "type constants" that Ada now provides are the attributes of a type
>(tag, size, and so on), as Ludovic pointed out.
>
>I understand that some would like to have a "write once" kind of record
>component that can be given a value once, when a record object is
>created, and cannot be changed afterwards. Discriminants are like that
>in Ada, but cannot be of arbitrary type.
>
>--
>Niklas Holsti
>Tidorum Ltd
>niklas holsti tidorum fi
> . @ .
next prev parent reply other threads:[~2011-11-26 0:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-24 18:14 Why constant components are not permitted ? David Sauvage
2011-11-24 19:06 ` anon
2011-11-24 19:49 ` David Sauvage
2011-11-24 22:55 ` Georg Bauhaus
2011-11-24 23:53 ` anon
2011-11-24 19:46 ` Ludovic Brenta
2011-11-25 9:10 ` Dmitry A. Kazakov
2011-11-25 10:23 ` Ludovic Brenta
2011-11-25 10:45 ` Dmitry A. Kazakov
2011-11-25 6:56 ` Niklas Holsti
2011-11-25 9:53 ` Yannick Duchêne (Hibou57)
2011-11-25 10:06 ` AdaMagica
2011-11-25 10:16 ` AdaMagica
2011-11-25 10:56 ` Yannick Duchêne (Hibou57)
2011-11-25 17:41 ` Niklas Holsti
2011-11-26 0:23 ` anon [this message]
2011-11-29 4:10 ` Randy Brukardt
2011-11-29 7:55 ` David Sauvage
2011-11-29 10:55 ` Yannick Duchêne (Hibou57)
2011-11-29 11:17 ` Mark Lorenzen
2011-11-26 10:22 ` Pascal Obry
2011-11-26 10:59 ` Dmitry A. Kazakov
2011-11-25 7:03 ` AdaMagica
2011-11-25 9:12 ` Dmitry A. Kazakov
2011-11-25 9:57 ` Yannick Duchêne (Hibou57)
2011-11-25 10:22 ` Dmitry A. Kazakov
2011-11-25 11:00 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox