Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treatment of machine integers (esp. in Python version) #133

Open
AndrewTolmach opened this issue Sep 22, 2022 · 1 comment
Open

Treatment of machine integers (esp. in Python version) #133

AndrewTolmach opened this issue Sep 22, 2022 · 1 comment

Comments

@AndrewTolmach
Copy link

AndrewTolmach commented Sep 22, 2022

p. 3 para -1 says that an $int$ in $\mathcal{L}_{int}$ is a 63-bit signed integer.

  • In fact, AFAICT all the assembly code generated prior to Ch. 10 assumes 64-bit signed integers.

  • Python actually does not parse a leading '-' as part of an integer (it parses as a unary negation even if there is no separating space), so in the concrete syntax of $\mathcal{L}_{int}$ , $int$ should really be a positive integer only. (I guess after, e.g., partial evaluation, we need the abstract syntax to be able to store a signed int.) This is a small point, but may confuse students.

  • More seriously, none of the support code (quoted in the book or otherwise) actually performs machine arithmetic (modulo $2^{64}$) on the source language or in the X86 interpreter. This really undercuts the nice diagram (1.8)! At the very least, this deviation deserves a footnote of explanation. I also have patches that provide a small set of utility routines for doing machine arithmetic in Python and invoking them from the interpreters, checkers, and the input_int routine (which should clamp to machine range in order to match the behavior of scanf in runtime.c).

@jsiek
Copy link
Collaborator

jsiek commented Sep 23, 2022

The patch for doing machine arithmetic in Python would be much appreciated! Could you do a pull request with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants