If you do, just remember that everything after that while loop won't happen until the pointer is valid.
function main might actually be a bad spot for such a loop, another alternative would be to just use "wait()"
or if you want to be absolutely sure, another way would be
function move_ahead()
{
if(!robot) return;
robot.x += 5;
}
Which terminates the function if robot is invalid, ergo no missing pointer.