Browse files

adding a shortcut to inspecting the env at run time and fixing issue …

…with defining functions with define rather than using lambda directly
  • Loading branch information...
1 parent e1bc61d commit 2cc7268c6b0665ea57b3d884f2d5371e7e0b574a @fitzgen committed Feb 9, 2010
Showing with 15 additions and 3 deletions.
  1. +15 −3 scheme.adb
View
18 scheme.adb
@@ -1227,6 +1227,10 @@ procedure Scheme is
-- Read an integer
Read_Integer(Str, I, Obj);
return;
+ elsif Element(Str, I) = '_' then
+ -- Shortcut for inspecting the env.
+ Obj := Make_Symbol(To_Unbounded_String("_"));
+ return;
else
Stderr("Read illegal state.");
raise Constraint_Error;
@@ -1305,8 +1309,13 @@ procedure Scheme is
end;
function Definition_Variable (Expr : Access_Object) return Access_Object is
+ Obj : Access_Object := Cadr(Expr);
begin
- return Cadr(Expr);
+ if Is_Symbol(Obj) then
+ return Obj;
+ else
+ return Car(Obj);
+ end if;
end;
function Make_Lambda (Parameters : Access_Object;
@@ -1461,8 +1470,11 @@ procedure Scheme is
begin
<<Tailcall>>
- if Is_Self_Evaluating(Exp) then
- return Exp;
+ if Exp.all.O_Type = Symbol and then Exp.all.Data.Symbol = "_" then
+ -- Shortcut for inspecting the env.
+ return Env;
+ elsif Is_Self_Evaluating(Exp) then
+ return Exp;
elsif Is_Variable(Exp) then
return Lookup_Variable_Value(Exp, Env);
elsif Is_Quoted(Exp) then

0 comments on commit 2cc7268

Please sign in to comment.