New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs on “my” should mention dynamic variables #1082
Comments
|
I'm not sure, the effect of a "my dynamic variable" is lexical, The difference with a dynamic variable is that you get a run-time failure if you try to refer to one if it isn't defined, rather than compile time. sub foo() {
say $*FOO || "boop";
}
foo();
{
my $*FOO = "blar";
foo();
}
foo();
The difference is that unless it has been introduced globally say with I think the difficulty is that dynamic variables are a different category of thing that may have a lexical scope, not just a normal variable. |
|
The |
|
I don't think most people care how you store it. They will care about what they expect based on what is documented. If you tell them it's lexical, they won't expect it to be visible outside of the scope where it was defined. Indeed, they shouldn't have to know the gory details. If this is the desired behaviour, then the docs should describe in the first paragraph both the lexical effects for "ordinary" variables and the other, leaky effect for dynamic variables. Furthermore, something should clarify why someone would prefer |
|
I noticed a comment in IO::Handle's indir that says that temp doesn't work in core settings: Is this low-level detail relevant to the reason we'd use I also asked this on Stackoverflow. |
|
I've changed the title so that the ticket is easier to approach. It is its defining feature, we just have to discuss dynamic variables a little bit. |
Explains the relationship between lexical/package and normal/dynamic scope a bit more. Asked in #1082
* “my” docs mentioning dynamic variables Explains the relationship between lexical/package and normal/dynamic scope a bit more. Asked in #1082 * Update variables.pod6 * Update variables.pod6 * Update variables.pod6
|
Solved by #1522 |
The documentation for my starts with:
But this isn't true in the sense that people expect since it does something different with dynamic variables (those with the * twigil). S04 says:
And later,
But, that's not what
mydoes with dynamic variables, say, as in Moritz's Testing say article) where he temporarily replaces$*OUT's value for a different scope that doesn't enclose it:There's a cryptic note at the end of the my docs that seems to contradict the rest of the documentation so far:
That is, if
$locationwere$*location, it's not a lexical variable anymore despite themy.The example for the * Twigil shows the same thing. A dynamic variable declared with
myisn't lexical in the sense that S04 defines or that people will expect.The text was updated successfully, but these errors were encountered: