2

In all Ada source code i know, including the standard library (sorry, i don't know where find it on the web) or the Small game implementation, all non-reserved words starts with uppercase letter. (Last, Stack, Index,…)
And because all reserved keywords are highlighted by editor, i guess/hope its not for discriminate user-defined identificators.

In Python, C++ or Java, upper case is generally used for some things (classes identificators & constants, generally), for allow them to be quickly identified by human readers. (case give information about signification)

Why "official" Ada code is doing this differently ? Why not use uppercase ffor things like types, modules ?

Is it because information through letter case is considered as a bad thing ?
If so, why ?

2
  • 1
    Good question. I guess the Ada community could have adopted a convention that type names begin with upper-case letters and variable names with lower-case, or something like that. Unlike others, I don't think it would have impaired readability too much, as long as underscores were still used between words. But it wouldn't have gained as much, at least before Ada 2005. In Java/C#, the convention is really helpful to distinguish ClassName.staticMethod from objectName.instanceMethod. Ada didn't have the latter syntax until Ada 2005, by which time the case convention was well established.
    – ajb
    Commented Mar 12, 2015 at 5:24
  • By the way, before Ada 95, the Ada convention was to use all upper-case for identifiers and lower-case for keywords only. Also: In Java, C#, and C++, upper case is not "reserved" for anything--the compiler accepts anything as long as it's not a keyword. The rules about letter case are just conventions, although they're pretty universally accepted in Java and C#. In C++, I don't think practice is as consistent.
    – ajb
    Commented Mar 12, 2015 at 5:27

3 Answers 3

6

The Standard Library is in Annex A of the ARM, which is at AdaIC.org.

Ada is case insensitive, so some uses of capitalization in case-sensitive languages are simply impossible.

The use of initial caps, as well as underlines to separate parts of identifiers (Some_Useful_Name), was chosen because it enhances readability. Ada has an explicit design goal of emphasizing ease of reading over ease of writing.

2
  • I just discovered the case insensitivity of Ada… According to @ajb, initial caps convention seems to be less used since Ada 95.
    – aluriak
    Commented Mar 12, 2015 at 6:57
  • @ajb didn’t say that. Title case for identifiers began (officially) with Ada 95. And the standard library does follow the new case conventions (except in Interfaces.C!) Commented Mar 12, 2015 at 7:59
2

Almost everything has been told but I just wanted to give you two links :

  1. Even if there's nothing mandatory, the Ada Quality and Style Guide can provide you explanations about the usual Ada coding style
  2. If you're using Gnat, you can also check the options to check the coding style (see gcc options)

But coding style is only convention and even for Java, Sun conventions are different from Google or Eclipse ones. It's up to you (or to your company) to define what is the best for you.

1
  • Sure, but i just began to learn Ada, and use standard conventions is the best way to understand why, later, i will need to switch to another style convention. I think a language, even if case sensitive, need to have rigorous code conventions for give to most of developpers a style guide.
    – aluriak
    Commented Mar 12, 2015 at 14:00
1

Another piece for the puzzle:

In the design of Ada, there has been some emphasis on substitutability of implementations. Arrays may be substituted with functions, plain records with tagged records, etc.

That would not really work as nicely if naming conventions for objects and subprograms were too different. Of if one named non-tagged types differently from tagged types. (For some reason the Object.Primitive_Operation notation does not include non-tagged types.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.