summary refs log tree commit diff
path: root/examples
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-18 16:44:49 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-18 16:48:42 +0100
commit7ec2bea103fee9bced8ac08c33223f795ab59213 (patch)
tree4a65214c9f4ce364335ec6c05ba9db3a2a189456 /examples
parentMisc: Start working on scopes (diff)
downloadinterpreter-7ec2bea103fee9bced8ac08c33223f795ab59213.tar.gz
interpreter-7ec2bea103fee9bced8ac08c33223f795ab59213.tar.bz2
interpreter-7ec2bea103fee9bced8ac08c33223f795ab59213.zip
Evaluator: Create environment abstraction for handling scopes
Diffstat (limited to 'examples')
-rw-r--r--examples/5.src6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/5.src b/examples/5.src
index d9a8dad..88c171c 100644
--- a/examples/5.src
+++ b/examples/5.src
@@ -1,3 +1,7 @@
+/* As you see, the language supports variable scopes */
+
+let x = 18;
+
 let foo = () => {
 	let x = 1;
 	print(x);
@@ -5,8 +9,8 @@ let foo = () => {
 };
 
 let main = () => {
+	print(x);
 	let x = 2;
-	/* As you see, the language supports variable scopes */
 	foo();
 	print(x);
 	return x;