Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Option _Explicit Keyword(s) of day XXX:
#18
(06-07-2023, 06:13 PM)Kernelpanic Wrote:
Quote:@Terry -  Correct. If OPTION _EXPLICIT were the first line of code in the example, the variable mm would have been flagged immediately. Also, a constant is not an ordinary variable. A constant can't have its value changed once set. The IDE will flag this if you try it:
Ordinary variable is probably worded a bit imprecisely, but by now one should know what I mean: Without Option Explicit there is no guarantee that a constant variable will be changed by a typo. This can really be a very nasty bug in a larger program - until you find it.

Ah, OK, I read your statement wrong. You are advocating for the use of OPTION _EXPLICIT to avoid this from happening, gotcha.

Something I used to do before OPTION _EXPLICIT existed in QB64 was to always capitalize every letter in constants except for the first letter which was always a lower case c. This way if I mistyped a constant the IDE would not capitalize it letting me know I misspelled it.

CONST cONEDEGREE = .017453292

<code>
<code>
Xrotate = Xrotate + condegree ' won't capitalize because of misspelling
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: Option _Explicit Keyword(s) of day XXX: - by TerryRitchie - 06-07-2023, 08:41 PM



Users browsing this thread: 2 Guest(s)