Re: why the perl docs suck
- From: robic0@xxxxxxxxx
- Date: Thu, 20 Oct 2005 02:07:17 -0700
On Thu, 20 Oct 2005 10:00:08 +0200, "Tassilo v. Parseval"
<tassilo.von.parseval@xxxxxxxxxxxxxx> wrote:
I havn't yet had the pleasure to read your whole narrative
but I will tommorow, and trust me I will digest every sentence.
$var = (stat($filename))[9];
might thow you for a loop.....
>Also sprach robic0@xxxxxxxxx:
>> On Thu, 13 Oct 2005 10:31:22 GMT, "Jürgen Exner"
>><jurgenex@xxxxxxxxxxx> wrote:
>> There is no difference between a list and an array.
>> Only difference is a list is a temporary on the "stack".
>
>There is no difference ... Only difference is ...
>
>You're making an awful lot of sense there.
>
>That aside, there appears to be a lot of confusion about certain
>terminology on either side.
>
>The notion of memory on the "stack" (in the traditional sense) which is
>implicitely reserved by a compiler local to the currently executing
>frame has little bearing on whether something is an array, a list or a
>list literal. In C I can easily have an array on the stack:
>
> void func (void) {
> char array[] = "string";
>
>Elements of that array are mutable because each has its own slot on the
>stack. This is not at all the same as:
>
> void func (void) {
> char *array = "string";
>
>Elements are immutable. Any attempt to change them will result in
>segmentation faults because the string literal is stored in a special
>read-only memory segment and not on the stack. However, and unlike
>above, I am allowed to assign a new string to 'array'.
>
>In perl there is no really satisfactory analogy to either of the above.
>It does have a stack, however the stack is also accessible via @_ which
>is a real array that I am allowed to resize, splice, assign to etc.
>
>Also, when talking about the perl stack, it's a mistake to think in
>terms of stack and heap. Perl's stack is dynamically allocated on the
>heap. Otherwise it couldn't grow or shrink as needed at runtime.
>
>A lot of the confusion with respect to the distinction of an array and a
>list would disappear if people used the term 'list literal' for what is
>currently (and IMO incorrectly) referred to as list. Once it's a literal
>it becomes fairly soon obvious that you're going to have a very hard
>time trying to resize it, or push values on it. And that is not because
>the literal would be stored on the stack or in read-only memory
>segments. That's not the case with Perl. The reason is simply that you
>don't have a variable that could act as a handle to that list literal.
>
>Perl could easily be rewritten to allow something like that:
>
> push (1, 2, 3, 4), 10;
>
>Even the dumbest programmer would soon realize that this is a no-op as a
>literal can only be referred to literally, and not by alias or name.
>Incidentally, we can already write something equally stupid now:
>
> push @{ [1, 2, 3, 4] }, 10;
>
>I doubt you see that often in real-world programs. Therefore I believe
>that people think about the difference between an array and a list much
>less often than the existence of that FAQ ("What is the difference
>between a list and an array?") would imply.
>
>Tassilo
.
- Follow-Ups:
- Re: why the perl docs suck
- From: robic0
- Re: why the perl docs suck
- References:
- re: why the perl docs suck
- From: Fred@xxxxxxxx
- Re: why the perl docs suck
- From: Matt Garrish
- Re: why the perl docs suck
- From: Fred@xxxxxxxx
- Re: why the perl docs suck
- From: Jürgen Exner
- Re: why the perl docs suck
- From: Jürgen Exner
- Re: why the perl docs suck
- From: robic0
- Re: why the perl docs suck
- From: Tassilo v. Parseval
- re: why the perl docs suck
- Prev by Date: Re: How can I download all the FAQ in this usenet
- Next by Date: Re: why the perl docs suck
- Previous by thread: Re: why the perl docs suck
- Next by thread: Re: why the perl docs suck
- Index(es):
Relevant Pages
|