News for hackers. Stuff that matters.
Re:To make programming easier, first be conscious of what ma... by grawprog on Friday August 13, 2021 @07:57PM (#28176344)
I find D's implementation of pointers not only to be fairly easy and straightforward to understand, but quite powerful and useful. They basically fix most of the problems with C's pointers.

https://www.tutorialspoint.com/d_programming/d_programming_p...

The toy virtual machine and language I built in D uses function pointers heavily to implement the machine's opcodes. They made it incredibly simple to program the 'CPU' of the virtual machine. The opcode functions are setup as an array of function pointers.

Whenever a byte that represents an opcode is read, it simply calls the function being pointed to at the corresponding index in the array. It allows for additional opcodes to be easily added without hassle or breaking things. Every other way I tried without pointers was convoluted and didn't work as expected. Using an array of function pointers just works.

There are no comments on this comment yet.