# HG changeset patch # User Paul Boddie # Date 1256490675 -3600 # Node ID f8de3c09afd2d3af102a82b6d6b1deabb73e87d3 # Parent 5c26eb35251e1107f357ea2930fc8a25967d1fd2 Added notes on type constraints deduced from attribute usage. Added a link to a discussion of module-level initialisation restrictions. diff -r 5c26eb35251e -r f8de3c09afd2 docs/rationale.txt --- a/docs/rationale.txt Sun Oct 11 02:40:20 2009 +0200 +++ b/docs/rationale.txt Sun Oct 25 18:11:15 2009 +0100 @@ -146,3 +146,48 @@ * Module and class attributes, locals * The exception: * Instance attributes + +Wild idea: isn't AttributeError just evidence of a bug in the program? + + * Note down all attributes used by a particular name during its lifetime + * Upon recording name usage, record the location of usage + * Use the set of attributes to constrain the range of types that can be used + without an AttributeError being raised + * Convert all name usage to specific attribute usage (on the range of types + found) for all attribute accesses + +Attributes on locals + + * Control-flow can make attribute tracking awkward: + + obj.x # obj must have x + if ...: # (branch) + obj = ... # obj reset + obj.attr # obj must have attr + else: # (branch) + obj.name # obj must have x, name + # (merge) + # obj must have + +Attributes on locals with loops + + * Loops complicate matters still further: + + obj.x # obj must have x + while ...: # (branch) + obj.y # obj must have x, y + obj = ... # obj reset + obj.z # obj must have z + # (re-branch) + # obj must have z, y (obj.y) + # obj reset (obj = ...) + # obj must have z, y (obj.z) + # (merge) + # obj must have + +Attributes on attributes + + * Classes and modules should preserve single interpretations of attributes + * Attributes on such attributes should accumulate on the targets + * Tracking attributes on such targets is only useful for unknown targets + * Instances cannot be relied upon to refer to a coherent set of targets diff -r 5c26eb35251e -r f8de3c09afd2 docs/related.txt --- a/docs/related.txt Sun Oct 11 02:40:20 2009 +0200 +++ b/docs/related.txt Sun Oct 25 18:11:15 2009 +0100 @@ -11,3 +11,7 @@ CapPython limits attribute access in order to facilitate code verification: http://mail.python.org/pipermail/python-dev/2008-September/082475.html + +Advocacy for limited module-level initialisation: + +http://plope.com/Members/chrism/import_time_side_effects