Dear Daniel, I already finished course, but I still have no idea what response s...

George Chow Answered 5 answers
Question by George Chow 2 years ago

Question

Dear Daniel, I already finished course, but I still have no idea what response system does, can you tell me more details about response system and give me an example which can make it work?

Answers

Answered by Daniel McCarthy

Instructor

Hello,
Its a good question, simply put when you call a function and pass arguments they get passed down the stack however it would be tedious for us to keep having to pass down data to subfunction after subfunction when the data can be so different, imagine struggling to do that, do we pass an integer down the stack or a structure of some kind. Then comes the issue of what if someone has passed us some data and we want to change it, how are we to pass the changes back up the stack, we could rely on a function return type but what if theirs many possibilities. As you can see things get complicated. The solution is the response system, we can have functions insert responses that can be popped further up the call stack this eliminates the messy code that would await us if we did not provide this type of abstraction. So in short its a way of us passing information back up the stack. The enums you saw in the video are a way for the person popping from the stack to understand the type of information that was pushed

Follow-up by George Chow

Question author

Thank you for your reply, I understood a little bit more after your explaining, I have tried writing several samples, but they could not make it work, can you give me a valid sample for debugging?

Answered by Daniel McCarthy

Instructor

Hi George im not sure what you mean by trying several samples. Debugging with gdb can be useful setting break points and stepping through your project.

Follow-up by George Chow

Question author

Dear Daniel, I am so sorry about my poor English, I meant C code samples which can make response system functions called, so I can step through the project and figure out how the response system functions work.

Answered by Daniel McCarthy

Instructor

Ahh I understand, we dont have any unit tests or such things in that regard, I do recommend still using the debugger to assist with this as you can step through