[fpc-pascal] Merging units

Zamrony P. Juhara zamronypj at yahoo.com
Tue Oct 6 22:52:29 CEST 2020


I use a secondary unit as alias of all separate units as Marco suggests in
https://github.com/fanoframework/fano/blob/master/src/fano.pas
However I am curious if merging units like this has drawback. AFAIK smart linking works.

Sent from Yahoo Mail on Android 
 
  On Sat, Oct 3, 2020 at 3:31, Marco van de Voort via fpc-pascal<fpc-pascal at lists.freepascal.org> wrote:   
Op 2020-10-02 om 19:55 schreef Ryan Joseph via fpc-pascal:
> Something that's bothered me for a while I wanted to ask about.
>
> I have a package I want to distribute which has 2 or more units, all of which are required to use the package. Technically all the code should be in one file but because units are a nice feature of Pascal we like to keep our code separate when we develop.
>
> Usually what happens is we compromise and do either:
>
> 1) Have the user of the package add all the units to the uses clause of every file which needs it. This is annoying for the user because it bloats the uses section but for the developer our code is nicely separated into units.
>
> 2) Break the units into include files and wrap the interface/implementation blocks in ifdefs. This is nice for the user because they only have a single unit to use but now the developers of the package have to work in what are essentially header files (like in C). The RTL is of course filled with examples like this.

In some cases you can also move types and consts to a secondary unit, 
but alias them in the primary one.

Like e.g. Unixtype (what unit you say? Never heard of it? That is 
because the types are aliased into core units baseunix and unix)
_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20201006/51131d19/attachment.htm>


More information about the fpc-pascal mailing list