LoginLogin
Might make SBS readonly: thread

Cool Coding 101: OPTION STRICT

Root / Submissions / [.]

chickenCreated:

What does OPTION STRICT do?

It sets a flag in the SB compiler that requires all variables to be declared (VAR A) before use. Many that use this also choose to use type suffixes, because those masochists just can't get enough of this stuff.

What does this even MEAN?

Well, this means that your awesome code should to go from this:
'Despacito Dating Sim, BETA!!! do not steal
'copyright me 2019-30239
X=100
Y=200
VEL=10.2
SPSET 0,4
WHILE DEAD==0
 SPOFS 0,X,Y
 INC Y,VEL
 VEL=VEL*0.97
 IF VEL<0.01 THEN DEAD=1
 VSYNC
WEND
to this:
'Despacito Dating Sim, RELEASE!!! do not steal
'copyright me 2019-30239
OPTION STRICT
VAR X%=100
VAR Y%=200
VAR VEL#=10.2
VAR DEAD%
SPSET 0,4
WHILE DEAD%==0
 SPOFS 0,X%,Y%
 INC Y%,VEL#
 VEL#=VEL#*0.97
 IF VEL#<0.01 THEN DEAD%=1
 VSYNC
WEND

Wait, slow down. What's up with the #s and %s?

Geez, I told you this already. They're type suffixes. You've probably used one before, though you might not know it.
  • $ is String, which is the one you've probably used a bunch of times already.
  • % is Integer, which lets you store whole numbers like 0, 73948, -22, and -1.
  • # is Float, or Real. This means you can have numbers with decimal points like 10.2, 3.333335, and -238.44, as well as any values that an Integer can hold!
  • For more on types, visit Variable Types (Resource) by 12Me21

What happens when VEL# is added to Y%? Aren't they different types? What happens to the decimal part?

When you add a Float to an Integer (or do any operation between the two), the result becomes a Float. When you try to assign this Float value to an Integer variable (A%=4.2), the decimal part is completely removed (4).

Thanks.

You're welcome. :)

>and have a type identifier symbol appended to the end of every variable name. wrong. also, "identifier" is a bad term for type suffixes (even though the manual might use it) because it has another meaning in syntax of 'any non-reserved word.' When referring to the character itself, use "suffix," when referring to the type... use "type" (looking at "$ is String, the identifier")

Replying to:Yolkai
>and have a type identifier symbol appended to the end of every variable name. wrong. also, "identifier" is a bad term for type suffixes (even though the manual might use it) because it has another meaning in syntax of 'any non-reserved word.' When referring to the character itself, use "suffix," when referring to the type... use "type" (looking at "$ is String, the identifier")
nooooo not like this EDIT: im upset i thought i had it all together (edit2, thanks, i was trying to figure out words in my head and couldn't find antonym of prefix again)

OPTION STRICT doesn't make type suffixes required... Also anyone who uses type suffixes on all their variables (and/or doesn't use OPTION DEFINT) is not a REAL PROGRAMMER

Replying to:12Me21
OPTION STRICT doesn't make type suffixes required... Also anyone who uses type suffixes on all their variables (and/or doesn't use OPTION DEFINT) is not a REAL PROGRAMMER
feelsbad

Replying to:Yolkai
>and have a type identifier symbol appended to the end of every variable name. wrong. also, "identifier" is a bad term for type suffixes (even though the manual might use it) because it has another meaning in syntax of 'any non-reserved word.' When referring to the character itself, use "suffix," when referring to the type... use "type" (looking at "$ is String, the identifier")
antiprefix