comp.lang.ada
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
Subject: How to include shared code
Date: Thu, 19 Sep 2013 02:17:52 +0200
Date: 2013-09-19T02:17:52+02:00	[thread overview]
Message-ID: <87zjr9u0ja.fsf@nl106-137-194.student.uu.se> (raw)

If I have two files:

protected_buffer.adb
bounded_buffer.adb

and those compile and run fine.

But, in both those, I have this piece of code:

function Random_Integer return integer is
   type Span is range 1..9;
   package Random_Integer is new Ada.Numerics.Discrete_Random(Span);
   Seed    : Random_Integer.Generator;
   Outcome : Span;
begin
   Random_Integer.Reset(seed);
   Outcome := Random_Integer.Random(seed);
   return INTEGER(Outcome);
end Random_Integer;

function Random_Period return Time_Span is
begin
   return Milliseconds(Random_Integer*100);
end Random_Period;

Now, how can I extract that piece of code from both files, and put
it into another file, say, random_period.adb, and then "include"
it into each of the above files (that operate in isolation)?

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573

             reply	other threads:[~2013-09-19  0:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-19  0:17 Emanuel Berg [this message]
2013-09-19  5:31 ` How to include shared code Peter Brooks
2013-09-19  6:24   ` Simon Wright
2013-09-19  7:20 ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox