Very basic question, but just reading through source code and trying to tell what the '
is for and how it differs from .
Asked
Active
Viewed 2,326 times
8

Keith Thompson
- 254,901
- 44
- 429
- 631

J Cooper
- 16,891
- 12
- 65
- 110
1 Answers
12
The '
character is used to introduce an attribute.
For example, Integer'Last
is the largest value of type Integer
, and Float'Digits
is the decimal precision of type Float
.
The complete list of language-defined attributes is in Annex K of the Ada Reference Manual.
It's also part of the syntax of qualified expressions, such as Some_Type'(expression)
.
The .
character is used, among other things, to introduce a record component name, such as Obj.Comp
, where Obj
is a record variable and Comp
is a component of that record.
Attributes are defined by the language or by the implementation; component names are defined when the record type is defined.
The apostrophe is also used to delimit character literals: 'x'
.

Keith Thompson
- 254,901
- 44
- 429
- 631
-
I see, thank you. You say it's language/implementation defined--I can't make my own attributes? – J Cooper Aug 25 '12 at 17:32
-
@JCooper: I haven't used Ada in a while. Last time I looked, there was no way to define your own attributes. – Keith Thompson Aug 25 '12 at 18:48
-
3No way t define your own attributes - you can overwrite only 'Write, 'Read, 'Input, 'Output (used for Ada.Streams.Stream_IO). – darkestkhan Aug 25 '12 at 19:58
-
@darkestkhan - One fine day they will allow overriding of `'image` as well. – T.E.D. Aug 27 '12 at 18:20
-
@T.E.D. That would be nice but how do you imagine 'Image of access type? – darkestkhan Sep 02 '12 at 09:52
-
1And the tick is used for Qualified expressions: Some_Type'(expression), Some_Type'Aggregate – Tod Mar 12 '15 at 01:29
-
@darkestkhan: `'Image` of an access type could be defined to be an implementation-defined string, so that `'Image` and `'Value` are inverses. It might also make sense to specify a specific string for a null access value, probably `"null"`. – Keith Thompson Mar 12 '15 at 01:35