Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the tick or apostrophe character for in Ada?

Very basic question, but just reading through source code and trying to tell what the ' is for and how it differs from .

like image 720
J Cooper Avatar asked Aug 25 '12 06:08

J Cooper


1 Answers

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'.

like image 112
Keith Thompson Avatar answered Sep 18 '22 10:09

Keith Thompson