comp.lang.ada
 help / color / mirror / Atom feed
From: joakimds@kth.se
Subject: Re: Ada interacting with Windows 8.1+ GUI
Date: Thu, 25 Oct 2018 15:30:44 -0700 (PDT)
Date: 2018-10-25T15:30:44-07:00	[thread overview]
Message-ID: <61c2515d-29fd-4b96-8138-88d7f5419fb5@googlegroups.com> (raw)
In-Reply-To: <5b897611-5e95-4bc8-b5b9-a8df97299cd6@googlegroups.com>

> Note: Anyhow, I plan on isolating only the type definitions needed to handle the window stuff and drop the rest. For me, to bring the whole win32 interface is overkill.

Isn't it easy for the compiler to optimize away/remove the code that is not used? Also I can imagine that the packages of the win32 interface is code that has been written and as a developer one only uses it which means it is only compiled once and no re-compilation needed.

When writing an Ada binding to a C library, consider the following two options:
1. Put all the source code in a package A.
2. Divide the source code into several packages, for example create an empty package A and divide the source code into several child packages A.B, A.C, A.D, ...

Let's imagine there is a type called Window. In solution 1 one writes "A.Window" to specify it and in solution 2 one maybe writes "A.D.Window".
Solution 1 makes the code less verbose and puts more responsibility on the compiler to be able to remove unused code. Solution 2 makes the source code more verbose but makes it easier for an Ada compiler to avoid including unused source code in the resulting executable. When I have been thinking about this I've thought "let's assume the compiler is really good and let's go for minimalistic Ada code". Solution 2 is sometimes advertised as one of the selling points of Ada to be able to describe structure of an Ada binding. Currently I am exploring solution 1 when writing Ada code, but "the ultimate way to structure code" is still an open question for me.

Best regards,
Joakim


  reply	other threads:[~2018-10-25 22:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 14:42 Ada interacting with Windows 8.1+ GUI Donar
2018-10-09 14:56 ` gautier_niouzes
2018-10-10 15:42   ` herbert.glarner
2018-10-10 18:19     ` G. B.
2018-10-25  9:24       ` gautier_niouzes
2018-10-11 14:42     ` gautier_niouzes
2018-10-11 15:26       ` rabbibotton
2018-10-11 18:25         ` rabbibotton
2018-10-11 18:37       ` Björn Lundin
2018-10-13  6:30       ` alby.gamper
2018-10-13 11:50         ` gautier_niouzes
2018-10-13 12:47           ` alby.gamper
2018-10-25 17:19 ` Olivier Henley
2018-10-25 17:33   ` Olivier Henley
2018-10-25 22:30     ` joakimds [this message]
2018-10-26  9:19       ` Simon Wright
2018-10-26  9:39         ` gautier_niouzes
2018-10-26 12:52         ` Bill Findlay
2018-10-26 13:42           ` Simon Wright
2018-10-26 21:19             ` Bill Findlay
2018-10-29 21:09         ` Randy Brukardt
replies disabled

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