The benefit of this devianceto the process is dubious.
function Keyword (Args : in Types.T_Array) return Types.T;
function Less_Equal is new Generic_Comparison ("<=");
function Less_Than is new Generic_Comparison ("<");
- function Mal_Do (Args : in Types.T_Array) return Types.T;
function Meta (Args : in Types.T_Array) return Types.T;
function Pr_Str (Args : in Types.T_Array) return Types.T;
function Println (Args : in Types.T_Array) return Types.T;
return (Kind_Keyword, Args (Args'First).Str);
end Keyword;
- function Mal_Do (Args : in Types.T_Array) return Types.T is
- begin
- Err.Check (0 < Args'Length, "expected at least 1 parameter");
- return Args (Args'Last);
- end Mal_Do;
-
function Meta (Args : in Types.T_Array) return Types.T is
begin
Err.Check (Args'Length = 1, "expected 1 parameter");
P ("deref", Types.Atoms.Deref'Access);
P ("dissoc", Types.Maps.Dissoc'Access);
P ("/", Division'Access);
- P ("do", Mal_Do'Access);
P ("=", Equals'Access);
P ("first", Types.Sequences.First'Access);
P ("get", Types.Maps.Get'Access);
Env.all.Set (Key, Val); -- Check key kind.
return Val;
end;
- -- do is a built-in function, shortening this test cascade.
+ elsif First.Str.all = "do" then
+ Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
+ declare
+ Result : Types.T;
+ begin
+ for I in 2 .. Ast.Sequence.all.Length loop
+ Result := Eval (Ast.Sequence.all.Data (I), Env);
+ end loop;
+ return Result;
+ end;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare
Env.all.Set (Key, Val); -- Check key kind.
return Val;
end;
- -- do is a built-in function, shortening this test cascade.
+ elsif First.Str.all = "do" then
+ Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
+ declare
+ Result : Types.T;
+ begin
+ for I in 2 .. Ast.Sequence.all.Length loop
+ Result := Eval (Ast.Sequence.all.Data (I), Env);
+ end loop;
+ return Result;
+ end;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare
Env.all.Set (Key, Val); -- Check key kind.
return Val;
end;
- -- do is a built-in function, shortening this test cascade.
+ elsif First.Str.all = "do" then
+ Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
+ declare
+ Result : Types.T;
+ begin
+ for I in 2 .. Ast.Sequence.all.Length loop
+ Result := Eval (Ast.Sequence.all.Data (I), Env);
+ end loop;
+ return Result;
+ end;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare
Env.all.Set (Key, Val); -- Check key kind.
return Val;
end;
- -- do is a built-in function, shortening this test cascade.
+ elsif First.Str.all = "do" then
+ Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
+ declare
+ Result : Types.T;
+ begin
+ for I in 2 .. Ast.Sequence.all.Length loop
+ Result := Eval (Ast.Sequence.all.Data (I), Env);
+ end loop;
+ return Result;
+ end;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare
Env.all.Set (Key, Val); -- Check key kind.
return Val;
end;
- -- do is a built-in function, shortening this test cascade.
+ elsif First.Str.all = "do" then
+ Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
+ declare
+ Result : Types.T;
+ begin
+ for I in 2 .. Ast.Sequence.all.Length loop
+ Result := Eval (Ast.Sequence.all.Data (I), Env);
+ end loop;
+ return Result;
+ end;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare
Env.all.Set (Key, Val); -- Check key kind.
return Val;
end;
- -- do is a built-in function, shortening this test cascade.
+ elsif First.Str.all = "do" then
+ Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
+ declare
+ Result : Types.T;
+ begin
+ for I in 2 .. Ast.Sequence.all.Length loop
+ Result := Eval (Ast.Sequence.all.Data (I), Env);
+ end loop;
+ return Result;
+ end;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare
Env.all.Set (Key, Val); -- Check key kind.
return Val;
end;
- -- do is a built-in function, shortening this test cascade.
+ elsif First.Str.all = "do" then
+ Err.Check (1 < Ast.Sequence.all.Length, "do expects arguments");
+ declare
+ Result : Types.T;
+ begin
+ for I in 2 .. Ast.Sequence.all.Length loop
+ Result := Eval (Ast.Sequence.all.Data (I), Env);
+ end loop;
+ return Result;
+ end;
elsif First.Str.all = "fn*" then
Err.Check (Ast.Sequence.all.Length = 3, "expected 2 parameters");
declare