Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Var declaration checking
#1
Please, Could be possible to add an command option to require declare all variables.
I think, not declared variables is the source of bugs more difficult to find.
The problem is worse when you consider that BASIC is case sensitive.
Reply
#2
This is "pending" task; it will eventually be implemented. It's the flag Explicit (see -lang qb)
<!-- m --><a class="postlink" href="http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOptionexplicit">http://www.freebasic.net/wiki/wikka.php ... onexplicit</a><!-- m -->

I will implement it both as
#pragma option explicit

and as a command line flag: --option explicit

What do you think?
Reply
#3
Perfect!
I think the sintaxis is very clear.
When you have the option implemented, I'll start using it.
As Pascal enthusiast, I think it should be active by default.
Reply
#4
wilco2009 Wrote:Perfect!
I think the sintaxis is very clear.
When you have the option implemented, I'll start using it.
As Pascal enthusiast, I think it should be active by default.
So do I. ZX BASIC started as a project with high Sinclair BASIC compatibility, but with the time I started to diverge in order to achieve higher performance. For compatibility, people should always use the --sinclair flag.
Reply
#5
Okay, I think I've implemented this one. Download 1.3.0s959.
Use:
Code:
zxb --explicit <yourprogram.bas>
To compile it.
The following program:
Code:
LET a = 5
Should trigger an error if you compile it with --explicit option.
You can also use #pragmas in source code, which is a way to change compiling options from within the source code.
Code:
REM The following line will override command line parameters
#pragma explicit = True
LET a = 5
NOTE: The OPTION command won't be implemented (it's being deprecated even in FreeBASIC). #pragmas are used in C/C++ compilers, and FreeBASIC. So ZXBASIC will support them too.
Reply
#6
It's great!

Many thanks. Both options are checked and are working perfectly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)