This is a discussion of a contemplated *future* change. If adopted, it
would have the effect of weakening the current check for function
arity agreement, but all currently accepted code would continue to be
accepted.
When we defined BitC, I chose to adopt n-ary functions. I did this for
three main reasons:
1. I felt that checking function arity was a useful thing.
2. It mapped directly onto the C behavior, and I wanted to keep things
more familiar for C users
3. In a language having PROCLAIM, it wasn't clear how to convert
single parameter
functions into conventional multi-parameter calls.
With the benefit of hindsight, I now see that [2] is mostly a
syntactic sugar issue that we could have dealt with pretty easily, and
I now see some use cases for currying that we might want to consider,
so I started to reconsider single argument functions.
Initially, I was concerned that curried single-argument functions did
not seem to support an optimized calling convention using the stack.
Having worked through some examples, I now see that the optimized
calling convention works out fine provided that arguments are passed
on the stack and are pushed in right-to-left order. Unfortunately, (a)
this optimization can't be expressed when C is used as an assembly
language, and (b) some arguments on modern architectures are
registerized, and this defeats the optimization. Given (b), I am
reluctant to abandon multi-argument functions, but I am considering
changing the apply rule.
Specifically, I am considering a change to the apply rule where, given:
(f a b c)
f: (fn 'a 'b -> (fn 'c -> 'd))
we would canonicalize this apply based on the function type of f into:
(apply (apply f a b) c)
This is "curry like"; the main difference being that it supports N-ary
functions.
The main use case for this, by the way, is variadic functions that
accept an argument of type DYNAMIC. Namely: printf-like functions.
I would appreciate reactions, and if you have them, specific opinions
on two points:
1. Does this seem reasonable?
2. Should a syntactically distinctive form of APPLY be used?
shap
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev