Steve Fink <[EMAIL PROTECTED]> writes:

> I would very much hate to see the prefixes go away or merge into a
> single one, but I'm not so sure I agree with Russ. I've had to teach
> lots of beginners that even though $x refers to scalar x, $x{...} refers
> to %x, but don't think of it that way because the $ is saying what value
> you're getting back, not which variable you're using, unless you're
> calling a function, or...

This falls firmly in the category of things that are powerful for
experienced users of the language but may be somewhat difficult to learn.
I don't think Perl has being easy to learn as it's primary goal, nor
should it.

> I'll just say I wouldn't mind having a stricture forbidding $x and %x in
> the same package.

Ugh.  I'll definitely never use it.  I don't object *provided* that it
doesn't become like the other strictures, things that people expect all
Perl scripts to use; I think it's an essentially worthless constraint.

> I've fairly frequently used code like the above, but I don't really like
> that code in the first place because the only purpose for the $args and
> @args is as temporaries. I like the way mjd describes it:  this is
> "synthetic" code. If you really did have distinct long-lived variables
> with the same name, then I bet it would be confusing.

I do this all the time and I don't find it confusing.  Please let's not
mandate programming style.  Often times the difference between the
variables changes some as the program proceeds, but context makes it quite
clear what's going on.

This strikes me as the same sort of meaningless style guideline as "all
variables must have names that are at least five characters long."

-- 
Russ Allbery ([EMAIL PROTECTED])             <http://www.eyrie.org/~eagle/>

Reply via email to