31 Jul 1996 19:31:26 -0400

Related articles |
---|

Appropriate methods for argument checking clodius@nis.lanl.gov (William Clodius) (1996-07-22) |

Re: Appropriate methods for argument checking grout@polestar.csrd.uiuc.edu (1996-07-23) |

Re: Appropriate methods for argument checking chase@centerline.com (1996-07-26) |

Re: Appropriate methods for argument checking jgllgher@maths.tcd.ie (Dara Gallagher) (1996-07-31) |

Re: Appropriate methods for argument checki chase@centerline.com (1996-08-05) |

Re: Appropriate methods for argument checki rwh@cs.cmu.edu (Robert Harper) (1996-08-09) |

From: | Dara Gallagher <jgllgher@maths.tcd.ie> |

Newsgroups: | comp.compilers |

Date: | 31 Jul 1996 19:31:26 -0400 |

Organization: | Dept. of Maths, Trinity College, Dublin, Ireland. |

References: | 96-07-144 96-07-178 |

Keywords: | design, debug |

chase@centerline.com (David Chase) writes:

*> If you use parametric polymorphism, the variable type is actually polymorphic:*

*> T (*f)(T) <type T> = f_of_char_yielding_char;*

*> T (*f)(T) <type T> = f_of_short_yielding_short;*

No; the only if f has the above type then it must accept arguments of any

type (and return a result of the same type). In many type theories, the

only such function is the polymorphic identity function. The lack of

polymorphism in traditional languages like Pascal, etc. means that the

programmer would be forced to write seperate definitions for the boolean

identity function, the integer identity function, etc. even though the

bodies would be identical.

The identity function may seem like a useless example; however consider a

similar situation where the programmer has to write seperate sort functions

for arrays of integers, arrays of floats, arrays of strings, etc. Modern

functional languages which support polymorphism (such as Haskell or SML)

solve this and similar problems very elegantly.

<snip further comments on parametric polymorphism>

I'm not really sure, but it looks like you're confusing

parametric polymorphism with existential types. I.e.

you seem to be referring to (using your C syntax)

T (*f)(T) <for some type T>

rather than parametric polymorphism or

T (*f)(T) <for all types T>

Cheers, Dara. --

_______________________________________________________________

Dara Gallagher. http://www.cs.tcd.ie/www/jgllgher/jgllgher.html

--

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.