comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Elaboration worries
Date: Thu, 22 Jun 2006 18:31:18 -0500
Date: 2006-06-22T18:31:18-05:00	[thread overview]
Message-ID: <J8udna2VIf6FtQbZnZ2dnUVZ_oCdnZ2d@megapath.net> (raw)
In-Reply-To: 4fva3aF1lff5cU1@individual.net

"Alex R. Mosteo" <devnull@mailinator.com> wrote in message
news:4fva3aF1lff5cU1@individual.net...
...
> I'm also interested in the "cheating" for I/O, since this seems really a
> weak spot. Any other cheats besides the one mentioned by Mr.Duff?

Well, I don't cheat, rather I pass in the logging routines to the
Preelaborated packages. (This will also work for Pure in Ada 2005.)

First, I declare a logging access type:

    type Logger_Access is access procedure (Message : in String);
        -- Write a line to the log (if any).

And then all of the routines that need to do logging including a Logger
parameter:
    Logger : in Logger_Access := null

If Logger is null, nothing is written. Logger_Access is defined so that the
profile matches Ada.Text_IO.Put_Line for unit debugging, and it matches the
profile of the logging routines that we usually use.

Now, you do have to pass this through all of the calls inside of
Preelaborated packages. Once you get to a normal package, you can just
provide the appropriate logger routine:
      ...
      Logger => Ada.Text_IO.Put_Line'Access);

And this provides a way to access "normal" stuff from Preelaborared
packages. Of course, it only works if the number of such things is rather
limited.

I should point out that I started using this because I had a need to use
different logging techniques in different programs that depended on the same
shared library. The fact that it let some of the libraries be Preelaborated
was a bonus.

                                Randy.







      parent reply	other threads:[~2006-06-22 23:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-21 12:33 Elaboration worries Alex R. Mosteo
2006-06-21 18:01 ` Samuel Tardieu
2006-06-21 20:34 ` Randy Brukardt
2006-06-21 23:07   ` Samuel Tardieu
2006-06-22 23:06     ` Randy Brukardt
2006-06-23 18:42       ` Samuel Tardieu
2006-06-23 19:54         ` Randy Brukardt
2006-06-21 23:12   ` Robert A Duff
2006-06-22 23:09     ` Randy Brukardt
2006-06-21 23:07 ` Robert A Duff
2006-06-22  2:24   ` Matthew Heaney
2006-06-22 10:36 ` Alex R. Mosteo
2006-06-22 16:25   ` Alex R. Mosteo
2006-06-22 23:31   ` Randy Brukardt [this message]
replies disabled

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