Comment

Comment by eqvinox

In my personal experience, "a bit more than a pointer" works best as a pair of (start, end) pointers (where "end" points to just beyond the last element.) The most obvious reasons for this are:

- slices become a total non-issue since a pair of (start, end) already is a slice and you can just move start and end.

- comparing against an end pointer is generally easier than adding up a length value first, particularly if you're slicing at the same time.

- the end pointer value is independent of the array element type, so if you e.g. cast to uint8_t * (which arguably you shouldn't in most cases) it stays exactly the same. If you store a count you need to adjust a multiplier. If you store a byte length, you need to do a lot of divides or casts to deal with pointer arithmetics.

Also, this is a huge red flag to me:

https://github.com/orangeduck/Cello/blob/master/include/Cell...

  #define is ==
  #define isnt !=
  #define not !
  #define and &&
  #define or ||
  #define in ,

P.S.: This also is a "try to invent a new programming language without inventing a new programming language" thing. Have your cake and eat it... either it's C or it isn't, and this library is leaving the space of "normal" C.
parent eqvinox 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton