# US 9,436,581 B2 · Dynamic lazy type system

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 9,436,581 B2
- Document ID: US9436581B2
- Status: Granted
- Kind: B2
- Application number: 14/734,007
- Filed: 2015-06-09
- Published: 2015-10-01
- Granted: 2016-09-06
- Earliest claimed: 2011-02-18
- Assignees: Microsoft Technology Licensing, LLC
- Applicants: Microsoft Technology Licensing, LLC
- Inventors: Erik Christensen; Michael Coulson; Clemens Szyperski; Gregory Hughes
- Web page: https://patentgrep.com/patent/US9436581B2

## CPC

- G06F 11/3608: {using formal methods, e.g. model checking, abstract interpretation (theorem proving G06N5/013)}
- G06F 8/437: {Type checking}
- G06F 9/44589: {Program code verification, e.g. Java bytecode verification, proof-carrying code (high-level semantic checks G06F8/43; prevention of errors by analysis, debugging or testing of software G06F11/36)}
- G06F 11/3612: {by runtime analysis (performance monitoring G06F11/3466)}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A dynamic, lazy type system is provided for a dynamic, lazy programming language. Consequently, programs can benefit from runtime flexibility and lightweight notation in combination with benefits afforded by a substantial type system.

## Claims

### Claim 1

A system, comprising:
a processor coupled to a memory, the processor configured to perform component execution, namely, configured to execute at least one computer-executable component which is stored in the memory;
a type system having a plurality of types, wherein type enforcement using a constraint is performed at runtime; and
an analysis component configured to analyze a value and a type which defines allowable values, in order to determine if the constraint provided by the type holds, wherein at least one allowable value is specified using a “where” clause; and
an assignment component configured to automatically identify the type for the value during runtime.

### Claim 2 (depends on 1)

The system of claim 1, wherein the system is configured to produce an error during runtime in response to the analysis component determining that the constraint does not hold.

### Claim 3 (depends on 1)

The system of claim 1, wherein the analysis component is configured to determine whether the constraint is satisfied when a function is called in the application program.

### Claim 4 (depends on 1)

The system of claim 1, wherein at least one allowable value is within allowable values specified by a predicate.

### Claim 5 (depends on 1)

The system of claim 1, wherein at least one allowable value is evaluated against at least a portion of another type.

### Claim 6 (depends on 1)

The system of claim 1, wherein at least one brand is associated with the type as a constraint.

### Claim 7 (depends on 1)

The system of claim 1, wherein the type itself is represented as a value.

### Claim 8 (depends on 1)

The system of claim 1, wherein the system is configured to employ at least one type flow function to infer or compute a predicted result type of an application program function based on actual argument types in a call to the application program function, as opposed to declared parameter types.

### Claim 9

A method, comprising:
employing at least one processor configured to execute computer-executable instructions stored in memory to perform the following acts during a runtime of an application program:
analyzing (i) a value and (ii) a type which defines allowable values, thereby determining whether a constraint provided by the type holds;
in response to determining the constraint provided by the type holds, automatically inferring the type; and
in response to determining the constraint provided by the type is not satisfied, producing an error during the application program runtime;
wherein the method comprises at least two of the following performed during the application program runtime:
assigning types to computed values in the application program;
determining whether the constraint is satisfied when a function is called in the application program;
employing at least one type flow function to infer or compute a predicted result type of an application program function based on argument types in a call to the application program function;
evaluating at least one allowable value against at least a portion of the type.

### Claim 10 (depends on 9)

The method of claim 9, wherein the analyzing and determining are performed lazily in order to evaluate an expression of the application program during the runtime.

### Claim 11 (depends on 9)

The method of claim 9, wherein the method is further characterized in that at least one allowable value is within allowable values specified by a predicate in the application program.

### Claim 12 (depends on 9)

The method of claim 9, wherein the method is further characterized in that at least one allowable value is specified using a “where” clause in the application program.

### Claim 13 (depends on 9)

The method of claim 9, wherein the method further comprises at least one of the following:
associating at least one brand with the type as a constraint;
creating the type dynamically during the application program runtime.

### Claim 14

A computer-readable storage medium having instructions stored thereon that enables at least one processor to perform the following acts:
lazily analyzing (i) a value and (ii) a type which defines allowable values, thereby determining whether a constraint provided by the type holds; and
identifying the type for the value during an application program runtime in response to determining that the constraint holds;
wherein the acts further comprise at least one of the following performed during the application program runtime:
determining whether the constraint is satisfied when a function is called in the application program;
employing at least one type flow function to infer or compute a predicted result type of an application program function based on argument types in a call to the application program function.

### Claim 15 (depends on 14)

The computer-readable storage medium of claim 14, wherein the acts further comprise at least one of the following performed during the application program runtime:
determining that the value is within allowable values specified by a predicate in the application program;
determining that the value is within allowable values specified using a “where” clause in the application program.

### Claim 16 (depends on 14)

The computer-readable storage medium of claim 14, wherein the acts further comprise associating at least one brand with the type as a constraint.

### Claim 17 (depends on 14)

The computer-readable storage medium of claim 14, wherein the acts further comprise treating the type as a first-class value during the application program runtime.

### Claim 18

A system, comprising:
a processor coupled to a memory, the processor configured to perform component execution, namely, configured to execute at least one computer-executable component which is stored in the memory;
a type system having a plurality of types, wherein type enforcement using a constraint is performed at runtime; and
an analysis component configured to analyze a value and a type which defines allowable values, in order to determine if the constraint provided by the type holds; and
an assignment component configured to automatically identify the type for the value during runtime;
wherein the system is configured to employ at least one type flow function to infer or compute a predicted result type of an application program function based on actual argument types in a call to the application program function, as opposed to declared parameter types.

### Claim 19 (depends on 18)

The system of claim 18, wherein the system is configured to produce an error during runtime in response to the analysis component determining that the constraint does not hold.

### Claim 20 (depends on 19)

The system of claim 19, wherein at least one allowable value is within allowable values specified by a predicate.

### Claim 21

A method, comprising:
employing at least one processor configured to execute computer-executable instructions stored in memory to perform the following acts during a runtime of an application program:
analyzing (i) a value and (ii) a type which defines allowable values, thereby determining whether a constraint provided by the type holds;
in response to determining the constraint provided by the type holds, automatically inferring the type; and
in response to determining the constraint provided by the type is not satisfied, producing an error during the application program runtime;
wherein the method is further characterized in that at least one allowable value is specified using a “where” clause in the application program.

### Claim 22 (depends on 21)

The method of claim 21, wherein the method comprises determining whether the constraint is satisfied when a function is called in the application program.

### Claim 23 (depends on 21)

The method of claim 21, wherein the method comprises evaluating at least one allowable value against at least a portion of another type.

### Claim 24

A computer-readable storage medium having instructions stored thereon that enables at least one processor to perform the following acts:
lazily analyzing (i) a value and (ii) a type which defines allowable values, thereby determining whether a constraint provided by the type holds; and
identifying the type for the value during an application program runtime in response to determining that the constraint holds; and
wherein the acts further comprise at least one of the following performed during the application program runtime:
determining that the value is within allowable values specified by a predicate in the application program;
determining that the value is within allowable values specified using a “where” clause in the application program.

### Claim 25 (depends on 24)

The computer-readable storage medium of claim 24, wherein the type itself is represented as a value.

### Claim 26 (depends on 24)

The computer-readable storage medium of claim 24, wherein the acts further comprise associating at least one brand with the type as a constraint.
