1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/assignment.txt Fri Feb 20 01:24:14 2009 +0100
1.3 @@ -0,0 +1,22 @@
1.4 +Assignment types:
1.5 +
1.6 + Assignment of stored value to... Effect on context
1.7 + -------------------------------- -----------------
1.8 + local preserved
1.9 + global (module) preserved
1.10 + class preserved
1.11 + instance preserved
1.12 +
1.13 + Assignment to a namespace preserves the context
1.14 +
1.15 +Access types:
1.16 +
1.17 + Access to stored value from... Effect on context Optimised instruction Unoptimised instruction
1.18 + ------------------------------ ----------------- --------------------- -----------------------
1.19 + local preserved LoadName
1.20 + global (module) preserved LoadAddress LoadAttrIndex
1.21 + class preserved LoadAddress LoadAttrIndex
1.22 + class via instance overridden LoadAddressContext LoadAttrIndex
1.23 + instance preserved LoadAttr LoadAttrIndex
1.24 +
1.25 + Access to a namespace may not preserve the stored context
2.1 --- a/docs/structures.txt Mon Feb 09 01:09:42 2009 +0100
2.2 +++ b/docs/structures.txt Fri Feb 20 01:24:14 2009 +0100
2.3 @@ -73,34 +73,31 @@
2.4
2.5 LoadAddress Load attribute from Classes, functions and modules
2.6 known object cause the loaded attribute to be
2.7 - retrieved unchanged; whereas
2.8 - constants (representing instances)
2.9 + (typically classes and retrieved unchanged; whereas
2.10 + modules) constants (representing instances)
2.11 cause the constant to override the
2.12 attribute's own context (since all
2.13 attributes should belong to the
2.14 constant's class hierarchy)
2.15
2.16 - LoadAddressContext Override loaded context with a
2.17 - predetermined object (provided
2.18 - that the object and context are
2.19 - compatible, which can be tested at
2.20 + LoadAddressContext Load attribute Override loaded context with a
2.21 + from known object predetermined object (provided
2.22 + (typically classes) that the object and context are
2.23 + for an instance compatible, which can be tested at
2.24 compile-time)
2.25
2.26 - LoadAttr Load attribute from Attributes with null contexts or
2.27 - instance contexts compatible with the
2.28 - instance cause loaded attributes
2.29 - to combine the instance as context
2.30 - with the object from the
2.31 - attribute; other attributes have
2.32 - their context preserved
2.33 + LoadAttr Load attribute from Contexts are preserved (since only
2.34 + instance values stored on instances can be
2.35 + accessed in this way, and their
2.36 + contexts would never be overridden
2.37 + upon access
2.38
2.39 - LoadAttrIndex Load attribute from Functions and modules as unknown
2.40 - object the unknown object accessor cause
2.41 - the loaded attribute to be
2.42 - retrieved unchanged; classes and
2.43 - instances cause the LoadAttr rules
2.44 - to apply (class compatibility
2.45 - applies)
2.46 + LoadAttrIndex Load attribute from Classes, functions and modules as
2.47 + object (can be the unknown object accessor cause
2.48 + classes, modules, the loaded attribute to be
2.49 + instances...) retrieved unchanged; instances
2.50 + cause the LoadAttr rules to apply
2.51 + (class compatibility applies)
2.52
2.53 A certain amount of run-time testing might be required for both LoadAttr and
2.54 LoadAttrIndex instructions. However, with certain restrictions in place around
2.55 @@ -152,6 +149,8 @@
2.56 necessary in order to prevent
2.57 assignments to classes
2.58
2.59 +Note that contexts are never changed in the stored value: they are preserved.
2.60 +
2.61 Objects
2.62 -------
2.63
3.1 --- a/tests/attributes2.py Mon Feb 09 01:09:42 2009 +0100
3.2 +++ b/tests/attributes2.py Fri Feb 20 01:24:14 2009 +0100
3.3 @@ -15,6 +15,8 @@
3.4 self.e(1) # TypeError: unbound C.e needs C instance, not int
3.5
3.6 class E(C):
3.7 + # e = C.e (via inheritance)
3.8 +
3.9 def test(self):
3.10 self.e()
3.11
4.1 --- a/tests/reference/methods.py Mon Feb 09 01:09:42 2009 +0100
4.2 +++ b/tests/reference/methods.py Fri Feb 20 01:24:14 2009 +0100
4.3 @@ -5,20 +5,20 @@
4.4
4.5 class B:
4.6 def f(self):
4.7 - pass
4.8 + print self
4.9
4.10 -def f(x):
4.11 - pass
4.12 +def f(self):
4.13 + print self
4.14
4.15 b = B()
4.16
4.17 - # on A on a
4.18 -A.f1 = f # unbound bound (a)
4.19 -A.f2 = B.f # unbound unbound
4.20 -A.f3 = b.f # bound (b) bound (b)
4.21 + # on A on a context on A attribute context on a attribute
4.22 +A.f1 = f # unbound bound (a) A a
4.23 +A.f2 = B.f # unbound unbound B (need B instance) B (need B instance)
4.24 +A.f3 = b.f # bound (b) bound (b) b b
4.25 a = A()
4.26 -a.f4 = f # N/A function
4.27 -a.f5 = B.f # N/A unbound
4.28 -a.f6 = b.f # N/A bound (b)
4.29 +a.f4 = f # N/A function N/A none
4.30 +a.f5 = B.f # N/A unbound N/A B (need B instance)
4.31 +a.f6 = b.f # N/A bound (b) N/A b
4.32
4.33 # vim: tabstop=4 expandtab shiftwidth=4