Re: why the perl docs suck



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

.



Relevant Pages

  • Re: why the perl docs suck
    ... > There is no difference between a list and an array. ... The notion of memory on the "stack" which is ... void func { ... In perl there is no really satisfactory analogy to either of the above. ...
    (comp.lang.perl.misc)
  • Re: I dont understand the definition of DOES>
    ... on stack on code entry). ... You can use DOES to make ARRAY and then use ARRAY ... CREATE CELLS ALLOT ... First you'd make the code that will execute on the child word. ...
    (comp.lang.forth)
  • Re: Globally declared arrays
    ... I noticed that my colleague was declaring local arrays on the stack, ... What is a "global array on ...
    (comp.lang.c)
  • Re: Use of PICK and ROLL
    ... An array, in contrast, may be accessed at any point: ... PICK and ROLL are therefore array operations, not stack ... I thuoght the point was that if you needed to change the search order ...
    (comp.lang.forth)
  • how does your language... make a map?
    ... "include"ed in the interpreter for testing. ... Since Forth uses a Last-in-First-out implicit stack, ... variable cols ... I want to create an array that will in the future contain all the ...
    (rec.games.roguelike.development)