Torstein Winterseth <[email protected]> writes: > Hello, > > I have found a bug where Guile does not handle escaped open > parentheses correctly. This was found in a real program which works in > Dr. Racket in R5RS mode. You are not the only interpreter on Fedora 15 > which fails this, but anyhow. > > Testcase: > > (define bug > '(\()) > > Expected results: > No errors. bug variable should now be bound to the list ((). > > Actual result: > [torstein@Desktor Skrivebord]$ guile -l testcase.scm --no-auto-compile > ERROR: In procedure primitive-load: > ERROR: In procedure scm_i_lreadparen: > /home/torstein/Skrivebord/testcase.scm:3:12: end of file > > In the actual program the list was larger, '(\{ \[ \(), and then the error > was: > ERROR: In procedure primitive-load: > ERROR: In procedure scm_read_expression: > /home/torstein/Skrivebord/testcase.scm:2:27: unexpected ")"
Whether or not this is a bug, I cannot say, but I would like to point out that neither the R5RS nor the R6RS consider '\( to be a valid symbol. I shan't quote the grammars here, but you can confirm this for yourself. http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-10.html#%_sec_7.1.2 http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-7.html#node_sec_4.3.1 Specifically, in the R5RS, \ is not an initial (a letter or a special initial), nor a peculiar identifier. In the R6RS, it is not an initial (a constituent, a special initial, or an inline hex escape) nor a peculiar identifier. Handling additional identifiers is done in different ways in different Scheme implementations. '|(| is pretty common, but in guile you would use '#{(}#. If you want portable R5RS though, you should use (string->symbol "(")). If you choose R6RS, you can also use hex escapes, in this case '\x28; Also, apologies for the double send, but I forgot to include the mailing list. Hope that helps, Ian
