Page 1 of 1
Some things can't be done with a 1 pass compiler
Posted: Thu Aug 04, 2016 2:37 pm
by Justin
Like this:
Code: Select all
Structure STRUCTA
a.i
List StructsB.STRUCTB()
EndStructure
Structure STRUCTB
b.i
List StrucsA.STRUCTA()
EndStructure
I know a could use pointers as a workaround but complicates things a lot. It is so hard to implement a 2 pass compiler and forget all the declares mess?
Or maybe a declarestructure STRUCTB ? but without declaring the fields i am not sure if it would make sense.
Re: Some things can't be done with a 1 pass compiler
Posted: Thu Aug 04, 2016 3:21 pm
by Lunasole
Yes, somethink like DeclareStructure should be nice to resolve such dependencies. I don't think that declaration of all fields is neccessary (but not sure for all cases too)
Also definitely 2-pass compiler would be much better as it can resolve several other problems and make whole language more powerful and flexible, but don't know how slow compilation will become then.
But generally... simple 2 passes are anyway very far from extremely slow C++ compilers doing lot of detailed analysis, for example. So should be fast enough, still much faster than C code compilation
Re: Some things can't be done with a 1 pass compiler
Posted: Thu Aug 04, 2016 4:57 pm
by Justin
With nowadays computers we would not notice absolutely anything in terms of speed, and frankly a would exchange 10 ms for not having to declare anything. I hope speed is not the reason.
Anyways 2 pass compiler has been requested maybe 10 years ago.
If no 2 pass compiler, no oop, no unsigned, probably not literal arrays, and many more things what else can we expect in the near future?
Re: Some things can't be done with a 1 pass compiler
Posted: Thu Aug 04, 2016 6:24 pm
by c4s
I already requested at least a way to declare it here:
Declare for Arrays, Lists, Variables, Structures
By the way, I think the topic title should be changed to something more meaningful.
Re: Some things can't be done with a 1 pass compiler
Posted: Thu Aug 04, 2016 7:10 pm
by STARGĂ…TE
You can merge both structures:
Code: Select all
Structure STRUCTAB
StructureUnion
a.i
b.i
EndStructureUnion
List StructsAB.STRUCTAB()
EndStructure
Re: Some things can't be done with a 1 pass compiler
Posted: Thu Aug 04, 2016 8:08 pm
by Justin
I don't think this will work with more than one struct member and is very messy.
c4s, yes i saw your post before requesting, 5 years ago

Re: Some things can't be done with a 1 pass compiler
Posted: Fri Aug 05, 2016 12:02 pm
by Dude
Justin wrote:It is so hard to implement a 2 pass compiler
Freak had this to say about it:
http://www.purebasic.fr/english/viewtop ... 16#p417016
Re: Some things can't be done with a 1 pass compiler
Posted: Sat Aug 06, 2016 5:45 am
by Mistrel
Having the compiler be single-pass is one of the reasons compilation is so mindbogglingly fast. I would not trade this for anything!
This is a limitation/feature of the language and you'll get used to it.
Also, besides being an example of something only a multi-pass compiler can do, I see no arguable value in the snippet you provided.
Re: Some things can't be done with a 1 pass compiler
Posted: Sat Aug 06, 2016 10:13 am
by User_Russian
Mistrel wrote:Having the compiler be single-pass is one of the reasons compilation is so mindbogglingly fast.
PB uses FASM which is multi-pass compiler.

Re: Some things can't be done with a 1 pass compiler
Posted: Sat Aug 06, 2016 10:29 am
by sys64802
non fixed n-pass compilers are beautiful IMO.
They can make one pass if it's enough, or two, three or more until the source dependencies are all resolved.
Basically they adapt to the code complexity to always get the job done without any excessive hand holding by the programmer.
They usually require a lot of more RAM though, but it's not real problem anymore.
Re: Some things can't be done with a 1 pass compiler
Posted: Sat Aug 06, 2016 7:30 pm
by Justin
Mistrel wrote:Having the compiler be single-pass is one of the reasons compilation is so mindbogglingly fast. I would not trade this for anything!
Probably you will spend 1000x more time declaring your stuff than waiting for a 2 pass compilation.
But seeing the last discussions and still has some fans i don' think it will bw implemented.
Re: Some things can't be done with a 1 pass compiler
Posted: Sat Aug 06, 2016 10:17 pm
by sys64802
Justin wrote:
Probably you will spend 1000x more time declaring your stuff than waiting for a 2 pass compilation.

Re: Some things can't be done with a 1 pass compiler
Posted: Tue Aug 16, 2016 4:19 pm
by Mistrel
Justin wrote:
Probably you will spend 1000x more time declaring your stuff than waiting for a 2 pass compilation.
I declare everything as I go so I never notice.
PureBasic is always incredibly refreshing compared to C++ when compiling large projects. ZOOM!