![]() |
|
Var declaration checking - Printable Version +- Boriel Basic Forum (https://forum.boriel.com) +-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11) +---- Forum: Wishlist (https://forum.boriel.com/forumdisplay.php?fid=14) +---- Thread: Var declaration checking (/showthread.php?tid=515) |
Var declaration checking - wilco2009 - 2012-12-19 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. Re: Var declaration checking - boriel - 2012-12-21 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? Re: Var declaration checking - wilco2009 - 2012-12-21 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. Re: Var declaration checking - boriel - 2012-12-22 wilco2009 Wrote:Perfect!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. Re: Var declaration checking - boriel - 2012-12-22 Okay, I think I've implemented this one. Download 1.3.0s959. Use: Code: zxb --explicit <yourprogram.bas>The following program: Code: LET a = 5You 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 parametersRe: Var declaration checking - wilco2009 - 2012-12-22 It's great! Many thanks. Both options are checked and are working perfectly. |