[fpc-pascal] optionally uses a unit

Xiangrong Fang xrfang at gmail.com
Mon Nov 18 13:01:45 CET 2013

2013/11/18 Mark Morgan Lloyd <markMLl.fpc-pascal at telemetry.co.uk>

> There are definitely hazards, but I think that an exists() predicate of
> some form would definitely be useful. For example, inside an {$ifdef
> persist} it would give the developers the ability to have a tailored error
> message advising the maintainer that if persists.pas didn't exist he should
> also get such-and-such a project from local svn, and set up appropriate
> symlinks.
> The major issue would be directories and search paths.

That's also what I want to achieve.  My original purpose is to reduce
dependencies by put non-critical functions into a separate aux unit while
make the main unit still workable without the aux unit.​​

As to the search path, I would suggest searching the current path (which
*this* unit resides in), plus the path defined in project options.  I also
suggest to disable path component in this proposed directive, i.e.:

{$ifexists some/relative/path/filename.pas} and
{$ifexists /some/absolute/path/filename.pas}

are BOTH NOT allowed, only {$ifexists filename.pas} is allowed.

I don't know if this conforms to fpc traditions or not.

As to the concern about existing ppu or .o file, I think it is not a
problem, because you just follow the normal rule to compare file datetime
of the .o and .pas file. I don't like to rely on make files as fpc has its
own building system.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131118/efd082b6/attachment.html>

More information about the fpc-pascal mailing list