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 = "" + }) end # The book does printing and error catching here, but