# \`Slice(T)#size\` should be \`UInt64\`, \`UInt32\`, or \`LibC::PtrdiffT\`

**URL:** <https://forum.crystal-lang.org/t/slice-t-size-should-be-uint64-uint32-or-libc-ptrdifft/1972>\
**Category:** Crystal Contrib\
**Created:** [April 18, 2020, 6:13pm UTC](https://forum.crystal-lang.org/t/slice-t-size-should-be-uint64-uint32-or-libc-ptrdifft/1972 "2020-04-18T18:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/scott/32/948_2.png) [@scott](https://forum.crystal-lang.org/u/scott)\
**Post date:** [April 18, 2020, 6:13pm UTC](https://forum.crystal-lang.org/t/slice-t-size-should-be-uint64-uint32-or-libc-ptrdifft/1972/1 "2020-04-18T18:13:16Z")

</div>

It makes no sense for `#size` to be negative, so that should obviously be unsigned at the very least.

- For compatibility with the most platforms (and still an improvement of one bit over the current implementation), it could be a UInt32. This provides the least opportunity for compile or runtime bugs on any 32+ bit platform, at the expense of Slices being at most `1 << 31` items long.
- For compatibility with the most popular platforms and greater versatility on those platforms, it could be a UInt64. I don’t think this is the best idea because it could lead to weird bugs on 32 bit systems.
- For compatibility with the widest array of platforms and operating systems, `LibC::PtrdiffT` could be chosen. This could result in some occasional compile-time or runtime errors, but for most cases things would work smoothly.

I will gladly implement this and submit a PR, but I’d like some opinions on which option is the best for Crystal before I do.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [April 18, 2020, 6:49pm UTC](https://forum.crystal-lang.org/t/slice-t-size-should-be-uint64-uint32-or-libc-ptrdifft/1972/2 "2020-04-18T18:49:20Z")

</div>

There is already an open issue: [https://github.com/crystal-lang/crystal/issues/3209](https://github.com/crystal-lang/crystal/issues/3209)

Unfortunately, the topic is more complex than just changing to any UInt type. See previous discussion for details.
