corth-lang / Corth

A self-hosted stack based language like Forth
MIT License
7 stars 1 forks source link

All intrinsic integer types #50

Open HuseyinSimsek7904 opened 6 months ago

HuseyinSimsek7904 commented 6 months ago

Currently, the compiler only recognizes int intrinsic type. These should also be implemented:

int8    // 1 byte signed integer
uint8   // 1 byte unsigned integer
int16   // 2 byte signed integer
uint16  // 2 byte unsigned integer
int32   // 4 byte signed integer
uint32  // 4 byte unsigned integer
int64   // 8 byte signed integer
uint64  // 8 byte unsigned integer

We should also update the load intrinsics so that they push the correct size of integer after reading. Same applies to the store intrinsics as well.

Utkub24 commented 6 months ago

Agreed, sized types are cool! But how about

i8    // 1 byte signed integer
u8   // 1 byte unsigned integer
i16   // 2 byte signed integer
u16  // 2 byte unsigned integer
i32   // 4 byte signed integer
u32  // 4 byte unsigned integer
i64   // 8 byte signed integer
u64  // 8 byte unsigned integer
HuseyinSimsek7904 commented 6 months ago

I like these kinds of type notations which Rust also uses. But I also want to add some aliases for the i8, u8, i64 and u64 types; char, byte, int, uint.

Is this convention understandable @Utkub24, what do you think?

HuseyinSimsek7904 commented 6 months ago

These types will also require a new integer parsing system that allows postfixes to the integers like u, u16, i32, etc... For example 34u16 will push a 16-bit unsigned integer that has the value 34.

I am not very sure about the syntax tho.

Utkub24 commented 4 months ago

I like these kinds of type notations which Rust also uses. But I also want to add some aliases for the i8, u8, i64 and u64 types; char, byte, int, uint.

Is this convention understandable @Utkub24, what do you think?

Just pick one and be consistent imo, the user can define aliases for them if they so desire.

(use i16 notation)