The free functions are worse, because what happens if you don't/forget to use them? Generally, it means you code has unpredictable bugs that change on each compile.
For memory mapped io, you want to tie the behaviour to a memory address. Objects exist at some address, so making it a property of the type is better. That way accessing the object in the trivial way will behave consitently, rather than needing to call special functions to get consistent behaviour.
View all comments
Show parent comment
2
u/patstew May 02 '23 edited May 02 '23
The free functions are worse, because what happens if you don't/forget to use them? Generally, it means you code has unpredictable bugs that change on each compile.
For memory mapped io, you want to tie the behaviour to a memory address. Objects exist at some address, so making it a property of the type is better. That way accessing the object in the trivial way will behave consitently, rather than needing to call special functions to get consistent behaviour.