• Print

Author Topic: $1 Offer  (Read 1076 times)

Johny B.

  • Sr. Member
  • ****
  • Posts: 486
    • Email
Re: $1 Offer
« Reply #15 on: October 23, 2011, 02:37:00 AM »
Personally, I think that you should be able to turn on option explicit for certain blocks of code. Say you added the following to a program you are working on:
Code: [Select]
INPUT "Name: ", username$
username$ = LTRIM$(RTRIM$(usrname$)
IF username$ <> "" THEN PRINT "HI ", username$ ELSE PRINT "Mr. Anonymous"
This code would obviously fail, because of a spelling error on line 2. If we were to use the following code instead:
Code: [Select]
OPTION EXPLICIT
DIM username$
INPUT "Name: ", username$
username$ = LTRIM$(RTRIM$(usrname$)
IF username$ <> "" THEN PRINT "HI ", username$ ELSE PRINT "Mr. Anonymous"
OPTION IMPLICIT
then we would be told that usrname$ has not been declared.

Obviously, it would have been quite easy to pick up manually in that example, but much harder if the code were any bigger.
-Luke
"Time is an illusion; Lunchtime doubly so." - Douglas Adams

DeeBee

  • Sr. Member
  • ****
  • Posts: 491
    • Donnelly-House
    • Email
Re: $1 Offer
« Reply #16 on: October 23, 2011, 09:20:43 AM »
OPTION IMPLICIT goes against the grain of the concept,
but I will think about it.

I believe it is generally defined as: -OPTION EXPLICIT

But I think you are only supposed to use one or the other at the beginning of your program.
I can't think where it is allowed to be performed on "sections of code" with it being
turned on and off. I also can't think of a "good" reason why you would want to do that.

There is also: OPTION STRICT

which "restricts implicit data type conversions to only widening conversions".

So it would generate an error or warning message for this code:

Code: [Select]
DIM bbb AS _BYTE
DIM iii AS INTEGER

iii = 1000
bbb = iii   ' this is potentially a bad situation

Option Strict implies Option Explicit.
But Option Strict situations are harder to discover.
And we don't have type casting like:

Code: [Select]
bbb = _BYTE (iii)
   or
bbb = (_BYTE) iii

Although that can be performed with a function.

And/or QB64 automatically does whatever needs to be done
behind the scenes to make it work and not generate an error,
although that is "magical programming", which is generally
not a good thing. (it is contra-indicated, like "magical thinking")

The point of programming is that you are IN CONTROL.
(that's why most good programmers are "control freaks" --
and tend to be perfectionists, anal retentive, game-players, puzzle-solvers, etc.)

More info: http://support.microsoft.com/default.aspx?kbid=311329
« Last Edit: October 23, 2011, 09:26:20 AM by DeeBee »

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: $1 Offer
« Reply #17 on: October 26, 2011, 06:21:58 AM »
Hi all,
    DeeBee post this question in the Developer Blog.
OlDosLover.

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: $1 Offer
« Reply #18 on: October 26, 2011, 08:43:56 AM »
If you use camel casing, the IDE already changes the variable name to the same case as the original, but I have had similar variable names like Xmax and Xmin. How would it note a spelling or thinking error?

First you want QB64 to be perfect and then PROVE how imperfect YOU really are by asking QB64 to take the ONUS for your mistakes! You will NEVER be happy! You just want to whine!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

DeeBee

  • Sr. Member
  • ****
  • Posts: 491
    • Donnelly-House
    • Email
Re: $1 Offer
« Reply #19 on: October 26, 2011, 10:34:28 AM »
Like Forest Gump's momma always said,
"Clueless is as Clueless does."

Lachie Dazdarian

  • Sr. Member
  • ****
  • Posts: 280
    • http://games.freebasic.net
    • Email
Re: $1 Offer
« Reply #20 on: October 26, 2011, 11:03:17 AM »
OPTION EXPLICIT, for lack of a better phrase, is good. OPTION EXPLICIT is right. OPTION EXPLICIT works. OPTION EXPLICIT clarifies, cuts through, and captures, the essence of the programming spirit.

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: $1 Offer
« Reply #21 on: October 26, 2011, 11:17:38 AM »
OPTION EXPLICIT is NOT BASIC! That is WHY we are here and NOT at the Free Basic site!  ;)
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2264
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: $1 Offer
« Reply #22 on: October 26, 2011, 11:23:04 AM »
I agree with Clippy that OPTION EXPLICIT is not BASIC and should not be forced on a BASIC programmer.

However, as Johnny B pointed out, misspellings of variable names is a real pain in the butt in very large sets of code. I would not mind at all if I had the option as a programmer to add this metacommand to my code to aid in variable creation.

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: $1 Offer
« Reply #23 on: October 26, 2011, 11:41:31 AM »
I don't have a problem with the OPTION. I just don't want to see Galleon spend a lot of time on things like that until other things are done. There are better priorities! I'm not too crazy about the recent shift to a Help system either!

Where is the optional SUB parameters, DEF Fn, etc. ?
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Mrwhy

  • Hero Member
  • *****
  • Posts: 2890
  • My Dad called me Mr Why when I was 5.
    • Email
Re: $1 Offer
« Reply #24 on: October 26, 2011, 11:51:44 AM »
Quote from: TerryRitchie on October 26, 2011, 11:23:04 AM
I agree with Clippy that OPTION EXPLICIT is not BASIC and should not be forced on a BASIC programmer.

However, as Johnny B pointed out, misspellings of variable names is a real pain in the butt in very large sets of code. I would not mind at all if I had the option as a programmer to add this metacommand to my code to aid in variable creation.

How about a "spell checker" that prints any NEW name in orange or itallics to remind you "not used in this prog before"

DeeBee

  • Sr. Member
  • ****
  • Posts: 491
    • Donnelly-House
    • Email
Re: $1 Offer
« Reply #25 on: October 26, 2011, 12:48:02 PM »
OPTION EXPLICIT IS "BASIC".

(sorry, but that is a completely ignorant comment)

And nothing is being forced on anyone.
(see my comment re: OPTional)

Mrwhy

  • Hero Member
  • *****
  • Posts: 2890
  • My Dad called me Mr Why when I was 5.
    • Email
Re: $1 Offer
« Reply #26 on: October 26, 2011, 08:05:21 PM »
DeeBee, could you please make it clear WHO said
OPTION EXPLICIT IS "BASIC".

DeeBee

  • Sr. Member
  • ****
  • Posts: 491
    • Donnelly-House
    • Email
Re: $1 Offer
« Reply #27 on: October 26, 2011, 08:28:23 PM »
Sure, right after you show me where someone says it is not.

DeeBee

  • Sr. Member
  • ****
  • Posts: 491
    • Donnelly-House
    • Email
Re: $1 Offer
« Reply #28 on: October 27, 2011, 12:33:27 AM »
My last reply was rhetorical. For those who may not get it,
asking someone to 'make it clear WHO said OPTION EXPLICIT IS "BASIC" '
is no different from something equally absurd and ludicrous, such as asking
someone to "make it clear WHO said _NEWIMAGE IS "BASIC" '.
(OR, it's not "BASIC" if you don't have line numbers, or if you do have
Functions and Subroutines, etc...., ad infinitum, ad nauseum ---
some of you will understand that, and I suppose some not)

However, as merely a FEW examples, even though it's not really necessary,
here are some "BASIC's" that offer "Option Explicit", or require it by default
without the OPTION of using it:

Visual BASIC
VB.NET
Several VB-like and BASIC(-ish) scripting languages
(VBA, etc., for M$ products (Word, Excel, Access, etc.), and in Open Office,
LibreOffice, etc...., as well as VBScript for web browsers)
SQABasic
FreeBASIC
PowerBASIC
REALbasic
BASIC Plus 2
VAX BASIC

And others.....

(some of those have been around longer than some of you have been alive)

Clippy

  • Hero Member
  • *****
  • Posts: 16431
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: $1 Offer
« Reply #29 on: October 27, 2011, 12:39:59 AM »
WAH!  :'(  Explicit Whiner....
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

  • Print