Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^6: Pointers and References

by LanX (Cardinal)
on Nov 23, 2020 at 22:17 UTC ( #11124086=note: print w/replies, xml ) Need Help??


in reply to Re^5: Pointers and References
in thread Pointers and References

Your coding style is peculiar, probably C'ish? ;)

> our tells you something is "global" where you declare the variable, but it doesn't tell you that where you use it.

I have problems to follow. our $var creates a lexically scoped alias to a package variable $PKG::var whith PKG for the current __PACKAGE__ . If you are afraid to loose count "where you use it" just limit the scope, much the same way you do with private vars declared with my.

> of a g prefix is an immediate and obvious reminder at the point of use that this is a global variable.

Then maybe consider full qualification instead of a g_ prefix.

Using $PKG::var is IMHO much clearer, and $::var is a handy shortcut for $main::var

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^7: Pointers and References
by GrandFather (Saint) on Nov 23, 2020 at 22:29 UTC

    C++ish I'd accept (but see the list of languages I've worked with on my home node).

    Perhaps I was being too specific when I said "our tells you something is "global" where you declare the variable". I was more intending to suggest that using an identifier over a wide scope puts more onus on the identifier to convey meaning and that any amount of "documentation" at the point of declaration doesn't help at the point of use. A simple g prefix is a heads up that this variable has large scope: beware, here be dragons. Most of the time the extra markup to convey that the variable hails from some package or another is unnecessarly heavy handed and doesn't add much value anyway.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124086]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-07-31 11:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?