10-27-2025, 01:28 AM
(This post was last modified: 10-27-2025, 01:39 AM by ahenry3068.)
(10-26-2025, 10:50 PM)bplus Wrote: @ahenry3068
I think Charlie is saying
Const MyDate$ = Date$, MyTime$ = Time$
These will remain constant through Run of the program, even though every time you start a new run they will be different. So there is that too!
Yes. I get what he said. That is exactly as I understood it. Those things are still not known at compile time though.
Being known at compile time and NOT CHANGING ever is the whole point of a CONSTANT in any programming language.
Allowing the code you put above would be contrary to the whole purpose of having a CONSTANT directive.
I've been doing a whole lot of assembly code lately, maybe that's why I feel so strongly about this.
We are talking about what machine code is generated.
When you use a CONSTANT value the code generated is like this
CONST FOUR=4
X = FOUR
D = FOUR
Would generate the EXACT same code as
X = 4
D = 4
ML CODE WOULD BE LIKE
LOAD REGISTER IMMEDIATE VALUE 4
STORE REGISTER AT ADDRESS X
LOAD REGISTER IMMEDIATE VALUE 4 ; this could possibly even be eliminated with a good code optimizer, but would probably be there without
optimization. Immediate register loads are usually much faster than Memory loads too.
STORE REGISTER AT ADDRESS D
THIS:
DIM X AS INTEGER
X = 4
D = X
Would generate quite different and more complex code at the machine level.
LD REGISTER WITH IMMEDIATE VALUE 4
STORE REGISTER AT ADDRESS X
LD SRC POINTER REGISTER WITH ADDRESS OF X
LD DEST POINTER REGISTER WITH ADDRESS OF D
MOV VALUE AT SRC POINTER TO DEST POINTER LOCATION
This is a pretty simple example. But the whole point of CONSTANT declarations is to speed up and simplify the generated code !
Charlie is missing the point of constants.
What he wants would make it NO LONGER A CONSTANT !


