orangeduck / BuildYourOwnLisp

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

Function defintions #166

Closed lewismj closed 2 years ago

lewismj commented 2 years ago

Hi, Not sure if I'm doing something wrong, but was following this project through (just bought the book), but I get this when trying to define functions (see below), always 'Unbound Symbol' ... any ideas?

Lispy Version 0.0.0.0.7 Press Ctrl+c to Exit

lispy> def {add-together} (\ {x y} {+ x y})
Error: Unbound Symbol '\'
lispy> def {add-together} (\\ {x y} {+ x y})
Error: Unbound Symbol '\\'
lewismj commented 2 years ago

I resolved the above issue by compiling the last version in 'strings.c' , it may be my Mac/editline version, But does the input processing need to change, so that we can have multi-line input, e.g. If I just cut-paste:

(fun {do & l} {
  if (== l nil)
    {nil}
    {last l}
})

I get errors, but not if, I push onto one line.

orangeduck commented 2 years ago

Yes the prompt only works when you input everything on one line.