susan@ic-cs.UUCP (07/18/84)
Available for research and teaching purpose only: Hope interpreter written in Pascal by Victor Wu at Imperial Col- lege. Computing requirements: A VMS Vax system with VMS Pascal or any virtual memory computer with an ISO Pascal compiler (a small amount of work may be neces- sary to get it up). Cost: Postage and packing if you send a tape, otherwise the price of a tape, postage and packing. Interested: Mail me ( ukc!west44!ic-cs!susan ) and I'll send you by post a form that says you will not exploit the interpreter commercially. Upon our receipt of this form we will send you a tape. A brief description of Hope: Hope (named after Hope Park Square, home of Edinburgh's Depart- ment of Computer Science) was designed by Dave MacQueen (Bell Labs), Rob Burstall and Don Sannella (Edinburgh) and is one of several recursion equation languages. In these, each function is represented by a set of equations which together will provide a result for the whole range of function arguments and a program is simply a hierarchy of these functions, together with a single in- vocation of the highest level function. Hope allows the programmer to define specific or polymorphic data types which are checked by the compiler. Polymorphic types allow for the creation of functions that can be applied to more than one type of data (for instance a routine that can sort numbers, characters, strings or records). The data types num (positive integer), truval (boolean), char and list are predefined and these can be used to build up more sophisticated data structures by means of type variables and data statements. Constructor functions (defined when the data structure is de- fined) are associated with each structure in the normal way but selection is done by pattern matching (as in Prolog). In the programming example below, items are selected from a list by representing the list as the pattern 'First::RestOfList' where 'First' is the item, '::' is the constructor which joins the item to 'RestOfList' is another list. To solve a problem using Hope the programmer designs data struc- tures that match the problem; produces higher-order functions (like FP's combining forms) to traverse these data structures and then invokes the higher-order functions with arguments which represent instances for which specific results are required. Finally, Hope has a modular structure. So, for instance, a pro- grammer can implement an abstract data type (e.g. a queue) with a type declaration and a collection of functions to operate on that type. The implementation of these functions and the representa- tion of the type itself can be hidden from the user, who relies solely on the specified properties of the abstract type. As an example of a Hope program the following computes the length of a list: dec length : list( alpha ) -> num --- length( nil ) <= 0 --- length( First :: RestOfList ) <= 1 + length( RestOfList ) ; This program works on a list where the elements are all of the same unspecified type. In English it says length is a function which takes a list of type 'alpha' and returns a number. If the list is empty then the number returned is zero; otherwise the length of the list is one more than the length of the list without the first element. Susan Eisenbach {mcvax,vax135}!ukc!west44!ic-cs!susan Dept of Computing Imperial College London SW7 2BZ 01-581-5111 x2703