Re: [Scheme-reports] r7rs-draft-6: identifiers looking as numbers Ray Dillinger (14 May 2012 00:29 UTC)

Re: [Scheme-reports] r7rs-draft-6: identifiers looking as numbers Ray Dillinger 14 May 2012 00:28 UTC

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/13/2012 03:16 PM, John Cowan wrote:
> Ray Dillinger scripsit:

>> My own parser uses a rule that identifiers cannot *both* begin
>> with a sign, digit or decimal point, *and* end with a digit or
>> decimal point.  This is on the assumption anything which does
>> both begin and end with such a character is syntax that I may
>> eventually want to use for some kind of number.

> That doesn't work in the general case because of the Scheme syntax
> for imaginary numbers: 2+3i begins with a digit but does not end
> with one.

The rule I mentioned *excludes* things from being identifiers.
Even things not excluded by that rule may be excluded by other
rules.  One of which is that things that parse as being numbers
are also excluded from being identifiers. Conversely, even things
that *would* be excluded by it are given a pass if they're on the
short list called "peculiar identifiers"

>> The standard has not historically forbidden such extensions to
>> identifier syntax.  I don't see a compelling reason why it
>> should do so now.

> R5RS defines an identifier thus:

> 1) The first character must be one of A-Z ! $ % & * / : < = > ? ^ _
> ~

> 2) Remaining characters may be any of those, or 0-9 + - . @

> 3) In addition, +, -, and ... are allowed as identifiers.

> Anything that doesn't fit these simple but restrictive rules or
> the precise grammar of numbers is a lexical syntax error.

R2RS, section I.1 Syntax, subsection Identifiers:

   The precise rules for forming identifiers vary among implementations
   of Scheme, but in all implementations a sequence of characters that
   contains no special characters and begins with a character that
   cannot begin a number is an identifier.  There may be other
   identifiers as well, and in particular the following are identifiers:

            +  -  1+  -1+

R3RS, section 2.1 identifiers:

   The precise rules for forming identifiers vary among
   implementations of Scheme, but in all implementations a
   sequence of letters, digits,    and "extended alphabetic
   characters" that begins with a character that cannot begin
   a number is an identifier. In addition, + and - (which can
   begin numbers) are identifiers.

all three of IEEE1178, R4RS and R5RS say in section 2.1 Identifiers:

   The precise rules for forming identifiers vary among implementations
   of Scheme, but in all implementations a sequence of letters, digits,
   and "extended alphabetic characters" that begins with a character
   that cannot begin a number is an identifier. In addition, +, -,
   and ... are identifiers.

"Vary among implementations" means to me that while implementations
are required "in all cases" to accept identifiers made according to
that rule, they are permitted (as R2RS says explicitly) to accept
other identifiers as well.

R6RS section 4,2,4:

   In general, a sequence of letters, digits, and “extended
   alphabetic characters” is an identifier when it begins with
   a character that cannot begin a representation of a number
   object. In addition, +, -, and ... are identifiers, as is a
   sequence of letters, digits, and extended alphabetic characters
   that begins with the two-character sequence ->.

R6 also defines an extended set of extended alphabetic
characters (including 19 categories of unicode characters)
relative to the other standards.

It appears to me that R6RS is the first and so far only standard
that has failed to explicitly permit extensions to identifier
syntax.

The formal syntax definitions have always outlined the most
restrictive allowed syntax, and have never specified the only
allowed syntax; the lack of something there does not mean
it's forbidden, only that it's not required.

				Bear

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPsFGWAAoJEAOzWkqOibfNFMsH/iaXvwxPqYLY0cZsZRkXWoFU
X9dsdJr1sIqm0bgzeoUO3FN7SVA23J30f8dZ7je9aP8iD1f9izeU2pnRrJdfRQVc
RShN93FJLSv82iMeYVHrMdXl/EIm77xKG96FLSU91HXorOy2GlhUeZXk2/4b7jUl
MtCCa/HRLKIXEfgr6f5PmFJiUrJn9OZYBzfWO683i5oIgfTeKRPt1wLGoWMjoTSj
zk5n20H/1csebmPTec7hi50nAPITjDduELsWH5YqFyXFZ6UcXVBIytsakpXWyv9Y
NxVZ538VwkGKkjiymeVMILYGSxA26ZVoJ96usEVPyDfZJxKfMLeJwJ8CD4orW2Q=
=/7+y
-----END PGP SIGNATURE-----

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports