in reply to On Declaration
I think that your looking at this from the wrong angle.
I would say the my, our, package and sub all declare something. They declare a name.
The fact that in some cases, that name will refer to a piece of storage that may already exist our, or a new piece of storage that will be created my, or to a potentially pre-existing, namespace in which other names can be grouped package, or a name of a piece of code, that will exist within current, potentially implicitly named, namespace sub, could be considered a side-effect of the declaration to the compiler that I wish to use a particular name at the current level of scope.
This is further reenforced on those occasions when my doesn't cause a new piece of memory to be allocate. Eg.
for my $key ( keys %hash ) {...} while( my $line = <FILE> ) {...}
In both these cases, my isn't creating anything. It is declaring a name that is used to refer to a pre-existing piece of storage for the duration of a level of scope.
In all cases, the four keywords declare names that the programmer wishes to use for some entity. That sometimes that entity may be a pre-existing one and other cases it will be created is (almost) incidental.
The joker in the pack of course is local, which says I wish to use a pre-existing name to refer to a new piece of storage.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: On Declaration
by demerphq (Chancellor) on Jun 16, 2003 at 09:50 UTC |