- Aug 2, 2003I think of a "constant" as a variable which holds a given value, and
may never be assigned a new value. (Of course, if that's the case,
it's not technically a "variable", because the value will not vary,
As an example, in your language you may want to establish a constant
called "pi". Your users will be allowed to use the constant "pi" in
an equation, but they will not be allowed to assign it a new value.
How might this be accomplished?
Well, when your users use your language, I suspose they will be
writing "programs" or "scripts" with some kind of an editor. As the
language author, I'm guessing that you will develop some kind of
a "parser" which reads the script line by line, and word by word.
When your parser comes upon the word "pi" (or any other constants
that you've established), I expect that you will provide the user
with an error message if "pi" is not used according to the
syntactical rules that you've set.
In short, I guess creating constants involves two steps: (1)
assigning each constant a value in the "engine" of your programming
language, and (2) protecting the constant against illegal use by the
programmer when the program is parsed and compiled.
---Tom Nally, New Orleans
--- In firstname.lastname@example.org, "willieej2002"
> Hello everyone. I am making a brand new language and I want it toa
> use constants similar to LB's.
> Is there some kind of command that will determine if the string is
> constant or will I have to define every single constant in windows?
> Help Please?
- << Previous post in topic