Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!warwick!nott-cs!piaggio!anw From: anw@maths.nott.ac.uk (Dr A. N. Walker) Newsgroups: comp.lang.misc Subject: Re: type checking problem Message-ID: <1991May21.144739.23901@maths.nott.ac.uk> Date: 21 May 91 14:47:39 GMT References: <1991May16.182932.26327@kodak.kodak.com> Reply-To: anw@maths.nott.ac.uk (Dr A. N. Walker) Organization: Maths Dept., Nott'm Univ., UK. Lines: 48 In article <1991May16.182932.26327@kodak.kodak.com> cok@islsun.Kodak.COM (David Cok) writes: > Given, say, myf of four arguments, >one would write > optimum_x = optimize(myf(#1,a,b,c)) >in which myf(#1,a,b,c) is a function of one argument obtained by supplying >values for three of the four arguments of f. Cf Algol Bulletin #37, July 1974, p 24 [the third time I've given this reference in a few weeks!] for the Algol partial parametrisation proposals: optimum_x := optimise (myf ( , a, b, c)) On the other hand, good luck in finding a commercially available Algol compiler with p-p implemented. > [2nd style of solution] The problem >also requires flexibility in number of arguments which is not common in >dynamically typed languages. Yes, it's a nice example. I don't know of many real situations in which the programmer may reasonably claim ignorance of both the number and type of the parameters to a procedure. I suspect that a good solution would require a much more visible type system than is common in compiled languages [statically or dynamically typed], which is why it's easier in interpreted languages. It can *nearly* be done in Algol with modals (same issue of Algol Bulletin, and same caution as above): PROC optimise = (MODE Z, PROC (REAL, REF Z) REAL f, REF Z args) REAL: (REAL result, x; WHILE result := f (x := pick_an_x, args); NOT converged (x, result) DO SKIP OD; x); which allows things like MODE THISZ = STRUCT (REAL p, COMPL q, CHAR f); optimum_x := optimise (THISZ, myf, THISZ := (a, b, c)) [I think -- no way of trying it here] at the expense of some restrictions on the nature of "myf". [Note that "Z" needn't be instantiated as a STRUCTure, it could be eg an array of UNIONs.] -- Andy Walker, Maths Dept., Nott'm Univ., UK. anw@maths.nott.ac.uk