Lazarus

Free Pascal => FPC development => Topic started by: ad1mt on July 11, 2020, 08:02:49 pm

Title: two-pass compile option
Post by: ad1mt on July 11, 2020, 08:02:49 pm
Hi,
I love Pascal and have been using it for decades, but... one of the biggest faults is the 1-pass compiler.
I get really annoyed at having to move the definition of procedures & functions round in a program, when I would prefer to have related procedures/functions near each other.
Please can you implement a 2-pass compile option? I don't think it would have a big impact on the language.
Thanks, Mark.
Title: Re: two-pass compile option
Post by: Awkward on July 11, 2020, 08:07:39 pm
if you want fixed function placement in file, why you don't want to use "forward" declaration?
Title: Re: two-pass compile option
Post by: howardpc on July 11, 2020, 08:12:08 pm
Please can you implement a 2-pass compile option? I don't think it would have a big impact on the language.
It would have little effect on the language syntax. But it would have a major impact on the speed of compilation.
If you want slow compiles, you should switch to C++. :)
Title: Re: two-pass compile option
Post by: Blaazen on July 11, 2020, 09:25:10 pm
And also please replace begin/end with { }.   :)
Title: Re: two-pass compile option
Post by: Leledumbo on July 11, 2020, 10:18:01 pm
Hi,
I love Pascal and have been using it for decades, but... one of the biggest faults is the 1-pass compiler.
I get really annoyed at having to move the definition of procedures & functions round in a program, when I would prefer to have related procedures/functions near each other.
Please can you implement a 2-pass compile option? I don't think it would have a big impact on the language.
Thanks, Mark.
Actually, FPC is a 3-pass compiler. But no, forward declaration isn't one that can be in pass 2 or 3. We don't sacrifice compilation speed for a little convenience while everything in pass 2 and 3 give substantial benefit (i.e. optimizations) or cannot be done otherwise.
Title: Re: two-pass compile option
Post by: winni on July 12, 2020, 12:56:24 am
Hi!

Forget about the "Holy Grail".

Search for interviews with Anders Hejlsberg what kind of dirty tricks they used to speed up Turbo Pascal.

Reality is not a virgin.

Winni
Title: Re: two-pass compile option
Post by: PascalDragon on July 12, 2020, 12:22:14 pm
I love Pascal and have been using it for decades, but... one of the biggest faults is the 1-pass compiler.
I get really annoyed at having to move the definition of procedures & functions round in a program, when I would prefer to have related procedures/functions near each other.
Please can you implement a 2-pass compile option? I don't think it would have a big impact on the language.

The whole parser is geared towards the single pass approach. Implementing a 2-pass approach would be a huge undertaking, one in which we have no interest in. Not to mention that there are legal mechanisms that you can use:

If you use units and have your functions declared in the interface-section the order won't matter in the implementation-section (except if you want inlining between them, then they need to be ordered correctly). Not to mention the use of forward for implementation only functions (which is also the case for the main program).
TinyPortal © 2005-2018