Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Make $^V and "my" implicit

by gunzip (Monk)
on Feb 03, 2014 at 17:57 UTC ( #1073243=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Make $^V and "my" implicit
in thread Make $^V and "my" implicit

Pre-declaration can be achieved by assigning an empty string or an empty list. "my" is more about scope.

Replies are listed 'Best First'.
Re^5: Make $^V and "my" implicit
by chromatic (Archbishop) on Feb 03, 2014 at 19:56 UTC
    Pre-declaration can be achieved by assigning an empty string or an empty list.

    Now you've overloaded the assignment operator to perform both declaration and assignment, depending on its second operand. How far are you going to take this? Does this apply only to constant operands? What if you assign an empty string returned from a function? What if you want to clear a variable in an inner scope? How do you disambiguate between assignment and declaration then?

Re^5: Make $^V and "my" implicit
by ikegami (Pope) on Feb 06, 2014 at 02:53 UTC

    Are you suggesting we declare variables using $x = undef; instead of my $x;? It doesn't sound like a good thing to me. It's longer, and it's less clear. And of course, you'd need a new way to undefine variables.

    If you're not talking about replacing all my $x; with $x = undef;, then it's not a declaration, and it would make it impossible to catch typos.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2016-07-29 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (259 votes). Check out past polls.