News for hackers. Stuff that matters.
Re:Tell HN: C Experts Panel – Ask us anything about C by benibela on Wednesday April 15, 2020 @10:18AM (#22877958)
Why not typedef struct {uint8_t *data, dataend} ?

Makes it easier to take subranges out of it

Re:Tell HN: C Experts Panel – Ask us anything about C by orenht on Wednesday April 15, 2020 @10:34AM (#22878176)
should be

  typedef struct {uint8_t *data, *dataend} 
if I'm not mistaken :)
Re:Tell HN: C Experts Panel – Ask us anything about C by gkfasdfasdf on Wednesday April 15, 2020 @11:07AM (#22878570)
What are the advantages of saving the end as a pointer? Genuinely curious. Seems like a length allows the end pointer to be quickly calculated (data + len), while being more useful for comparisons, etc.
Re:Tell HN: C Experts Panel – Ask us anything about C by benibela on Wednesday April 15, 2020 @03:32PM (#22882007)
You can remove the first k elements of a view with data += k.

With the length you would need to do data += k; length -= k

Especially if you want to use it as safe iterator, you can do data++ in a loop

Re:Tell HN: C Experts Panel – Ask us anything about C by zoomablemind on Thursday April 16, 2020 @05:33PM (#22893804)
> ...You can remove the first k elements of a view with data += k.

How would you safely free(data) afterwards? You'd need to keep an alloc'ed pointer somehow.

Re:Tell HN: C Experts Panel – Ask us anything about C by gkfasdfasdf on Thursday April 16, 2020 @09:09AM (#22888954)
Got it. That is really neat, going to add to my bag of tricks...
Re:Tell HN: C Experts Panel – Ask us anything about C by benibela on Wednesday April 15, 2020 @06:03PM (#22883630)
Right. I always think the pointer declaration is part of the type. (that is why I do not use C. Is there really a good reason for this C syntax?)