Hacker News new | past | comments | ask | show | jobs | submit login

You don't need new runtime operators to retrieve the length. Once you remove the decay issue, you can use sizeof:

  sizeof(a)
  sizeof(a)/sizeof(a[0])



I get what you mean and I'm not saying that not having extra operators is a dealbreaker that will make spans unusable. I just find it more pleasant/convenient for the following reasons: 1. Helps clarify intent 2. Makes teaching the feature easier, since it's name is closer to what the user wants to write. Also, rejecting pointers helps people not make mistakes. 3. Keeps sizeof consistent. The operator sizeof is supposed to return the size of the storage occupied by the object. A span is a pointer and some sizes (one could also design a span to be strided, meaning more integers to the mix), so sizeof could just return the size of that pointer ond the integers. Having sizeof be somewhat overloaded for spans could be surprising to nome people. But again, just having sizeof is fine




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: