orangeduck / BuildYourOwnLisp

Learn C and build your own programming language in under 1000 lines of code!
http://www.buildyourownlisp.com/
Other
2.93k stars 396 forks source link

In chapter 9, some code may be unneeded #112

Closed akshat-harit closed 7 years ago

akshat-harit commented 7 years ago

I am following the book(great resource!), and in chapter 9, in function lval_read, I think the lines if (strcmp(t->children[i]->contents, "}") == 0) { continue; } if (strcmp(t->children[i]->contents, "{") == 0) { continue; }

are from the following chapter on q-expr. Till now "{" or "}" are not in the language defined by the parser.

Also, I am not sure about the "regex" in the following line, as it also isn't defined. I assume these lines will never be executed, so don't really cause a problem, but are somewhat confusing.

In the git repo, these lines will be from https://github.com/orangeduck/BuildYourOwnLisp/blob/master/chapter9_s_expressions.html#L270

Same change on the source code at https://github.com/orangeduck/BuildYourOwnLisp/blob/master/src/s_expressions.c#L261 as well. I think a patch would be just removing these lines? I can submit a pull request, if this seems correct.

orangeduck commented 7 years ago

Yeah good find I think removing those lines makes sense 👍