Poll: Unseen is crazy...
You do not have permission to vote in this poll.
Defo...no doubt...
100.00%
1 100.00%
Defo again - but he may actually be on to something here...
0%
0 0%
Total 1 vote(s) 100%
* You voted for this item. [Show Results]

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arbitrary CONST values
#13
(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 !
Reply


Messages In This Thread
Arbitrary CONST values - by Unseen Machine - 10-25-2025, 11:25 PM
RE: Arbitrary CONST values - by SMcNeill - 10-25-2025, 11:41 PM
RE: Arbitrary CONST values - by Unseen Machine - 10-26-2025, 12:01 AM
RE: Arbitrary CONST values - by bplus - 10-25-2025, 11:51 PM
RE: Arbitrary CONST values - by bplus - 10-26-2025, 12:15 AM
RE: Arbitrary CONST values - by Unseen Machine - 10-26-2025, 12:26 AM
RE: Arbitrary CONST values - by ahenry3068 - 10-26-2025, 02:48 PM
RE: Arbitrary CONST values - by CharlieJV - 10-26-2025, 06:06 PM
RE: Arbitrary CONST values - by ahenry3068 - 10-26-2025, 08:16 PM
RE: Arbitrary CONST values - by bplus - 10-26-2025, 05:35 PM
RE: Arbitrary CONST values - by bplus - 10-26-2025, 06:37 PM
RE: Arbitrary CONST values - by bplus - 10-26-2025, 10:50 PM
RE: Arbitrary CONST values - by ahenry3068 - 10-27-2025, 01:28 AM
RE: Arbitrary CONST values - by bplus - 10-27-2025, 01:48 AM
RE: Arbitrary CONST values - by ahenry3068 - 10-27-2025, 04:29 AM
RE: Arbitrary CONST values - by SMcNeill - 10-27-2025, 02:12 AM
RE: Arbitrary CONST values - by CharlieJV - 10-27-2025, 02:17 AM
RE: Arbitrary CONST values - by Unseen Machine - 10-27-2025, 02:36 AM
RE: Arbitrary CONST values - by bplus - 10-27-2025, 08:18 AM
RE: Arbitrary CONST values - by a740g - 10-27-2025, 09:37 AM
RE: Arbitrary CONST values - by SMcNeill - 10-27-2025, 09:45 AM
RE: Arbitrary CONST values - by Jack - 10-27-2025, 12:05 PM
RE: Arbitrary CONST values - by a740g - 10-27-2025, 06:06 PM
RE: Arbitrary CONST values - by Kernelpanic - 10-27-2025, 08:41 PM
RE: Arbitrary CONST values - by Pete - 10-28-2025, 06:57 AM
RE: Arbitrary CONST values - by Unseen Machine - 10-28-2025, 11:22 PM
RE: Arbitrary CONST values - by Unseen Machine - 10-28-2025, 11:30 PM
RE: Arbitrary CONST values - by ahenry3068 - 10-29-2025, 12:31 AM
RE: Arbitrary CONST values - by Unseen Machine - 10-29-2025, 01:50 AM
RE: Arbitrary CONST values - by bplus - 10-29-2025, 02:27 AM
RE: Arbitrary CONST values - by ahenry3068 - 10-29-2025, 02:56 AM
RE: Arbitrary CONST values - by bplus - 10-29-2025, 05:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Upcoming changes to CONST may affect your code SMcNeill 14 2,716 12-30-2023, 05:13 PM
Last Post: Kernelpanic
  TYPE and CONST within SUB/FUNCTION TerryRitchie 9 1,939 07-11-2023, 01:22 AM
Last Post: bplus
  suggestion: initialize array values within the DIM statement bobalooie 19 3,312 12-22-2022, 06:46 PM
Last Post: Kernelpanic
  Convert IPv4 dotted quad into four decimal values bert22306 6 1,528 10-31-2022, 03:30 AM
Last Post: bert22306
Bug Color CONST Warning v1.5+ bplus 3 797 05-05-2022, 06:13 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)