[fpc-pascal] Proper preprocessor?

Michael Van Canneyt michael at freepascal.org
Wed Jun 20 16:06:13 CEST 2018



On Wed, 20 Jun 2018, Ryan Joseph wrote:

>
>
>> On Jun 20, 2018, at 8:09 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>> 
>> Nothing stops people from preprocessing their code if they need really
>> advanced preprocessing: The toolchain can handle it already.
>> 
>> But there is no need to integrate it in the compiler and thus needlessly
>> complicating it even more. The consequences of such a step are far-reaching.
>> 
>> And till now, no-one has presented the really pressing use cases that would warrant such a step.
>
> How can you integrate a preprocessor without misaligning error messages
> and debugging information?  I would have already done this myself if I
> thought it was possible.  A way to hook into the compiler to run external
> programs would be very handy and let us craft our own solutions without
> adding junk into the compiler.

This will not solve your misalignment problem, and see below.

>
> I put this into the category of dogma because we’re being asked to provide
> “valid” use cases instead of trusting that we have know what’s best for
> our own code.  It’s not possible to know in advance what people may need
> so providing them good tools as a fail safe is only sensible.

Please stop calling it 'dogma'.

As with all features, it is a trade-off between the burden this places on 
the compiler (and the people maintaining it) and the expected gain.
Gain can only be estimated by giving use case(s).

Till now, the burden of preprocessing is considered simply too big for the
gain.

One consequence, for example, is that the ppu files are thrown out of the 
window. The compiler would have to compile every used unit every time again, 
since it has no idea what the user of the preprocessor can/will/wants to do.
Just as the C compiler is forced to do, by the way.

Second consequence is the generation of debug info: you need to work back to
the original source location. This places a restriction on the preprocessor,
since it somehow needs to communicate back the original source locations to the
compiler. etc.

Same is true for error locations, and so on.

Is there a workaround ? Yes, there is: you can do the preprocessing by
yourself. Lazarus is equipped for it. Use makefiles if you want.

Speed should be mentioned: all this will add another layer on top of the
compiler, which will aversely affect speed. People already complain about
speed...

So, it really is not dogma, but a simple weighing of pros and cons.

Michael.


More information about the fpc-pascal mailing list