micropython

Change of docs/concepts.txt

245:f6f367f0005e
docs/concepts.txt
     1.1 --- a/docs/concepts.txt	Sun Jun 14 23:17:22 2009 +0200
     1.2 +++ b/docs/concepts.txt	Mon Jun 15 00:40:25 2009 +0200
     1.3 @@ -10,6 +10,7 @@
     1.4    * Parameters and lookups
     1.5    * Instantiation
     1.6    * Register usage
     1.7 +  * List and tuple representations
     1.8  
     1.9  Namespaces and Attribute Definition
    1.10  ===================================
    1.11 @@ -498,3 +499,34 @@
    1.12  storage locations are typically employed. However, optimisations may reduce
    1.13  the need to use such temporary storage where instructions which provide the
    1.14  "active value" can be re-executed and will produce the same result.
    1.15 +
    1.16 +List and Tuple Representations
    1.17 +==============================
    1.18 +
    1.19 +Since tuples have a fixed size, the representation of a tuple instance is
    1.20 +merely a header describing the size of the entire object, together with a
    1.21 +sequence of references to the object "stored" at each position in the
    1.22 +structure. Such references consist of the usual context and reference pair.
    1.23 +
    1.24 +Lists, however, have a variable size and must be accessible via an unchanging
    1.25 +location even as more memory is allocated elsewhere to accommodate the
    1.26 +contents of the list. Consequently, the representation must resemble the
    1.27 +following:
    1.28 +
    1.29 +    Structure header for list (size == header plus special attribute)
    1.30 +    Special attribute referencing the underlying sequence
    1.31 +
    1.32 +The underlying sequence has a fixed size, like a tuple, but may contain fewer
    1.33 +elements than the size of the sequence permits:
    1.34 +
    1.35 +    Special header indicating the current size and allocated size
    1.36 +    Element
    1.37 +    ...             <-- current size
    1.38 +    (Unused space)
    1.39 +    ...             <-- allocated size
    1.40 +
    1.41 +This representation permits the allocation of a new sequence when space is
    1.42 +exhausted in an existing sequence, with the new sequence address stored in the
    1.43 +main list structure. Since access to the contents of the list must go through
    1.44 +the main list structure, underlying allocation activities may take place
    1.45 +without the users of a list having to be aware of such activities.