Forum OpenACS Development: Re: Do not use namespace qualification for PL/SQL variables

Tom, I didn't remember exactly conventions OpenACS has used before, but yes what you describe for p_* and v_* variables sounds excellent to me.

(At aD, I think the rest of the Muniversal team and I had written reams of custom PL/SQL in a similar style before most of the aD "core team" started using PL/SQL much at all. [grumble grumble])

If you occasionally need to use Oracle's namespace qualification feature on local variables, fine, that's what it's there for. But it would would much nicer to see it only where it's actually needed, not willy nilly all over the place in order to make the variable names as hard to read as possible.

That old style guide Dirk links to above seems awfully mis-guided on this relatively trivial point. Note that the authors seemed to confuse two unrelated things, they say: "Name parameters as simply as possible" and "To achieve this we must fully qualify arguements passed into procedures" - nonsense, the second statement does not follow from the first.

Personally it never bothered me at all to call PL/SQL functions with parameters named "p_foo" rather than "foo", but if you really hate that, that does not mean that your only other option is to use namespace qualification all over the place. Rather obviously, you can simply declare a "p_foo" or "v_foo" variables near the top of your function, and initialize "v_foo" to the passed in value of "foo". Not necessarily ideal, but for a long function, that is going to be much clearer than prefixing the variable with the function name dozens of times throughout the code.

Andrew, I agree, using the function name to qualify a local variable is a useless idea, an idea that is pretty much solved by appending p_ to every passed in parameter, or in pg, aliasing the same way. And every locally declared variable gets appended with v_. The place to be verbose, if at all, in a variable name is in the meat of the name, not in some prefix. Of course what is clear to me might be confusing to someone else. So the debate may continue.