pointers and I just wonder why. It’s like the least ergonomic language feature I think I’ve ever seen, and never once have I seen them used without it feeling like a super alien kludge. I’d use flag bit packing bullshit too if function pointers were the option I had for injecting one function into another.
And like they’re this obnoxious to use and yet they have to be a designed feature right? It’s not obvious that you should be able to address a function, and there’s specific syntax for it, so someone must have sat down at some point and said “yes, this is how function pointers should work”
Why is it unergonomic? And why is it unobvious that functions should be addressable
callbacks ig?
i understand the hate for asterisks, assembly uses square brackets for pointers and honestly its way easier to comprehend visually at first
im not a c dev but i think that's the only way to use callbacks, right?
Well a callback must be passed as an argument
I can It's the only runtime way anyway
The syntax is p funky imo, I mean you need something but why the extra parens? Why the asterisk on the identifier and not after the arg list? That’s mostly a taste thing but it does feel kludgy compared most the rest of the language and it’s something I always have to look up. More substantially, you can’t dereference a function pointer and expect anything meaningful to result, so the most fundamental operation of a pointer is basically unused. Pointer arithmetic doesn’t really work either, since depending on architecture a function pointer is not necessarily in the same address space as data. So I guess my complaint is that a function pointer is basically not a pointer, imo defining an opaque func_t or something and an apply function or built in would have been preferable
You'd love learning about execution tokens in Forth
Syntax stuff I was expecting, but the pointer operation stuff makes sense too
I guess you could have a separate "function address" type entirely
Обсуждают сегодня