Author Topic: Strict  (Read 1537 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Full Member
  • ***
  • Posts: 146
Strict
« on: July 12, 2013, 06:50:13 AM »
Deleted
« Last Edit: May 08, 2015, 03:15:22 PM by Peter »

Charles Pegge

  • Author
  • *****
  • Posts: 3282
    • Oxygen Basic
Re: Strict
« Reply #1 on: July 12, 2013, 09:31:39 AM »
Developer Peter,

#autodim off is what you are looking for. However this does not work with iterators yet. I will fix this on the next release.

Another useful switch is #unique on/off, which prevents anything from being defined more than once.

These switches can be turned on or off at any position of the program.

Any further ideas for code discipline?  ;D


« Last Edit: July 12, 2013, 09:45:28 AM by Charles Pegge »

John

  • Hero Member
  • *****
  • Posts: 2803
Re: Strict
« Reply #2 on: July 12, 2013, 10:42:33 AM »
Quote
This program automatically creates 2 local variables: 'k' and 'sum'. However, this behaviour can often lead to unexpected bugs. For example, if you mistyped one of the 'sum' variables, the program would not work as expected. No error would be given - a new variable would simply be created.

FYI

ScriptBasic supports something similar.

declare option DeclareVars
declare option AutoVars

You can also control if variables used in functions/subs default to local scope. By default variables created within functions are global unless they are predefined as LOCAL prior to assignment within the function.

I personally like ScriptBasic's lazy / careful programming mode as the default. If I was doing a large project in SB, I would enable these language checks during the development cycle.

John

  • Hero Member
  • *****
  • Posts: 2803
Re: Strict
« Reply #3 on: July 12, 2013, 01:33:45 PM »
Quote
This image, is it a Microsoft logo?

No. I think it's Charles's vision of the golden arch for the new McDonald's campaign.  :D

Would you beg and take a few lashes for a Big Mac?

« Last Edit: July 15, 2013, 05:55:16 PM by JRS »

kryton9

  • Hero Member
  • *****
  • Posts: 721
Re: Strict
« Reply #4 on: July 13, 2013, 05:30:49 PM »
I love the humor!