Permalink
Browse files

stack is all working again; yaye

  • Loading branch information...
1 parent 145e398 commit 2db62bd20aba1ae25f6eed51c424c0e3be884e64 @technomancy committed Feb 25, 2008
Showing with 7 additions and 3 deletions.
  1. +1 −1 lib/eval.rb
  2. +2 −2 lib/lambda.rb
  3. +4 −0 lib/primitives.rb
View
@@ -29,7 +29,7 @@ def apply(function_sym, args)
end
def current_scope
- @@stack.empty? ? SYMBOL_TABLE : @@stack.last.scope
+ @@stack.empty? ? SYMBOL_TABLE : @@stack.last
end
def in_scope?(sym)
View
@@ -24,7 +24,7 @@ def call(*args)
@scope = RecursiveHash.new(locals, @enclosing_scope)
- BusScheme.stack.push self.dup
+ BusScheme.stack.push @scope
begin
val = @body.map{ |form| BusScheme.eval(form) }.last
rescue => e
@@ -44,7 +44,7 @@ def initialize body
def call(*args)
@scope = BusScheme.current_scope
- BusScheme.stack.push self
+ BusScheme.stack.push @scope
begin
val = @body.call(*args)
rescue => e
View
@@ -25,6 +25,10 @@ def self.special_form(identifier, value)
define 'list', lambda { |*members| members.to_list }
define 'vector', lambda { |*members| members.to_a }
define 'map', lambda { |fn, list| list.map(lambda { |n| fn.call(n) }).sexp }
+
+ define 'read', lambda { gets }
+ define 'write', lambda { |obj| puts obj.inspect; 0 }
+ define 'display', lambda { |obj| puts obj }
define 'eval', lambda { |code| eval(code) }
define 'stacktrace', lambda { BusScheme.stacktrace }

0 comments on commit 2db62bd

Please sign in to comment.