Ada Function vs Procedure

PeakGen picture PeakGen · Apr 5, 2013 · Viewed 8.2k times · Source

Can anyone explain me the difference between the Ada "procedure" and "function"?

Answer

Archie picture Archie · Apr 5, 2013

Ada language is not very much different comparing to other imperative C-like languages. The syntax though may look very strange and overwhelmed with different statements, but this is mainly because of a very rich static typing system and features directly provided by language (like tasks for example), that other languages provide as side libraries.

Unlike most of C-like languages, Ada distinguishes procedural and functional routines. In this sense function is very much as mathematical function that takes arguments (or none) and returns a value, and thus is used in expressions. Procedures do not return any values and cannot be used in expressions. Pascal language keeps the same distinction between functions and procedures. C-like languages chose to have just functions that can be used outside expressions (returned value is ignored in this case) or return a void value to act like a procedure.