fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

lib: use unsigned int where we do not need negative values.

Open michaellilltokiwa opened this issue 1 year ago • 1 comments

just one example but there are many examples in the base library:

module internal_array(T type, module data fuzion.sys.Pointer, module length i32) is

  module index [ ] (i i32) T
    pre
      safety: 0 ≤ i < length
  =>
    get T data i

  module set [ ] (i i32, o T) unit
    pre
      safety: 0 ≤ i < length

could just be:

module internal_array(T type, module data fuzion.sys.Pointer, module length u32) is

  module index [ ] (i u32) T
  =>
    get T data i

  module set [ ] (i u32, o T) unit

michaellilltokiwa avatar Apr 29 '24 13:04 michaellilltokiwa

I just looked into this, there do not seem to be any examples of this that do not relate to arrays in some way.

And I was told by @michaellilltokiwa that we might not want to switch over arrays to unsigned integers due to problems with type inference and the issue of count - 1 leading to -1 in the case of count being 0.

maxteufel avatar May 15 '24 11:05 maxteufel