Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ada Function vs Procedure [closed]

Tags:

ada

gnat

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

like image 875
PeakGen Avatar asked Apr 05 '13 14:04

PeakGen


People also ask

What is an Ada function?

The function of the adenosine deaminase enzyme is to eliminate a molecule called deoxyadenosine, which is generated when DNA is broken down. Adenosine deaminase converts deoxyadenosine, which is toxic to lymphocytes, to another molecule called deoxyinosine, which is not harmful.

Is Ada procedural?

The ADA does not specify procedural safeguards related to special education; it does detail the administrative requirements complaint procedures, and consequences for noncompliance related to both services and employment.

What is the difference between procedures and functions?

A procedure performs a task, whereas a function produces information. Functions differ from procedures in that functions return values, unlike procedures which do not. However, parameters can be passed to both procedures and functions. In a program for drawing shapes, the program could ask the user what shape to draw.

Why do we use => in Ada?

=> has multiple purposes: Parameter passing: Which formal parameter is passed which argument (if it isn't done by order). Record and array aggregates: Which field gets which value. Aspects: Separating aspect names from the expressions they are assigned.


1 Answers

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.

like image 137
Archie Avatar answered Oct 05 '22 23:10

Archie