s-expressions / pose

Portable S-expressions (POSE) spec and libs
29 stars 3 forks source link

Treacherous escapes #21

Open lassik opened 11 months ago

lassik commented 11 months ago

I don't recall whether we made a deliberated decision about string escapes.

I think that either Pose should support the usual escapes like \n and \t, or reading those escape sequences should raise an exception.

It's treacherous if someone writes a newline as \n (using a non-Pose S-expression writer, such as the one built into every Lisp implementation) and it is read by a Pose reader as if it were the letter n.

johnwcowan commented 11 months ago

I agree that unknown escapes should be errors, but I would rather not provide escapes other than \\ and \".

lassik commented 11 months ago

That's a good call, given that in Common Lisp "test\n" is read as "testn" and "test\t" is read as "testt".

lassik commented 11 months ago

Specifically, CLHS section 2.4.5 says:

If a single escape character is seen, the single escape character is discarded, the next character is accumulated, and accumulation continues.

The standard "single escape character" is backslash, so CL has no special backslash escapes.

johnwcowan commented 11 months ago

R5RS treats other escapes as having unspecified meaning.