Repository navigation
Get rid of NameErrors and variable-delay-wrapping #583
nielstron
started this conversation in
Ideas / Improvements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
OpShin currently wraps many variables into delays, somewhat unnecessarily. This causes somewhat large contract sizes and more expensive execution than necessary.
The reason this is necessary is code like the following
We know that
awill be initialized after the loop and don't need to explicitly initialize it. However, ifrange(x)would be dependent on user input, it could be empty, and in that caseais not initialized at access in theprintstatement. Therefore OpShin currently implicitly initializes every variable during creation withdelay (traceError "NameError: var accessed before init)and forces variables upon access.It should be fairly possible to get rid of this implicit initialization by just forbidding accessing potentially uninitialized variables. However, this would require an explicit initialization of variables (causing less readability). An alternative is to implicitly initialize potentially uninitialized variables and treat them differently throughout the compilation chain. This seems brittle. I would thus prefer to just disallow reading potentially uninitialized variables. Also need to figure out how this pairs with #562
All reactions