Name: Anonymous 2013-08-27 21:22
((let ((a 1)) (lambda () a)))
gives a is undefined
although (let ((a 1)) a) gives 1
what am I doing wrong?
gives a is undefined
although (let ((a 1)) a) gives 1
what am I doing wrong?
else if (parseqs(y.list[0],"let")){//fun stuff! you eval each name-expression pair in order, and later expressions might depend on earlier vars
struct parsable s = y.list[1];
cout << "let1\n";
if (s.type != 1){
cout << "let: expected list of names and expressions, but got type " << s.type << "\n";
exit (EXIT_FAILURE);
}
cout << "let2\n";
struct Environment * e2 = createEnvironment(e,std::vector<std::string>(),std::vector<struct something>());
cout << "let3\n";
int i;
int size = s.list.size();
cout << "let4\n";
for (i=0;i<size;i++){
cout << "let5\n";
struct parsable s2 = s.list[i];
if (s2.type != 1){
cout << "let: expected pair of name and expression, but got type " << s2.type << "\n";
exit (EXIT_FAILURE);
}
if (s2.list[0].type==0){
e2->env[s2.list[0].string] = eval(s2.list[1],e2); //like I said, it can depend on other vars in the list
} else {
cout << "let: expected valid var name but got type " << s2.list[0].type << "\n";
exit (EXIT_FAILURE);
}
}
cout << "let6\n";
return eval(y.list[2],e2);
}