国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

從零開始學習Ada(入門)

2019-11-08 19:44:33
字體:
來源:轉載
供稿:網友

What is Ada?

Ada 語言最初設計是為了構建長周期的、高度可靠的軟件系統。它提供了一系列功能來定義相關的數 據類型(type)、對象(object)和操作(Operation)的程序包(package)。程序包可以被參數化,數據類型可以被擴 展以支持可重用庫的構建。操作既可以使用方便的順序控制結構,通過子程序(subPRogram)來實現,也可以 通過包含并發線程同步控制的入口(entry)來實現。Ada 也支持單獨編譯(separate compilation),在物理層上 支持模塊性。

Ada 包含了很復雜的功能以支持實時(real-time),并發程序設計(concurrentprogramming)。錯誤可以作為 異常(exception)來標示,并可以被明確地處理。Ada 也覆蓋了系統編程(system programming);這需要對數 據表示和系統特性訪問的精確控制。最后,提供了預定義的標準程序包,包括輸入輸出、字符串處理、數值計算的基本函數和隨機數生成。

What is available for Ada?

There are many Ada compilers, including a free Ada 95 compiler called GNAT based on the Free Software Foundation’s gcc. There are also many Ada-related tools and on-line reference documents. A later section of this tutorial provides more information about on-line Ada information sources.

如何安裝GNAT在下面的帖子里有詳細說明。不得不說,上述這篇寫的非常詳細,對小弟非常有幫助。 在WINDOWS系統上安裝GNAT GPL 2015 ADA開發環境

當然GPS作為集成開發環境,也支持很多語言,按需要選擇目標語言。

但是我個人在運行Helloworld.exe的時候,cmd顯示了:

C:/>Gnatwork/helloworld>helloworld.exeaccess is denied.

也是頗感郁悶。

Ada HelloWold

-- Ada 2017 Hello, world.with Ada.Text_Io;use Ada.Text_Io;procedure Helloworld isbegin Put_Line("Hello, World!");end Helloworld;Ada的標注是 “–”,和C++ 的// 一樣with clause, which specifies the library units (other items) that we need. This particular with clause specifies that we need Ada.Text_IO. The library unit Ada.Text_IO is a predefined library unit that provides operations to perform basic text input and output.Defining a new procedure named Hello. 相比起(in C and C++, it must be called main, and in Pascal, it must be specially identified as the program),Ada只是一個簡單的procedure。begin 和 end 都一樣使用Put_Line有分號semicolon,和C,C++相似

Ada Compute

with Ada.Text_IO, Ada.Integer_Text_IO;use Ada.Text_IO, Ada.Integer_Text_IO;procedure Compute is procedure Double(Item : in out Integer) is begin -- procedure Double. Item := Item * 2; end Double; X : Integer := 1; -- Local variable X of type Integer.begin -- procedure Compute loop Put(X); New_Line; Double(X); end loop;end Compute;

1. 制作了X local variable,Integer用于想儲存某signed integers。這里不會在意 integers 的minimum and maximum range 2. Double函數把取值乘了2 3. Put 把數值顯示出來,New_Line使數值內容走向下一頁 4. When a computation (such as doubling) cannot be performed, Ada raises an `exception’.

現在我們對 Ada 程序長的什么樣已有了基本的認識,下面需要了解幾個術語。一個 Ada 程序是由 一個或多個程序單元組成(programunit)。

一個程序單元可以為: 1. 子程序(subprogram),定義一些可執行運算。過程(procedure)和函數(function)都是子程序。 2. 程序包(package),定義一些實體(entity)。程序包是 Ada 中的主要分組機制,類似于 C 的函數 庫,Modula 的”module”。 3. 任務單元(taskunit),與線程類似,定義一些計算,然后并發執行。 4. 保護單元(protectedunit),在并發計算中協調數據共享,這在 Ada83 中不存在。 5. 類屬單元(genericunit),幫助構建可重用組建,和 C++ 的模板類似。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南宫市| 威海市| 双牌县| 黄龙县| 娱乐| 邢台市| 道真| 清河县| 雅安市| 呼图壁县| 陵水| 靖边县| 巴林左旗| 陆河县| 河源市| 萨迦县| 碌曲县| 钟山县| 西平县| 贡山| 房山区| 鞍山市| 米脂县| 德州市| 万州区| 黑龙江省| 新建县| 高淳县| 班戈县| 定南县| 万年县| 垣曲县| 香河县| 安阳市| 安乡县| 东乡县| 南澳县| 新丰县| 和顺县| 武鸣县| 邢台县|