![]() |
|
option explicit - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: option explicit (/showthread.php?tid=4401) |
option explicit - Unseen Machine - 01-23-2026 How many of you guys use this? Why do you use it if you do? To me, its a weird but maybe compile side reasons reducing bloat. But if thats not the reason then WHY as to me it just adds a whole extra layer on a language that's supposed to be basic! And as an example... Code: (Select All)
THIS ERRORS! And this error took me a couple of mins to trace to this command! So i ask, can we add to the DEBUGGER something that says "Variable not defined before use - Option Explicit Error" or something as if it baffled me, newbies got no chance! also at the devs the error that this reports isnt very informative either Code: (Select All)
Surely the parser should pick up the somesilly and not inference the declare command as having been already declared! It's minor BS like this that adds to the "WTF" and people not wanting to play with QB64PE! Also, as it has 32 and 64 bit variants, why not call it QBasic PE - removes the "Oh its only for 64 bit systems" thought from a possible user who doesnt care to dig deeper. Whinge, whinge whinge! Unseen RE: option explicit - SMcNeill - 01-23-2026 (01-23-2026, 02:55 AM)Unseen Machine Wrote: How many of you guys use this? Your's is an error that screams at you nice and loud. Code: (Select All) DIM ThisIsMyVariable0123 as LongNow WTF is wrong with this code? It runs! It compiles! It frigging glitches out!! GAHHHHHHH!!! QB64 IS BROKEN!!! GAHHHHHHHH!!!!! It's two AM! I'm tired! My eyes are hurting! There's nothing frigging wrong with my code! It has to be the stupid devs and the stupid language itself that is wrong! I've looked over all 80,000 lines of my code and there's no damn compiler error in there anywhere!! Let me post this on the forums and see what those dumn devs have to say for themselves! Show me what's wrong with it, if you can, you noobs!!! GAAHHHHHHHH!! Response 30 seconds later: "Add OPTION _EXPLICIT to the top of your code. You mistyped a variable name. The code is right; your naming isn't." WTTTTFFFFFFFF!!!!!!! GAAAAHHHHHHHHHHHHHHHHHHH!!!!! *And thus, another user of Option Explict was born.* RE: option explicit - Unseen Machine - 01-23-2026 To me the suffix dims it as i use it so KB$ = or ANum& = etc...FORCING ME to declare a value implicitly before i can inference it is just as mad as linking unused libs when compiling! youre tired so youll agree! Me RE: option explicit - ahenry3068 - 01-23-2026 (01-23-2026, 03:24 AM)Unseen Machine Wrote: To me the suffix dims it as i use it so KB$ = or ANum& = etc...FORCING ME to declare a value implicitly before i can inference it is just as mad as linking unused libs when compiling! I use it for the same reason Steve said. It prevents small typos from becoming untraceable errors in your code. RE: option explicit - madscijr - 01-23-2026 I know the folks here play fast & loose, but I take comfort in having the variables used by any given routine all DIMmed up top. Call me OCD, but I feel it makes my code cleaner, and I think it has to help performance at least a little. I see code with DIM statements inside a loop, is the variable going to be re-allocated each time? In any case, the benefits of stopping you from mistyping variable names make Option Explicit a no brainer for me. RE: option explicit - SMcNeill - 01-23-2026 (01-23-2026, 03:24 AM)Unseen Machine Wrote: To me the suffix dims it as i use it so KB$ = or ANum& = etc...FORCING ME to declare a value implicitly before i can inference it is just as mad as linking unused libs when compiling! Reread what I was saying. Using ANum& is all fine and dandy. But will your tired eyes notice it when you type ANun& in the middle of a line of code that scrolls across the screen, in the middle of a 2000 line subroutine what's nothing but math and formula and calculations? What about when you have a variable called Gray = _RGB(128, 128, 128) and then in you code you want to LINE (x,y)-STEP(w,h), Grey, BF? Will your brain even pick out that you've screwed up on that line? Or are you going to spend endless hours trying to debug what's working 100% perfectly -- just not as you intended. The code isn't broke. There's nothing for the IDE to catch. No way to warn you or scream at you or slap you upside the head. You'll spend countless hours screaming, "WHY! OH GOD WHY!! WTF IS WRONG WITH THIS!!!!!" And one Option _Explicit would have told you the problem instantly. RE: option explicit - Unseen Machine - 01-23-2026 Fairs, Ill avoid it like Pete avoids showers i guess! I've never used it, AI dropped it into some dev and I didnt notice for ages! Thanks as always folks! Love ya John RE: option explicit - SMcNeill - 01-23-2026 One important point: If you want to share libraries and have folks use them, they should be OPTION _EXPLICT compliant. A vast portion of the user base uses Option _Explicit in their code. If your libraries don't have it, then they're not going to be readily usable for all those people to make any use of. RE: option explicit - Unseen Machine - 01-23-2026 ALL my libs are at least from now C/C++ with NO QB64 defined variables or UDT's so people can call em whatever they want now! Me going bed Laters John RE: option explicit - Pete - 01-23-2026 Me and option _expletive have an understanding. I don't use it, and it understands why. Pete
|