AlexNisnevich / ECMAchine

Lisp-based in-browser toy operating system
http://alex.nisnevich.com/ecmachine/
201 stars 14 forks source link

Return value from + when concatenating strings not a string? #12

Closed davep closed 12 years ago

davep commented 12 years ago

Mostly the reply displays a string return value as a string just fine. For example:

ecmachine:/ guest$ "Hello"
"Hello"
ecmachine:/ guest$ (car (cons "Hello" "World"))
"Hello"
ecmachine:/ guest$ ((lambda () "Hello"))
"Hello"

but when using + (which I notice has been extended to allow concatenation of strings) the result isn't shown as a string. If almost looks as if it's been turned into a symbol:

ecmachine:/ guest$ (+ "Hello")
Hello
ecmachine:/ guest$ (cons (+ "Hello") "World")
(Hello . "World")
ecmachine:/ guest$ (car (cons (+ "Hello") "World"))
Hello
AlexNisnevich commented 12 years ago

This is a tricky one, because I need special cases for strings and quoted literals (as both are treated as strings internally).

Does it work now?

davep commented 12 years ago

Looks good now:

ecmachine:/ guest$ (+ "Hello")
"Hello"