User loginNavigation |
Overloading in a dynamic functional languageHi, What we have: Without overloading it is even not possible to implement your own numeric type and support standard operators for it such as "+", "-", etc. So it seems like a very handy thing to have. However when we take a dynamic functional language it is not really clear what is the direct way to go. The requirement is - to have overloaded functions as first class functions (first class values). I have one solution but it looks like I actually created solid ground for side effects. This is how it works: open Con let foo x = "foo1" on Any let _ = writen (foo 12) let foo x = "foo2" on Int# let _ = writen (foo 12) The first function is overloaded for "any" type, the second - only for integers. Overloads are dynamic and are processed as regular bindings (in the order of execution). And here is the result - when I call "foo" function before the second overload a first implementation is called, but after the second overload the second implementation fits best and it gets called. The function invocation code is the same in both cases as you see. I have a strong feeling that this is a problem. What do you think? Thanks. By vorov2 at 2011-09-24 15:19 | LtU Forum | previous forum topic | next forum topic | other blogs | 4878 reads
|
Browse archives
Active forum topics |
Recent comments
27 weeks 1 day ago
27 weeks 1 day ago
27 weeks 2 days ago
49 weeks 3 days ago
1 year 1 week ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 5 weeks ago
1 year 10 weeks ago
1 year 10 weeks ago