Question: Why are the sizes or lengths of the string and Builder procedures data type all received and returned as Int's? #2736
Replies: 4 comments
-
Hello, len() returns a Int, this is a major flaw in the design of Odin! As in a 32bit's now and in a 64 bit's in same (many) years, you are not able to create an array of bytes with the max size of your memory. The example that is easy to think about is for a 32 bits CPU architecture, the fact that you can only create a array or buffer of 2GB Max when with a size_t in C ou C++ you could allocate one with 4 GB. From the documentation: len len :: proc(v: Array_Type) -> int {…} The len built-in procedure returns the length of v according to its type: Array: the number of elements in v. For some arguments, such as a string literal or a simple array expression, the result can be constant. Best regards, |
Beta Was this translation helpful? Give feedback.
-
From what I understand, |
Beta Was this translation helpful? Give feedback.
-
Like with what Beefster09 said, |
Beta Was this translation helpful? Give feedback.
-
Hello, Once again thank you for the response, Best regards, |
Beta Was this translation helpful? Give feedback.
-
Hello,
Question: Why are the sizes or lengths of the string and Builder procedures data type all received and returned as Int's?
They can never be a negative value, right?
I really think that it should be the max addressable size of a unsigned register for the platform memory, (ex: 4 GB for a 32 bit's architecture and not 2 GB), that mean something like a usize in Rust.
Right?
This allows to easily find many bugs in Rust and to use the types to help you. And doesn't limit the max size that can be used by halving it.
Example:
Thank you,
Best regards,
João Carvalho
Beta Was this translation helpful? Give feedback.
All reactions