Reassign ##Constant

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Reassign ##Constant

Post 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..
Horst.
Moonshine
Enthusiast
Enthusiast
Posts: 263
Joined: Tue May 25, 2004 12:13 am
Location: UK

Post by Moonshine »

Well it sortof defeats the object of calling it a constant then, doesnt it?
Mark my words, when you least expect it, your uppance will come...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post 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...
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post 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...
Horst.
Post Reply