Fixed bug where all func calls require an argument
Certain I/O functions (like `inp` or `repl`) do not need arguments, but previously all functions required at least one argument to called correctly (i.e. `(inp 0)` or `(repl "banana")`). Now, these can be called as intended: `(inp)` or `(repl)`.
This commit is contained in:
parent
811e9e3dd2
commit
a6f3fc96e6
|
@ -15,8 +15,13 @@ Object fetchFromEnvironment(const char *name, struct Environment *env)
|
||||||
if(!env)
|
if(!env)
|
||||||
return errorObject(NULL_ENV);
|
return errorObject(NULL_ENV);
|
||||||
|
|
||||||
if(env->size == 0)
|
if(env->size == 0) {
|
||||||
|
if (env->outer) {
|
||||||
|
return fetchFromEnvironment(name, env->outer);
|
||||||
|
} else {
|
||||||
return errorObject(EMPTY_ENV);
|
return errorObject(EMPTY_ENV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < env->size; i++) {
|
for(int i = 0; i < env->size; i++) {
|
||||||
if(env->strings[i] == NULL) {
|
if(env->strings[i] == NULL) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/pl
|
#!/usr/bin/pl
|
||||||
(def repl (fn (_) (
|
(def repl (fn () (
|
||||||
(prn "pebblisp::> ")
|
(prn "pebblisp::> ")
|
||||||
(def input (inp 0))
|
(def input (inp))
|
||||||
(if (= input "q") () (
|
(if (= input "q") () (
|
||||||
(prnl (eval input))
|
(prnl (eval input))
|
||||||
(repl 0)))
|
(repl)))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(repl 0)
|
(repl)
|
||||||
|
|
|
@ -162,6 +162,10 @@ Object listEvalFunc(
|
||||||
const int length,
|
const int length,
|
||||||
struct Environment *env)
|
struct Environment *env)
|
||||||
{
|
{
|
||||||
|
if(length == 0) {
|
||||||
|
return function->func(boolObject(0), boolObject(0), env);
|
||||||
|
}
|
||||||
|
|
||||||
Object rest[length];
|
Object rest[length];
|
||||||
evalForms(rest, list->list->forward, env);
|
evalForms(rest, list->list->forward, env);
|
||||||
|
|
||||||
|
@ -244,13 +248,6 @@ Object evalList(const Object *obj, struct Environment *env)
|
||||||
return cloneObject(*obj);
|
return cloneObject(*obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(evalLength == 1) {
|
|
||||||
if(listLength(obj->list) == 0) {
|
|
||||||
return cloneObject(*obj);
|
|
||||||
}
|
|
||||||
return startList(eval(obj->list, env));
|
|
||||||
}
|
|
||||||
|
|
||||||
Object *first_form = obj->list;
|
Object *first_form = obj->list;
|
||||||
|
|
||||||
{ // Try to eval built-ins
|
{ // Try to eval built-ins
|
||||||
|
|
Loading…
Reference in New Issue