Difference Between pros::delay() and pros::Task::delay()

Hello everyone,

What is the difference between pros::delay() and pros::Task::delay()? I looked in the pros 3 api documentation, but I could only find an explanation for pros::Task::delay(). I’ve always used pros::delay() for everything, but I’ve never known the difference.

Thank you.

They both work the same, from looking through the pros code it looks like the both just run the same function internally.

1 Like

Thank you for your reply, but why are there two functions if they accomplish the same task?
Also, I tried to post this question under the “PROS Support” category, but the option wasn’t available, and when I tried to create a new topic directly from that category, it said that I’m not allowed to create topics under that category. Could someone please explain why this is?

While I may not know all of the details of each function, I know that Task::delay() is used within a Task in Pros. This allows you to delay inside the task without delaying the entire program. I believe delay() on the other hand delays the entire program. That’s a very rough explanation, but I think that’s the basic idea of why there are two functions for delaying. I would say most use cases will just require delay().

Just to clarify for anyone reading this in the future.

They are the same, PROS has had quite a long development cycle and has evolved over the years. The C++ class Task was added at some point and had the new delay() member function, pros::delay() was kept presumably for backwards compatibility with existing code.

5 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.