kanaka / mal

mal - Make a Lisp
Other
10.07k stars 2.55k forks source link

Newline Escaping #596

Closed cookrn closed 2 years ago

cookrn commented 2 years ago

I think there might be conflicting direction between step 1 (reader) and step 4 (if/fn/do) as it relates to basic newline escaping/unescaping in strings. I'm currently working through the tutorial in Ruby and worked on getting this test to pass in step 1:

https://github.com/kanaka/mal/blob/master/impls/tests/step1_read_print.mal#L248-L249

"\n"
;=>"\n"

Then, in step 4, related to #289, the test is as follows:

https://github.com/kanaka/mal/blob/master/impls/tests/step4_if_fn_do.mal#L298-L299

"\\n"
;=>"\\n"

I find the two different tests a bit conflicting, but maybe I'm not understanding. My implementation treats the step 4 test as an error with an invalid use of \ chars. It is the only test failing out of steps 0/1/2/3/4.

Is the step 1 test detecting whether a raw newline can be read and then printed back? Then, the test in step 4 is checking whether an escaped newline is NOT read in as a raw newline and instead behaves as escaped? Thanks in advance for any insight to this issue.

As an aside, I've found the tutorial really well done and have enjoyed working through it. Great job!

cookrn commented 2 years ago

I think after looking again/further, this is based on a misunderstanding on my part. I'll review and compare with the existing Ruby implementation. Thanks again for the great project!