develooper Front page | perl.perl6.language | Postings from May 2005

Re: Declaration of my() variables using symbolic referentiation

Thread Previous | Thread Next
From:
=?ISO-8859-1?Q?=22TSa_=28Thomas_Sandla=DF=29=22?=
Date:
May 23, 2005 12:43
Subject:
Re: Declaration of my() variables using symbolic referentiation
Message ID:
42923250.5080304@orthogon.com
Ingo Blechschmidt wrote:
> am I correct in the assumption that the following is an error? 
>   # Not in a BEGIN block 
>   my $::(calc_varname()) = 42;

The more interesting question is: how do you expect to
adress the var in the code that follows? I guess the compiler
won't have a problem with taking $::(calc_varname()) as
a variable name. The name doesn't appear anywhere outside the
scope anyway. But you should also not expect any &calc_varname
beeing called at runtime. And at most once during compile time.


> I think so, as my() is a compile-time operation, but in this 
> example, the variable name is not known until runtime, so I 
> think this should be forbidden.  Correct?

Well, &my has got a runtime counterpart which creates a fresh
set of local variables everytime the code object is invoked.
-- 
TSa (Thomas SandlaƟ)


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About