US2018165106A1PendingUtilityA1

Instance Interfaces and Mix-ins for Dynamic Languages

56
Assignee: MICROSOFT TECHNOLOGY LICENSING LLCPriority: Aug 1, 2007Filed: Feb 9, 2018Published: Jun 14, 2018
Est. expiryAug 1, 2027(~1.1 yrs left)· nominal 20-yr term from priority
Inventors:Bertrand Le Roy
G06F 9/4492G06F 8/315G06F 11/0718G06F 9/4488G06F 8/24
56
PatentIndex Score
0
Cited by
0
References
0
Claims

Abstract

Various technologies and techniques are disclosed for using contracts in dynamic languages. For example, a contract can be directly associated with an object. The contract can then be used to provide type safety for the object. As another example, contracts can be used with mix-ins. A declaration for a contract is provided with a mix-in. The contract is associated with a target object at runtime when applying the mix-in. Conditions can be assigned to mix-ins that must be met before the mix-in can be applied to the target object. At runtime, if the target object meets the one or more conditions, then the mix-in can be applied to the target object.

Claims

exact text as granted — not AI-modified
What is claimed is: 
     
         1 . A system for restricting the use of mix-ins based on meeting of a condition, comprising:
 a computer comprising a processing unit coupled to a memory, the memory storing computer-executable instructions which, when executed, cause the processing unit to perform the steps of:   by calling an add interface method of a target object, associating at least one condition with a mix-in that must be met by the target object before the mix-in can use the target object;   enforcing type safety for the mix-in by, at runtime of the target object, before applying the mix-in to the target object, determining whether the target object meets the at least one condition;   if the target object meets the at least one condition, at runtime, applying the mix-in to the target object; and   if the target object does not meet the at least one condition, at runtime, not allowing the mix-in to be used and throwing an exception.   
     
     
         2 . The system of  claim 1 , wherein the condition is a constraint contract that constrains objects to which the mix-in can be applied. 
     
     
         3 . The system of  claim 1 , wherein the condition is evaluated based data contained in the target object. 
     
     
         4 . The system of  claim 1 , wherein determining whether the target object meets the at least one condition is performed using reflection. 
     
     
         5 . The system of  claim 1 , the memory storing further computer-executable instructions which, when executed, cause the processing unit to perform the steps of:
 receiving a method call to register the mix-in, the method call including as a parameter at least one of an interface implementation provided by the mix-in, a set of types the mix-in is able to extend, or a set of base mix-ins from which the mix-in inherits implementations.   
     
     
         6 . The system of  claim 1 , the memory storing further computer-executable instructions which, when executed, cause the processing unit to perform the steps of:
 allowing the mix-in to be extended by another mix-in, wherein the another mix-in inherits an interface from the mix-in.   
     
     
         7 . The system of  claim 1 , wherein the target object is an instance of a class. 
     
     
         8 . A method, comprising:
 by calling an add interface method of a target object, associating at least one condition with a mix-in that must be met by the target object before the mix-in can use the target object;   enforcing type safety for the mix-in by, at runtime of the target object, before applying the mix-in to the target object, determining whether the target object meets the at least one condition;   if the target object meets the at least one condition, at runtime, applying the mix-in to the target object; and   if the target object does not meet the at least one condition, at runtime, not allowing the mix-in to be used and throwing an exception.   
     
     
         9 . The method of  claim 8 , wherein the condition is a constraint contract that constrains objects to which the mix-in can be applied. 
     
     
         10 . The method of  claim 8 , wherein the condition is evaluated based data contained in the target object. 
     
     
         11 . The method of  claim 8 , wherein determining whether the target object meets the at least one condition is performed using reflection. 
     
     
         12 . The method of  claim 8 , further comprising:
 receiving a method call to register the mix-in, the method call including as a parameter at least one of an interface implementation provided by the mix-in, a set of types the mix-in is able to extend, or a set of base mix-ins from which the mix-in inherits implementations.   
     
     
         13 . The method of  claim 8 , further comprising:
 allowing the mix-in to be extended by another mix-in, wherein the another mix-in inherits an interface from the mix-in.   
     
     
         14 . The method of  claim 8 , wherein the target object is an instance of a class. 
     
     
         15 . A computer storage memory having computer-executable instructions for causing a computer to perform steps comprising:
 by calling an add interface method of a target object, associating at least one condition with a mix-in that must be met by the target object before the mix-in can use the target object;   enforcing type safety for the mix-in by, at runtime of the target object, before applying the mix-in to the target object, determining whether the target object meets the at least one condition;   if the target object meets the at least one condition, at runtime, applying the mix-in to the target object; and   if the target object does not meet the at least one condition, at runtime, not allowing the mix-in to be used and throwing an exception.   
     
     
         16 . The computer storage memory of  claim 15 , wherein the condition is a constraint contract that constrains objects to which the mix-in can be applied. 
     
     
         17 . The computer storage memory of  claim 15 , wherein the condition is evaluated based data contained in the target object. 
     
     
         18 . The computer storage memory of  claim 15 , wherein determining whether the target object meets the at least one condition is performed using reflection. 
     
     
         19 . The computer storage memory of  claim 15  having further computer-executable instructions for causing the computer to perform steps comprising:
 receiving a method call to register the mix-in, the method call including as a parameter at least one of an interface implementation provided by the mix-in, a set of types the mix-in is able to extend, or a set of base mix-ins from which the mix-in inherits implementations. 
 
     
     
         20 . The computer storage memory of  claim 15  having further computer-executable instructions for causing the computer to perform steps comprising:
 allowing the mix-in to be extended by another mix-in, wherein the another mix-in inherits an interface from the mix-in.

Cited by (0)

No later patents cite this yet.

References (0)

No backward citations on record.