Reputation: 3913
How are LISTS internally represented in PERL? I had someone telling me it is represented as linked lists, True? If so won't that be a overhead on the interpreter? I'm unable to visualize it.
Upvotes: 2
Views: 454
Reputation: 98398
Lists in Perl are stored on the stack. It is an array, resized when necessary, with a second array used to store pointers to demarcate different lists.
If you meant arrays, not lists, Perl arrays consist of a C array of pointers, an allocated size of that array, an offset to the current beginning of the Perl array in the C array, and a used length.
I don't know what you mean by "overhead". Running programs is an overhead on the interpreter in general :) But in fact Perl does not use linked lists for arrays or lists.
Upvotes: 6