User loginNavigation |
Closures without function pointers
I am working on compiling a dynamic, collection-oriented, (mostly) first-order language onto hardware which does not efficiently support function pointers (or much indirection of any sort). This would be easy if my language were fully first-order, but the language has a limited set of primitive higher-order operators (such as map, reduce, and scan). I avoid the creation of function values by specializing these higher order operators on each distinct function argument they receive. So, map(sqrt, ...) is compiled separately from map(cos, ...) and so forth. In my current translation/compilation scheme I have a template for each operator, such as:
map_template(f, arg_type, result_type) =
I run into trouble, however, when I try to pass a closure to a higher order operator. I can't simply inline the function portion of the closure, since it will be missing its closed-over arguments. Do the closure parameters need to be passed into the emitted function? It seems that I need to distinguish ordinary naked functions from closures in some way-- though I'm not sure what a rigorous way to do this might be. Can someone suggest some reading which will either give me ideas worth copying or help me clarify my thinking?
edit: For clarification, compilation happens at runtime, so the set of possible first-order functions is unbounded. Thanks, Alex By Alex Rubinsteyn at 2010-11-07 08:41 | LtU Forum | previous forum topic | next forum topic | other blogs | 9297 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 11 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