You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Does that last line compile the same as
%dimA = 2561
Politically incorrect signatures about immigration patriots are forbidden. Searching “immigration patriots” is forbidden. Thinking about searching ... well, don’t even think about it.
The answer to both questions is Yes.
Constanta are evaluated during compilation.
The macro Foo is expanded when encountered dunring the compile time evalaution of %dimA
And something like
x = 5 + y + 4
gets compiled the same as
x = y + 9
?
Politically incorrect signatures about immigration patriots are forbidden. Searching “immigration patriots” is forbidden. Thinking about searching ... well, don’t even think about it.
In post 1 x is known at compile time (%dim = 10); so %dimA can be resolved at compile time.
In post 4 y is not known at compile time. Will y in the middle interrupt resolution; or will 5 and 4 be added? Either way resolving x has to wait till run time; I agree with Stuart about decompiling.
edit - aside: key word (ie dim in this case) as a constant/variable name???? may work, asking for a problem (IMO)
And something like
x = 5 + y + 4
gets compiled the same as
x = y + 9
If you are worried about that, you are worried about the wrong things. This would NOT be what is slowing your program or making your executable file overly large.
Mark didn't say that his program was slow or bloated, he asked a question about how the compiler works. I don't see any reason to critique that; the only information that your post provides is about your personal opinion.
mark didn't say that his program was slow or bloated, he asked a question about how the compiler works. I don't see any reason to critique that; the only information that your post provides is about your personal opinion assumption.
And something like
x = 5 + y + 4
gets compiled the same as
x = y + 9
?
No, but x = 5 + 4 + y will compile to 9 + y. Everything to the left of the variable will be evaluated to a single value so long as there is no hint of floating-point arithmetic and the operands are integer literals or equates, so our discussion is really only relevant to integer expressions involving the operators that will not produce non-integer results from integer operands. It's not whether they will in a given instance, it's whether they can in any instance. Some examples:
Honestly, it was years ago and I don't remember testing exactly that before/after scenario, so I'll buy Mark's assertion. It makes sense that the parser would be thrown off by that.
Generally speaking, later versions of PB do a very thorough job of resolving numeric and string constants at compile time, but I probably over-generalized.
Methinks, y must have a value or you'll get a compiler error, ergo, the two 'diametrically opposed assertions' are both correct. There is nothing in x=5+4+y or in x=5+y+4 that relates to 'constant math'(there are no constants indicated). Only the rules of operator precedence apply to those two equations.
Rod
I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment