10.2.1
change qyxupqzqnxzlpsxmsszsmknylumlpuxl
commit f5128180dc213f6565e8262fa91bac7ce07afdbd
author Alpha Chen <alpha@kejadlen.dev>
date
parent ymvnwspv
diff --git a/ruby/lib/lox/interpreter.rb b/ruby/lib/lox/interpreter.rb
index 28904cc..56c4891 100644
--- a/ruby/lib/lox/interpreter.rb
+++ b/ruby/lib/lox/interpreter.rb
@@ -4,7 +4,14 @@ module Lox
   class Interpreter
 
     def initialize(env=Environment.new)
-      @env = env
+      @globals = env
+      @env = @globals
+
+      @globals.define("clock", Class.new {
+        def arity = 0
+        def call(*) = Time.now.to_f
+        def to_s = "<native fn>"
+      })
     end
 
     # The book does printing and error catching here, but