Skip to content

Sized and (un)signed integer types #46

@RobertBendun

Description

@RobertBendun

Removes ptr

Introduces

  • New types
    • Unsigned: u8, u16, u32, u64, usize
    • Signed: i8, i16, i32, i64, isize
    • Pointers: written with * before type, for example: *u32
  • Typed integer literals (like 1u64, 0xdead_i32)

usize and isize are type aliases for type that matches their bit length. For example isize == i64 <=> sizeof(isize == i64)

Memory declarations produce pointers with correct type. For Foo 1 []u32 holds typeof(Foo) == u32

Conversion from smaller type to bigger type is implicit given their both (un)signed. (Not sure about this, time will tell)

Pointers

Addition, subtraction, load, store have different meaning according to what pointer is pointing to.
For example: *i32 + u64 is val(*i32) + 4 * val(u64) (same as C)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions