Introduction to Ada and Java

These are lecture notes from my Computer Science course. For learning about real-time systems, I recommend Real-Time Systems and Programming Languages.

Most of this was just a recap on ADS.

OOP in Ada

We wont use OOP in Ada too much. Thankfully. It’s based on type extensions and dynamic polymorphism. So you can do something like:

type EA is tagged record ... end record; -- tagged type

procedure Op1(E : EA; Other_Param : Param);
	-- primitive operation
procedure Op2(E : EA; Other_Param : Param);
	--- primitive operation

type EEA is new EA with record ... end record; -- inherit OP1
procedure Op2(E : EEA; Other_Param : Param);
	-- override Op2
procedure Op3(E : EEA; Other_Param : Param);
	-- add new primitive operation
type EEEA is new EEA ...
type EAE is new EA ...
type EAEE is new EAE ...

procedure Generic_Call(X : EA’Class) is
	X.OP1(Param);-- Ada 2005
end Generic_Call;

Standard example of ‘coordinates’ in slides.

This entry was posted in lecture, rts. Bookmark the permalink.