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

Support for binary, octal and hexadecimal integer literals #71

Open
kevinramharak opened this issue Aug 24, 2020 · 3 comments
Open

Support for binary, octal and hexadecimal integer literals #71

kevinramharak opened this issue Aug 24, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@kevinramharak
Copy link
Contributor

It would be nice to support the following integer literals:

let binary = 0b0110;
let octal = 0o777;
let hex = 0xdead;

I think forcing the b, o and x to be lower case would be a good idea. Taken from Rust.

@adam-mcdaniel
Copy link
Owner

How would these be represented in the backend? Until we support using integers or characters as the de-facto representation of data on the memory tape, I think that we cant use hex, octal, or binary in a meaningful way. I would like to implement memory as an array of characters, but that would definitely require several more machine code instructions. I don't think that's necessarily a bad thing, though.

@adam-mcdaniel
Copy link
Owner

How do you think we should make the change from doubles to bytes in memory? I think that we should just introduce push_double, push_int, push_byte, pop_double, pop_int, pop_byte functions where they pop different sizes of memory off of the stack.

@kevinramharak
Copy link
Contributor Author

Ah right, I didn't think about float representation since im limited to 16 bit wide integers in my implementation. I think having different data types would be a good idea as a tape of floats is very limiting. Having different push/pop functions should be a good start but that would require a definition on how operations on mixed data types would work. Or how they are forbidden. And ofcourse how a cast should be implemented.
I would prefer names like i32 over int as it would be easier to infer the width of the data type, but that is just a suggestion.

@adam-mcdaniel adam-mcdaniel added the enhancement New feature or request label Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants