The consequences of shifting into reverse while driving will depend on whether the vehicle has an automatic or manual gearbox. If you have a newer car with an automatic transmission, putting the gearshift lever into reverse (R) while driving will do nothing but turn on the backing camera and disengage the gearbox from the engine like it's in N or neutral. And since the transmission is acting like it's in neutral, pushing the throttle pedal or revving the engine will not affect forward motion.
If you expect the gearbox to shatter in smithereens when forcefully shifting from drive (D) to reverse (R), the reverse inhibitor prevents that. Automakers know that people could do some dumb things with their cars, so they thought ahead and installed a feature that prevents the gearbox from shifting into reverse gear when the car is moving forward.
What happens is shifting from D to R while moving disengages the gearbox until the vehicle slows down to a crawl (less than five mph) before connecting the reverse gear, precisely the reason why automakers recommend shifting into drive or reverse only when the vehicle is at a stop or when the wheels are not moving. But for vehicles without reverse inhibitors, shifting into reverse while driving will most likely stall the engine.
What happens if I shift to reverse while moving forward in a manual car?
It's typically a similar story in a manual-equipped car. Manual gearboxes have locks in the shift mechanism that bar the stick from entering reverse gear when moving forward. It means it'll take some muscle to jam the reverse gear forcefully into the gates. And when it does engage, it won't do anything but lock up the driving wheels (when moving at higher speeds) and put undue strain on the synchronizer, a component that matches the speed of the main shaft to the driving gears and enables smoother, more precise shifts.
Even in a hurry, it's good practice to shift to reverse or drive when the vehicle is at a stop. If your car has a manual, stop before pressing the clutch and shifting into reverse. If you accidentally shift to reverse (R) when in drive (D), don't panic. Steer towards the side of the road and apply the brakes gently until the vehicle stops. Next, move the gearshift lever into neutral (N), then park (P) before moving back to drive (D).
If the engine stalls after unintentionally shifting into reverse from drive, the vehicle will lose power and vacuum assistance to the steering and brakes, making it doubly hard to steer and stop the car. The lesson is to avoid shifting into reverse when the vehicle is in forward gear, especially in older vehicles with an automatic or manual gearbox.