에이다

위키백과, 우리 모두의 백과사전.
이동: 둘러보기, 찾기

에이다(Ada)는 구조화되고, 통계학적 형태를 가지고, 명령적이며, 객체 지향적인 고급 수준의 컴퓨터 프로그래밍 언어이다. 처음에는 1977년에서 1983년까지 수백 개의 프로그래밍 언어를 대신할 목적으로 CII 허니웰 벌의 진 이히비아가 주도한 팀에서 고안된 것이다. 에이다는 CC++의 몇 가지 작업이 같지만, 에이다는 매우 강력한 유형 시스템의 언어이다.

에이다는 컴퓨터 프로그래밍을 발명하는 데 공헌한 에이다 러브레이스 (1815년-1852년)의 이름을 딴 것이다.

목차

[편집]

헬로 월드 [편집]

언어의 구문의 일상적인 예로 들 수 있는 헬로 월드 프로그램:

with Ada.Text_IO; 
 
procedure Hello is
begin
  Ada.Text_IO.Put_Line("Hello, world!");
end Hello;

자료형 [편집]

type Day is range 1 .. 31;
type Month is range 1 .. 12;
type Year is range 1800 .. 2100;
 
type Date is
   record
     Day   : Day;
     Month : Month;
     Year  : Year;
   end record;

제어 구조 [편집]

while a /= b loop
  Ada.Text_IO.Put_Line ("Waiting");
end loop;
 
if a > b then
  Ada.Text_IO.Put_Line ("Condition met");
else
  Ada.Text_IO.Put_Line ("Condition not met");
end if;
 
for i in 1 .. 10 loop
  Ada.Text_IO.Put ("Iteration: ");
  Ada.Text_IO.Put (i);
  Ada.Text_IO.Put_Line;
end loop;
 
loop
  a := a + 1
  exit when a = 10;
end loop;
 
case i is
  when 0 => Ada.Text_IO.Put("zero");
  when 1 => Ada.Text_IO.Put("one");
  when 2 => Ada.Text_IO.Put("two");
end case;

패키지, 프로시저, 함수 [편집]

with Ada.Text_IO; 
 
package Mine is
 
  type Integer is range 1 .. 11;
 
  i : Integer := Integer'First;
 
  procedure Print (j: in out Integer) is
 
    function Next (k: in Integer) return Integer is
    begin
      return k + 1;
    end Next;
 
  begin
    Ada.Text_IO.Put_Line ('The total is: ', j);
    j := Next (j);
  end Print;
 
begin
  while i < Integer'Last loop
    Print (i);
  end loop;
end Mine;

바깥 고리 [편집]