CISC108 Lecture Notes - Lecture 3: Complex Instruction Set Computing, Cross Product
Document Summary
Templates are the core structure that we know a function must have, independent of the details of its de nition. In many cases the template for a function is determined by the type of data the function consumes. We refer to these as data driven templates. The recipe below can be used to produce a data driven template for any type comment. For a given type typename the data driven template is: (define-(fn. for. type. name-x)- Where x is an appropriately chosen parameter name (often the initials of the type name) and the body is determined according to the table below. To use the table, start with the type of the parameter, i. e. typename, and select the row of the table that matches that type. The rst row matches only primitive types, the later rows match parts of type comments. (note that when designing functions that consume additional atomic parameters, the name of that parameter gets added after every in the template.