a3f278 No.1624
Currently learning Sepples, and I'm genuinely curious about how pointers are used in a general basis. What are some situations where pointers would make your life easier, or save your ass or time? So far, I've only seen how useful it can be for iterating through shit like arrays and cstrings…
ba4b36 No.1626
>>1624For building abstract data structures.
Also, for when passing the data is too expensive, but you really need to use a profiler and a CPU cache simulator in that case to make sure it's worth it.
5c95be No.1631
>>1626OP here, I think I see what you mean, if I was working with or targeting a potato or working with embedded shit controlling everything 'by hand' would be that tiny bit more efficient… That's pretty cool, actually.
4255ff No.1637
>>1631> if I was working with or targeting a potato or working with embedded shit controllingActually, I thought of modern full scale computers, where memory access is expensive.
3bb39d No.1668
>>1631> if I was working with or targeting a potato or working with embedded shit You disgust me,i bet you think tech startups are the coolest thing you fucking yuppie.
a3f278 No.1673
>>1637Oh I see, I guess I misunderstood what you were saying. Excuse my ignorance, I'm still reading babbys first c++ books.
>>1668y-you too 29652d No.1724
>>1624Linked list
You have a pointer to the next element
0bce2f No.1747
Anything that requires indirection. That recursive data type? You're going to use pointers. Want to modify this stack allocated variable in this function? You're going to use pointers internally.
c4abfd No.1768
How about a linked list?
Function pointers, maybe?
Flyweights?
Basically everywhere that a "reference type" in managed languages are useful, plus some more.
b33ed6 No.1992
It's like references that you have in your everyday language, but on steroids.
df33de No.1998
>>1626Since we're talking about data structures, how about structs? Can I be sure that the order of the elements in memory reflect how they are arranged in code? Could I malloc a variety of structs of varying sizes, but keep a common type on top (say, a char*) and then use that as a header?
b8145a No.2000
>>1998I think so, yes. That is what gobject uses
802746 No.2002
b768ae No.2044
Deletions in Linked Lists and Trees are a lot prettier if you can read pointer.
4d7663 No.2098
>>1624Most common use is a more convenient way to generate SIGSEGV than kill(2)
a36148 No.2401
>>2098
int die() { return *(int *)0; }