marcomaggi / vicare

A native compiler for Scheme compliant with R6RS
http://marcomaggi.github.com/vicare.html
Other
200 stars 34 forks source link

Should `+o` as an accpeted identifier? #68

Closed ustcscgy closed 10 years ago

ustcscgy commented 10 years ago

I am asking this because in https://github.com/miniKanren/TheReasonedSchemer/blob/master/mkprelude.scm#L162 causes an error in vicare:

vicare> (load "mkprelude.scm")
Unhandled exception
 Condition components:
   1. &lexical
   2. &i/o-read
   3. &message: "invalid sequence of characters while parsing numeric lexeme"
   4. &irritants: ("+o")
   5. &source-position:
       port-id: "mkprelude.scm"
       byte: 3424
       character: 3424
       line: 162
       column: 9

In R6RS section 4.2.4 Identifiers, it seems that +o is illegal because + is not <initial> but <peculiar identifier> ; on the other hand, mit-scheme, guile, petite supports +o as identifier.

I hope vicare regard +o as identifier; should this be fixed?

marcomaggi commented 10 years ago

Yes, +o is an illegal identifier. The basic idea of the R6RS reader is that after reading the single next character, we know the category of the token we are composing; after reading +, - or a character in the range [0-9]: we know that we are reading a number. This basic idea is extended with special cases; after reading a #, we know that we have to look at the further next character to know the category.

When running Vicare's reader in #!vicare mode there are other special cases, but, right now, I am not eager to introduce the full generalisation; rather, Vicare's special cases might go away in the future.

Most of the times, it is very easy to port R5RS code to R6RS (I did it, I know); if the problem is the presence of non-R6RS identifiers, it can be done in minutes. So I will not do this change for now.