[fpc-pascal]Interface-only units (was: shared libraries interface)

Nikolai Zhubr s001 at hotbox.ru
Fri Aug 2 14:59:22 CEST 2002


Hi
Friday, 02 August, 2002, 14:41:38, Michael Van Canneyt wrote:

> I don't see the use of such a construct:
> A. If the internal naming conventions of the compiler change,
>    chances are that the object file is useless anyway.
> B. If the internal alignment rules for constants, sets, records and
>    I don't know what change, then you're stuck as well.
> Since with a new compiler version, you are not guaranteed that these
> things have not changed, this rather defeats the purpose of the unit as
> you will be forced to redistribute anyway.
> So I see no real use for a 'interface-only' unit.

Ok. First, traditional "wrapper" units like your example get
not that good-looking if there are 1000 or more externals
to declare, and in case that full pascal source is available,
<U> which i'm only talking about </U>, it is just kind of source
code duplication, it looks not elegant, it is an additional
source of typos and bugs, and it does not seem to really provide
*something* that would be essentially missing from the project
otherwise (In the case of *pure* pascal project with full source
available)

But actually I was thinking about some different point when
I asked. That is, about how to put some classes implementation
into a library (preferrably shared one). The example below won't
help much here :(.

BTW, now I've got an impression that VP's approach is only
good for hiding sources. Well, it wasn't designed for anything
else.
-- 
Best regards,
 Nikolai Zhubr

> What is more, you can easily make o an 'interface-only unit' now. The
> easy way is to have all functions in a separate object file and create
> a unit that just contains the needed definitions.
> This is already possible as follows:

> -----------------------------------------------------------------------
> unit something;

> interface

> {$l realsomething.o} // Contains actual implementation.

> Procedure Dosomething; External name 'DoSomething';

> Implementation

> end.
> -----------------------------------------------------------------------

> The object file can be created compiling the following:

> -----------------------------------------------------------------------
> unit realsomething;

> interface

> Procedure Dosomething; [alias: 'DoSomething'];

> Implementation

> Procedure DoSomething;

> begin
>   DoSomething
> end;

> end.
> -----------------------------------------------------------------------

> The something.pp unit can be distributed, together with the
> realsomething.o file. No compiler support needed.

> But this will still suffer from the same problem (B) as the
> 'interface-only' unit.

> Michael.


> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal






More information about the fpc-pascal mailing list