TI-994A wrote:Hi BorisTheOld. I don't know enough about the inner workings of PureBasic's macro system to comment on you earlier remark, but what do you mean when you say
the way one would expect?
I don't know anything about PB's macro processor.
Two weeks ago I reported what looks like a bug in the macro processor, but Fred said it's not, and moved me to Feature Requests.
Here's the problem I reported. The first block of code works, but the second block fails.
The "Field" statement expands as follows: Field(x, typInt32) --> x.typInt32 --> x.i
Code: Select all
Macro typInt32
i
EndMacro
Macro Field (DataName, DataType)
DataName.DataType
EndMacro
Field(x, typInt32) ; x.i
With this next block of code, the compiler complains about a missing structure named, "typInt32".
The "Field" statement expands as follows: Field(x, typInt32) --> x.typInt32 , then stops
This time the "typInt32" is not recognized as a macro, but in the first block of code the compiler appeared to continue scanning the text to resolve the "typInt32" macro. Obviously, under certain conditions, something is going on in the macro processor to terminate parsing before all possible macro references have been resolved.
Code: Select all
Macro typInt32
i
EndMacro
Macro Field (DataName, DataType)
DataName.typ#DataType
EndMacro
Field(x, Int32) ; structure not found: typint32
All other macro processors I've worked with keep parsing the text until all macro references have been resolved. PB seems to be working only with the parameters, then dropping the expanded text into the macro body as a final step. This unusual behaviour severely limits what can be done with PB macros, and makes it difficult to write utility programs to expand macros the way PB does.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan