Author Topic: Readability of keywords "uint32", "float64" etc  (Read 311 times)

acbaile

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Readability of keywords "uint32", "float64" etc
« Reply #15 on: November 12, 2018, 10:55:26 PM »
For code like this, having a usize/isize is a real requirement.

Too much [ice] in word "size". Let's find something better. Maybe, native? unative, inative, uint_native, int_native...
« Last Edit: November 17, 2018, 02:18:40 AM by acbaile »

acbaile

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Readability of keywords "uint32", "float64" etc
« Reply #16 on: November 15, 2018, 05:38:34 AM »
It's common to store pointers in numbers. Code like that often keeps track of the meaning of the value. It could be a real number or a pointer.
For code like this, having a usize/isize is a real requirement.

Maybe, types with names "uint" and "int" ? With clear rules for defining their sizes. For example: these types always have size of common/address registers for target platform.

So, it will be set of types: int8, uint8, int16, uint16, int32, uint32, int64, uint64, int, uint.

int, uint are last in set with recommendation to use its only when necessary (of course, because of uncertain size) - pointers, sizes of buffers etc.
« Last Edit: November 15, 2018, 10:01:58 AM by acbaile »

acbaile

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Readability of keywords "uint32", "float64" etc
« Reply #17 on: November 17, 2018, 02:14:02 AM »
For code like this, having a usize/isize is a real requirement.

    Maybe, regint and reguint? register's int. First feelings are good. Speaking names. I will test them.

    Programmer will read these names and understand just-in-place that these types have undefined size, have size of registers for target platform.

    I tried rint, it looks good, but i can not create name for unsigned. I can not take urint - because it's close to [urined], from urine. I can not take ruint - because it's close to [ruined] from ruine. So, i took regint and reguint.
« Last Edit: November 18, 2018, 02:29:54 AM by acbaile »

lerno

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Readability of keywords "uint32", "float64" etc
« Reply #18 on: November 17, 2018, 01:59:04 PM »
I would have prefered using the well known Java convention of:

byte = i8
short = i16
int = i32
long = i64
float = f32
double = f64

Then extend to unsigned:

char = u8
ushort = u16
uint = u32
ulong = u64

However, if we want to support: i/u24 i/u48, f128 then that naming scheme is better. I prefer shorter if numbers are added. For the real horror example: NSUInteger of Objective-C on mac. That one is 32 bits or 64 depending on architecture. Aside from the obvious problem of 32/64 bit, the real pain is writing 4 uppercase followed by lower case. Hard to type as well as overly long.

acbaile

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Readability of keywords "uint32", "float64" etc
« Reply #19 on: November 20, 2018, 02:28:35 PM »
    No, reguint feels no good... )

    In testing of intreg, uintreg. Naming scheme is the same with uint32 - reg instead of 32.
« Last Edit: November 22, 2018, 08:57:35 PM by acbaile »

acbaile

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Readability of keywords "uint32", "float64" etc
« Reply #20 on: November 20, 2018, 04:16:30 PM »
    uintreg looks organically:

        *********************************
        const uintreg buffer_length = 20;
        char buffer[buffer_length];

        uintreg length = strlen(str);
        *********************************

    Organically to type... On a place where i usually think "32", here i think "reg", and i know - this is register-size. Right idea appears.

    What do you think about formal definition of this type? Size of address registers? Or common registers? I used x86 and x64 only, so, my point of view is not wide.
« Last Edit: November 20, 2018, 04:26:12 PM by acbaile »