This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Containers.Ordered_Maps; | |
with Ada.Numerics.Discrete_Random; | |
procedure Race_Example is | |
-- custom integer type and random number generator for it | |
type Indices is range 0 .. 1024; | |
package Random is new Ada.Numerics.Discrete_Random (Result_Subtype => Indices); | |
-- map/dictionary/whatever else it gets called | |
package Map is new Ada.Containers.Ordered_Maps (Key_Type => Indices, Element_Type => Indices); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Real_Time; | |
generic | |
with procedure Handle_Collision(ObjA, ObjB : Collisions.Geometry_Object); | |
package Collisions is | |
type Geometry_Float is private; | |
type Vector2D is record | |
X, Y: Geometry_Float; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package body Inductive is | |
function Is_Succ (Item: in Nat) return Boolean | |
is | |
begin | |
if Item = 0 then | |
return True; | |
else | |
return Is_Succ (Nat'Pred (Item)); | |
end if; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ LD_LIBRARY_PATH=. ./launch_architect | |
X11 thread management initialised. | |
'MMI.APPLET.RESIZE_EVENT_RESPONSE' | |
openGL Server version: 3.3.0 NVIDIA 340.76 | |
'MMI.APPLET.KEY_PRESS_RESPONSE' | |
'MMI.APPLET.KEY_RELEASE_RESPONSE' | |
'add_new_Sprite' | |
'add_new_Sprite' | |
'MMI.APPLET.BUTTON_PRESS_RESPONSE' | |
'MMI.APPLET.BUTTON_RELEASE_RESPONSE' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(07:18:43 PM) charlie5 [~rod@ppp118-211-219-42.lns20.syd4.internode.on.net] entered the room. | |
(08:17:53 PM) sukaeto: dbotton: the use cases for generics and the use cases for interfaces are different | |
(08:19:35 PM) sukaeto: dbotton: for an example of something you can do with generics that you cannot with interfaces, consider a package that takes a some function F(X : T1) return T2 and contains a function G(X : T1_Sets.Set) return T2_Sets.Set | |
(08:19:45 PM) sukaeto: you can't do this with interfaces | |
(08:20:11 PM) sukaeto: you just can't get the compile time type guarantees | |
(08:21:48 PM) sukaeto: for a simpler example, when you have package Int_Vectors is new Ada.Containers.Vectors(Positive, Integer); | |
(08:21:56 PM) sukaeto: and Vec : Int_Vectors.Vector | |
(08:22:13 PM) sukaeto: you know that all the elements of Vec are Integer | |
(08:22:33 PM) sukaeto: you don't get that guarantee with an interface | |
(08:22:45 PM) sukaeto: you can have a Vector of Interface T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Text_IO; | |
procedure Ex is | |
package TIO renames Ada.Text_IO; | |
type X is array (Positive range <>) of Boolean; | |
type X_Acc is access X; | |
W: X_Acc := new X'(False, True); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(09:02:10 AM) Allegra: books: Adapower has a nice list of on-line Ada books, at http://ada.cx/HFg | |
(09:02:11 AM) Allegra: or: The Big Online Book of Linux Ada Programming is available at http://ada.cx/RFe | |
(09:02:11 AM) Allegra: or: The University of Brighton in the UK has both John English's AdaCraft (http://ada.cx/sv6) and Mike Smith's "OOP in Ada95" (http://ada.cx/FVy), though the Smith book seems to be offline a lot. | |
(09:02:12 AM) Allegra: or: A commercial book highly recommended for those who already know another programming language is Norman H. Cohen's "Ada as a Second Language", ISBN 0-07-011607-5 | |
(09:02:13 AM) Allegra: or: See a list at http://adacommons.org/Free_Books | |
(09:02:13 AM) Allegra: or: AdaIC has learning materials available at http://ada.cx/mdr | |
(09:02:14 AM) Allegra: or: M. Ben Ari's "Ada for Software Engineers" (http://ada.cx/S4c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Text_IO; | |
procedure Exceptions_Example is | |
package TIO renames Ada.Text_IO; | |
-- Own exception. | |
Fake_Error: exception; | |
FD: TIO.File_Type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with Ada.Text_IO; | |
procedure Test is | |
type S is array (Integer range <>) of Integer; | |
function "&" (Left, Right: in S) return S | |
is | |
X: S (1 .. Left'Length + Right'Length); | |
begin | |
for K in 1 .. Left'Length loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This from Lazyfoo: | |
GLuint targetColor; | |
GLubyte* colors = (GLubyte*)&targetColor; | |
colors[ 0 ] = 000; | |
colors[ 1 ] = 255; | |
colors[ 2 ] = 255; | |
colors[ 3 ] = 255; | |
Traslates in Ada to: | |
Target_Colour: constant GL.UInt := 16#FF_FF_FF_00# |
NewerOlder