Restrict variable names

Ideas for new features & functions

Moderators: JRL, Dorian (MJT support)

Post Reply
NancyM
Pro Scripter
Posts: 66
Joined: Mon Jul 18, 2016 7:01 pm

Restrict variable names

Post by NancyM » Wed Aug 17, 2016 2:35 pm

Imagine my surprise when I learned that I'd accidentally redefined 0 to a string. I'd love for the interpreter to check that variables begin with non-numeric values like most languages do. Maybe underscore and letters?

User avatar
Marcus Tettmar
Site Admin
Posts: 7118
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Restrict variable names

Post by Marcus Tettmar » Wed Aug 17, 2016 2:50 pm

Why not use VAREXPLICIT?

https://www.mjtnet.com/manual/index.htm ... lution.htm

This allows you to distinguish between 0 and %0%. This is more like regular programming languages. Your code would not have failed in this case.

We won't be forcing variables to start with non numerics or we are very likely to break backward compatibility. We could make an option like VAREXPLICIT which prevents it, but for backward compat reasons would not make it default. Therefore you may as well just use your own sensible naming conventions.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply