4. The system of claim 1 , wherein the variable is bound to the value if the first pattern matches the value.
1. A system for programming a computer for pattern matching; the system comprising: a processor; and a memory coupled to the processor, the memory having stored thereon instructions that when executed by the processor cause the processor to: define a first pattern in an object-oriented programming language, the first pattern being a structured literal that is capable of matching a value contained in an incoming data stream, the structured literal comprising a representation of a list, tree, object, or graph; compare the first pattern to the value in the incoming data stream; determine that one or more variables are defined in the first pattern; infer the type of the one or more variables based on the position of the one or more variables in the first pattern; bound the one or more variables to the value; define a guard expression to be associated with the first pattern; and evaluate the guard expression, wherein if the first pattern matches the value, the guard expression evaluates to true; and if the first pattern does not match the value, the guard expression evaluates to false and a second pattern is compare to the value in the incoming data stream to determine whether the second pattern matches the value.