Page 1 of 1
Constants
Posted: Sat Sep 06, 2008 10:57 pm
by luis
I did a search but the word "constant" is very used as you can guess.
Well, sorry if already requested.
I would like to have a keyword "const" in addition to global, protected and so on.
Something like
Code: Select all
Const myconst.l
Protected Const localconst.l
Global Const globalconst.l
like the classical C/C++ keyword.
Just to get rid of some of the #MYCONST = 1 definitions and to have the ability to define local constants (would be nice) and to have constant parameters to procedures (e.g. constant pointers).
Well, here goes my request!
Thank you.
Posted: Sat Sep 06, 2008 11:14 pm
by Kaeru Gaman
I'm curious what you would need it for?
it's a while ago I progged in C...
a PB constant is replaced while compile time.
what against using a normal variable and taking care not to alter it?
Posted: Sat Sep 06, 2008 11:31 pm
by luis
Kaeru Gaman wrote:
a PB constant is replaced while compile time.
and it's only text, that's why you can't have a local const.
Kaeru Gaman wrote:what against using a normal variable and taking care not to alter it?
- well, for once it makes clear the intentions of who wrote the proc:
"this variable is for input only", or read only if you prefer
- you can see that like some additional implicit documentation of the proc, too
- being a variable and not a preprocessor string, you could initialize it using other variables or a function
- const pointers (the pointer is fixed and can point only to the specific location used to initialize it)
- pointers to const (the pointer can't change the data, but the pointer can change and point to other data)
- const pointers to const (the pointer is fixed and can't change the data is pointing to)
and so on ...

Posted: Sat Sep 06, 2008 11:39 pm
by Kaeru Gaman
yo, I get the point. thnx. as I said, just curious.
it can help to have additional support on keeping a variable unchanged, I see.
Posted: Sat Sep 06, 2008 11:49 pm
by luis
Yep but not only that: you could have LOCAL consts (now you can't) and you could initialize constants in many ways (directly, using other variables, using procedures). Now you can't.
Posted: Sun Sep 07, 2008 2:21 am
by Mistrel
I see this feature as redundant and necessary. If you want something like this in your own code you can add a keyword to the IDE and parse for it with a pre-compiler.
Re: Constants
Posted: Sat May 25, 2013 12:57 pm
by uwekel
Hi, this is already an old post but this is what i need as well

+1
Re:
Posted: Sun May 26, 2013 5:57 pm
by luis
Mistrel wrote:I see this feature as redundant and necessary.
As long it's necessary ...
Amusement aside, no, it's not redundant at all.
A "Const"
type qualifier is totally different from the current search and replace in the source for a
literal constant, as it's evident from the examples I've made above.
Probably it will never be implemented, but that's another story.