Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constants and global variables #12

Closed
SpencerPark opened this issue Nov 20, 2016 · 0 comments
Closed

Constants and global variables #12

SpencerPark opened this issue Nov 20, 2016 · 0 comments

Comments

@SpencerPark
Copy link
Owner

The sync link has changed the code execution order and there is no longer the top down intuition for execution. There is no way to reliably predict when each block will change a global variable value.

To solve this problem I think there should be the introduction of a constant. All global variables must be constants. This also opens up the possibility of exporting variables for consumption by other programs.

Proposed Syntax

Reuse the def keyword used for defining blocks and functions. This would define a value.

def myChord -> (a, b, c) //A constant
myOtherChord -> (a, b, c) //A variable

Assignment to constants would then throw an exception

myChord -> (d, e, f) //Error, myChord is constant

The compiler should also ensure that the current behavior of manipulation operations making fresh objects as everything in the object should be immutable. i.e.

myRoot -> (a)
def myChord -> (myRoot, b, c)
myRoot -> (b) //Must not change myChord
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant