Loading ...
Sorry, an error occurred while loading the content.

16273Re: Constants

Expand Messages
  • Tom Nally
    Aug 2, 2003
    • 0 Attachment
      I 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,
      eh?)

      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 libertybasic@yahoogroups.com, "willieej2002"
      <willieej2002@y...> wrote:
      > Hello everyone. I am making a brand new language and I want it to
      > use constants similar to LB's.
      >
      > Is there some kind of command that will determine if the string is
      a
      > constant or will I have to define every single constant in windows?
      >
      > Help Please?
      >
      > ---
    • Show all 3 messages in this topic