CSHW89 wrote:Recursive data structures, e.g. Nondeterministic Finite Automata:
Your example with NFA.pb ,NFAState.pb, and NFATrans.pb, would never be compilable. Each of the files requires all of the other files (and itself) to be included before continuing. It is a clear example for the need of better programming structure because the improvements to XIncludeFile still wouldn't make it possible.
PureBasic is a one-pass compiler, not a recursive one.
I know you didn't ask for it but I might as well suggest it anyway. Until XIncludeFile is improved as you suggested you can define constants that can be tested with CompileIf's.
It would look like this:
Code: Select all
;//NFA.pb:
CompilerIf Defined(include_NFA, #PB_Constant)
CompilerElse
#include_NFA = 1
XIncludeFile "NFAState.pb"
Structure NFA
List state.NFAState()
EndStructure
CompilerEndIf
Code: Select all
;//NFAState.pb:
CompilerIf Defined(include_NFAState, #PB_Constant)
CompilerElse
#include_NFAState = 1
XIncludeFile "NFATrans.pb"
Structure NFAState
List trans.NFATrans()
EndStructure
CompilerEndIf
Code: Select all
;//NFATrans.pb:
CompilerIf Defined(include_NFATrans, #PB_Constant)
CompilerElse
#include_NFATrans = 1
XIncludeFile "NFA.pb"
Structure NFATrans
*value
*goal.NFAState
EndStructure
CompilerEndIf