Menu

#42 Inexact integers permitted as indices

Future
closed
nobody
None
9
2020-05-30
2014-12-27
saulgoode
No

R5RS states that all indices (e.g., in vector-ref, vector-set!, list-ref) must be exact integers. In contravention to the spec, TinyScheme permits an inexact integer to be used as an index.

For example,

(vector-ref #(1 2 3 4 5) (exact->inexact 3))

In practice, TinyScheme's behavior causes no problems and it is extremely unlikely that such a situation would ever be encountered (why would one ever want to coerce an exact integer to be inexact?). Nonetheless, I figured it would be worth mentioning this minor deviation from the specification.

[1] R5RS 6.2.3 Implementation restrictions -- "... it is an error to use anything but an exact integer as an index."

Discussion

  • Kevin Cozens

    Kevin Cozens - 2020-05-30

    Thanks for the report, Saul. I added checks for exact indexes to string-ref, string-set!, vector-ref, and vector-set!. I can't change list-ref as that is implemented in Scheme in the init.scm file.

    Fixed in revision 117 (2020-05-29 22:56:11).

     
  • Kevin Cozens

    Kevin Cozens - 2020-05-30
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB