Recent

Author Topic: two-pass compile option  (Read 471 times)

ad1mt

  • Newbie
  • Posts: 1
two-pass compile option
« 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.

Awkward

  • Jr. Member
  • **
  • Posts: 65
Re: two-pass compile option
« Reply #1 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?

howardpc

  • Hero Member
  • *****
  • Posts: 3487
Re: two-pass compile option
« Reply #2 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++. :)

Blaazen

  • Hero Member
  • *****
  • Posts: 2846
  • POKE 54296,15
    • Eye-Candy Controls
Re: two-pass compile option
« Reply #3 on: July 11, 2020, 09:25:10 pm »
And also please replace begin/end with { }.   :)
Lazarus 2.1.0 r63594 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Leledumbo

  • Hero Member
  • *****
  • Posts: 8244
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: two-pass compile option
« Reply #4 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.

winni

  • Hero Member
  • *****
  • Posts: 1604
Re: two-pass compile option
« Reply #5 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

PascalDragon

  • Hero Member
  • *****
  • Posts: 1941
  • Compiler Developer
Re: two-pass compile option
« Reply #6 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