User loginNavigation |
Help with N-Ary functions?I feel incredibly silly posting this, but I could use some pointers. There seem to be two schools of function specification: one in which all function types are expressed as T1 -> T2, and the other in which function types are expressed as T1 x T2 x ... Tn -> Tout. The difference here is that the second makes function arity part of the type. In BitC, we initially chose the N-ary functions because I was slow figuring out how to make C's void type come out right. Later, we retained it because I thought that arity checking was important. That is, given a function: (define (f x y) ...)
it seemed like a good thing to be able to notice that: (f 1 2 3)
was a malformed call because the number of arguments do not agree. The alternative was to define application to occur by pair consing (similar to Scheme style, but with using an unboxed construction): (f 1 2 3) =>
My concern about this is that type checking doesn't accomplish arity checking in the case where the type of the last parameter to the function is parametric. That is, if we get a function f whose type is something like: (int32, float, 'a) -> bool
then you'll get to pass as many arguments as you want. The N-ary function thing is now getting in our way, and I would like to switch to something like the pair-consed view. There seem to be three resolutions:
So: how do other polymorphic languages handle this? By shap at 2008-09-28 23:23 | LtU Forum | previous forum topic | next forum topic | other blogs | 7937 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 9 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago