Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top