You need to initialize v to nil so that it exists. The with binding creates a v that can be set. But you're right, there doesn't seem to be a reason you need the gensym.
The problem is that if you define it this way, then your v is no longer lexical; instead, it's in the global namespace. Thus, writing (for ref 0 n (frob ref)) would overwrite the global ref procedure, which is not what you want.