2-pass compiling support

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

2-pass compiling support

Post by breeze4me »

If it will be supported, following features will be possible.

1. no need to use "Declare".
2. "Global" command placed in any part of code.

Code: Select all

;;;;Declare b()
Procedure a()
  b()                ;<--without Declare b(), currently error here.
EndProcedure

Procedure b()

EndProcedure

a()

Code: Select all

Procedure a()
  z=30
EndProcedure

Global z.l=100
a()
Debug z  ;100 (if 2-pass supported, will be 30)
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Personnaly, i don't like this way of coding ...
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post by nco2k »

KarLKoX wrote:Personnaly, i don't like this way of coding ...
me neither.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

in a big project a 2 pass compiler is a must. you can get easily lost placing includes, interfaces, declares, structures.. at the right place
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post by Jan Vooijs »

Justin wrote:in a big project a 2 pass compiler is a must. you can get easily lost placing includes, interfaces, declares, structures.. at the right place
I dissagree on that one very strongly. I have a 16000 lines program i'am developing at this moment use PB in single pass. The ONLY use for a 'double pass' if to resolve 'forgotten' or wrong declares or includes by the programmer!

But than again I would LIKE to have the option of double pass so I could do without the Declares in the beginning of the program, for the procs that is its ONLY use for it. Sometimes i change a name of a parameter and have to go to two places to correct (yes I know about copy/paste).

Jan V.
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

I agree about the declare issue - it's counter-productive to have to declare because the procedure order is 'wrong'. Is there some other need for declare, apart from making the code perhaps nicer to read?

If the second option were done, maybe it would be better to make procedure variable protected by default (to avoid confusion)?
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Post by aaron »

mskuma wrote:Is there some other need for declare, apart from making the code perhaps nicer to read?
That is enough of a reason to leave it as a single pass compiler in my opinion. :)

Seriously though, it would be a major change for Fred to convert from a single pass to multipass compiler. For that reason alone, this is extremely unlikely to happen.

A more likely approach would be to have an attachment to the IDE that runs a first pass through the code, extracts all the procedure names and re-writes them as declares, and then either jams them into the top of the source code or into a second include file.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post by nco2k »

aaron wrote:A more likely approach would be to have an attachment to the IDE that runs a first pass through the code, extracts all the procedure names and re-writes them as declares, and then either jams them into the top of the source code or into a second include file.
jup.

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

aaron wrote:... an attachment to the IDE that runs a first pass through the code, extracts all the procedure names and re-writes them as declares, and then either jams them into the top of the source code or into a second include file.
But than all structures have to be extracted and put before all declares, because there could be structure pointers as procedure argumnts! And the structures also have to be in the right order!

cu, helpy
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

helpy wrote:
aaron wrote:... an attachment to the IDE that runs a first pass through the code, extracts all the procedure names and re-writes them as declares, and then either jams them into the top of the source code or into a second include file.
But than all structures have to be extracted and put before all declares, because there could be structure pointers as procedure argumnts! And the structures also have to be in the right order!

cu, helpy
And all prototypes has to be extracted and put before the structures who contain them.

Edit: And the macros...
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Well, I'd be happy to wait a bit longer for a compile if it meant not having to worry about what order everything comes in. Sheesh, compiles of code even thousands of lines in size is happening in less than a second here. I remember compiling 500 lines of Clipper code on a 20 mhz AT and going out for a smoke waiting for it to finish!
BERESHEIT
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

I remember this being requested before and was turned down because the speed of the compiler compiling was a higher priority.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Nowadays single pass compilation/compilers has/have "status" for some reason.

But the reason 1 pass compilation was considered important originally was because in the old days things like card-hoppers made 2 passes difficult. Had we had a different way to input, multiple pass would have been used.

In fact with paper (ticker) tape readers, some compilers could read in the source and build tables, etc, then re-read the paper tape backwards to do pass 2 and resolve the unresolved. This was considered waaaaay cool and elite and had "status". :)
Dare2 cut down to size
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

netmaestro wrote:Well, I'd be happy to wait a bit longer for a compile if it meant not having to worry about what order everything comes in.
Agreed.

If speed was the original reason for one-pass, with most reasonable speed machines available these days, it's not really valid these days (apologies to those running on older/slower machines for budget reasons). There's no valid reason for declares.. be nice to get rid of them.. the earlier suggestion of the IDE plugin is ok, but it's still inserting (unnecessary) code.
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post by Jan Vooijs »

netmaestro wrote:Well, I'd be happy to wait a bit longer for a compile if it meant not having to worry about what order everything comes in. Sheesh, compiles of code even thousands of lines in size is happening in less than a second here. I remember compiling 500 lines of Clipper code on a 20 mhz AT and going out for a smoke waiting for it to finish!
I remember exactly the same, those where the "good old days!!" wauw that is some 15 years back in time!!! Since i last used Clipper (5.02) in a commercial app......

Eeks 5000+ lines took 17 mins to compile!! On a 100Mhz machine a Wang to be precise who remembers Wang??

(I still mis Clipper........... sigh) :cry:

Jan V.
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
Post Reply