close Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Initial Version and Version 1 of ContextPy

01/10/2011 04:32:53 PM (11 years ago)



  • ContextPy

    v1 v1  
     1= ContextPy =
     3ContextPy, our context-oriented extension to the [ Python] language, provides a COP-based approach to ''design by contract'' (DBC).
     4DBC is a programming technique to separate contract enforcement from application code. DBC provides information about the applicability of methods and helps  to  narrow  down  the  search  space  in  case  of  a  software failure.   However,  most DBC implementations suffer from inflexibility:  Contract enforcement can only be activated or deactivated at compile-time or start-up, contracts are checked globally and cannot be restricted in their scope such as to the current thread of execution,  and contracts
     5cannot be grouped according to the concerns they relate to.
     7ContextPy provides DCL for fine-grained and flexible contract management and extends DBC by a grouping mechanism for contracts, thread-local activation and deactivation of such groups, and selective contract enforcement at run-time. 
     9PyDCL, our proof-of-concept implementation of DCL, is built onto of ContextPy
     12== Implementation ==
     13ContextPy  supports the layer-in-class approach and with that allows developers to define their partial methods within the scope of the actual classes these methods are contributing to. Similar to all other COP extensions so far, ContextPy provides both layers, partial methods, and dynamic scoping.
     15=== Layers ===
     16In ContextPy layers are represented by regular objects  that  provide  the  identities  layers  need  to  exhibit  at
     17run-time.  Layer access has to be managed by the developers.
     19=== Layer Composition ===
     20The representation of activated and deactivated layers is handled by two stacks—one for thread-
     21specific and one for globally activated layers. Layers can be(de-)activated using Python’s with statement or by library
     22methods for stack operations.
     24=== Partial Methods ===
     25In Python, each class has its own dictionary that maps identifiers (keys) to objects (values). For instance, a method is stored with its name as key and the method object as value. We introduce a layered method descriptor that consists of all (partial) methods and a cache