diff --git a/src/env.c b/src/env.c index 5265d65..2c18351 100644 --- a/src/env.c +++ b/src/env.c @@ -209,7 +209,6 @@ struct Environment defaultEnv() pf(numToChar), pf(printEnvO), pf(systemCall), - pf(loadFile), pf(cd), pf(cwd), pf(takeInput), diff --git a/src/examples/lib.pbl b/src/examples/lib.pbl index 0fb6a00..4f5e7ab 100644 --- a/src/examples/lib.pbl +++ b/src/examples/lib.pbl @@ -4,6 +4,10 @@ (prn (cat _txt (ch 10))) ))) +(def loadfile (fn (file-name) ( + (eval (rf file-name)) +))) + ; Exponentiate a^b (def exp (fn (a b) (if (= b 0) diff --git a/src/plfunc.c b/src/plfunc.c index 388a20c..346abd7 100644 --- a/src/plfunc.c +++ b/src/plfunc.c @@ -483,18 +483,6 @@ Object takeInput(Object* params, int length, unused struct Environment* env) return errorWithContext(NULL_PARSE, "fgets() error"); } -Object loadFile(Object* params, unused int length, struct Environment* env) -{ - checkTypes(loadFile) - Object filename = params[0]; - - if (isStringy(filename)) { - readFile(filename.string, env); - return numberObject(0); - } - return numberObject(1); -} - Object cd(Object* params, unused int length, unused struct Environment* env) { checkTypes(cd) diff --git a/src/plfunc.h b/src/plfunc.h index f389ad5..114d8e6 100644 --- a/src/plfunc.h +++ b/src/plfunc.h @@ -248,10 +248,10 @@ tfn(numToChar, "ch", ); fn(printEnvO, "penv", - "Prints out the current scoped environment.\n" - "(penv) prints a mostly human-readable list of env variables.\n" - "(penv T) prints a mostly list of env variables, including pointer addresses.\n" - "Calling (penv) with no argument is equivalent to (penv F)" + "Prints out the current scoped environment.\n" + "(penv) prints a mostly human-readable list of env variables.\n" + "(penv T) prints a mostly list of env variables, including pointer addresses.\n" + "Calling (penv) with no argument is equivalent to (penv F)" ); tfn(systemCall, "sys", @@ -261,15 +261,6 @@ tfn(systemCall, "sys", "(sys \"echo yee > /dev/null\")", "0", ); -tfn(loadFile, "loadfile", - ({ expect(isStringy), anyType }), - "Loads and parses the given file.\n" - "Returns 0 if the file was loaded and parsed successfully. Otherwise 1.\n" - "(loadfile \"printdate.pl\")\n" - "Mon 21 Mar 2022 10:35:03 AM EDT\n" - "=> 0" -); - tfn(cd, "cd", ({ expect(isStringy), anyType }), "Change the current directory."