mob
var
A = 0 // set to a number
strict/B = "" // set to a string
Login()
. = 444
A = . // Sets A to "444"
B = . // Produces an error because . is not a string which was B's initial value type.
ID:2130609
Aug 11 2016, 11:23 pm (Edited on Nov 15 2016, 12:55 pm)
|
|||||||
| |||||||
Aug 12 2016, 1:06 am
|
|
Pretty sure the compiler would have no way of doing this. Runtime, sure, compile-time? Doubtful.
|
Think it would be possible to get its value at run-time when it's created and set that to its specific-type if the variable is set to strict?
A run-time error/crash would be okay imo too :) |
To implement this, an additional if() check would be needed during all var writes that would slow all code down across the board. That's a non-starter, at least as far as runtime checks would be concerned.
There is a distant possibility that the compiler could be made to recognize this and simply build in an automatic istype() assertion. |