Page 1 of 1

Reassign ##Constant

Posted: Sat Sep 25, 2004 8:38 am
by horst
How about a new type of constant that can be reassigned, beginning with two hash signs.

For axample you can define:
##x = 20
and later:
##x = #blah + 12
or even:
##x = ##x + 10

I often have to invent (long) constant names, that will only be used for the next few source lines anyhow..

Posted: Sat Sep 25, 2004 9:30 am
by Moonshine
Well it sortof defeats the object of calling it a constant then, doesnt it?

Posted: Sat Sep 25, 2004 11:55 am
by PB
> it sortof defeats the object of calling it a constant then, doesnt it?

Agreed. A constant can NEVER be changed, once defined. Use a variable if
you need to change the value later. And take a look at this similar topic:

viewtopic.php?t=12571

Posted: Sat Sep 25, 2004 1:30 pm
by GPI
Nice would be global and constants, which are only "active" in a file / included file...

Or local-file-global-variable and local-file-constant...

Posted: Sat Sep 25, 2004 6:11 pm
by horst
@moonshine
> Well it sortof defeats the object of calling it a constant then

Actually, a constant is, for example <b>123</b> in <b>size = 123</b> or "something" in <b>#word = "something"</b>.

A constant <b>object</b> is a compile-time variable that never changes. So, what I want, is a value assignment or a string assignment, that may change at compile time.

@PB
> Use a variable if you need to change the value later.

I want to keep it off run-time.
Which is no big deal: The A86 Assembler, for example has two different assignments:
name = value
name equ value

BTW: this reminds me of string concatenation:
Why do we need lots of runtime calls for this statement:
string$ = "something" + #crlf$ + "another" + chr(34) + "word" + chr(34)

@GPI
> Nice would be global and constants, which are only "active" in a file / included file...

Another concept of a compile-time reassignment.
But PB does not support modular environments...