Some things can't be done with a 1 pass compiler

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Some things can't be done with a 1 pass compiler

Post 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.
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Some things can't be done with a 1 pass compiler

Post 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
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Some things can't be done with a 1 pass compiler

Post 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?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Some things can't be done with a 1 pass compiler

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Some things can't be done with a 1 pass compiler

Post by STARGÅTE »

You can merge both structures:

Code: Select all

Structure STRUCTAB
	StructureUnion
		a.i
		b.i
	EndStructureUnion
	List StructsAB.STRUCTAB()
EndStructure
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Some things can't be done with a 1 pass compiler

Post 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 :D
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Some things can't be done with a 1 pass compiler

Post 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
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Some things can't be done with a 1 pass compiler

Post 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.
User_Russian
Addict
Addict
Posts: 1518
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Some things can't be done with a 1 pass compiler

Post 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. :wink:
sys64802
Enthusiast
Enthusiast
Posts: 105
Joined: Sat Sep 12, 2015 6:55 pm

Re: Some things can't be done with a 1 pass compiler

Post 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.
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Some things can't be done with a 1 pass compiler

Post 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.
sys64802
Enthusiast
Enthusiast
Posts: 105
Joined: Sat Sep 12, 2015 6:55 pm

Re: Some things can't be done with a 1 pass compiler

Post by sys64802 »

Justin wrote: Probably you will spend 1000x more time declaring your stuff than waiting for a 2 pass compilation.
:mrgreen:
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Some things can't be done with a 1 pass compiler

Post 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!
Post Reply