In this example, the „Define/Contract“ form defines a contractual limit between the definition of the amount and the surrounding context. In other words, the two parts here are the definition and the module it contains. A contract thus creates a boundary between the two parties. When a value exceeds this limit, the contract tracking system conducts contract audits to ensure that partners comply with the established contract. All contracts and modules in this chapter (except those that follow) are written with the syntax #lang by default for module description. Because the modules serve as a boundary between the parties in a contract, examples refer to several modules. As a contract between two business partners, a software contract is an agreement between two parties. The agreement sets out obligations and guarantees for each „product“ (or any value) that is handed over from one party to the other. . In this case, is the monitoring system used in a positive way? a symbol, but positive? reports an error, because its domain is only numbers. In order to get the treaty to grasp our intentions for all racketeering values, we can ensure that the value is both a number and a positive one by combining the two contracts with and/c: in many cases, it makes sense to add contracts to the limits of the module. However, it is often convenient to use contracts with a finer granularity than the modules.
The „Define/Contract“ form allows for this type of use: an even more serious error would be to retain an unencrypted value: forms that establish these interlocking contractual limits can sometimes be used subtly because they may have unexpected effects on performance or blame a party that might seem intuitive. These subtleties are explained using the definition/> and contract limits and definition/contract. When the module is needed, the monitoring system reports an infringement and makes the module responsible for breaking its promises. (provision of contract [amount (and/or c) positive() Frequent short expressions: 1-400, 401-800, 801-1200, Plus The contract library is integrated into the Racket language, but if you want to use rackets/base, you can explicitly use the contract library as follows: To experiment with multiple modules within a single module or in the DrRacket definition area, use the Rackets sub-module. For example, try this above in this section as follows: If we link an amount to a number that is not positive, each modulated module and its contracts are included in brackets with the keyword module at the front. The first form after the module is the name of the module that must be used in a later instruction requires (each reference by a reference requires the name with „..). promises to all customers in the above module that the value of the amount will always be a positive figure. The contractual system closely monitors the module`s obligation. Each time a customer refers to the amount, the monitor checks whether the value of the amount is actually a positive number.