106 points · by cioc · 13y ago · 30 comments
[0: http://www.boost.org/doc/libs/1_49_0/libs/range/doc/html/ran...
If I understand correctly, though, your implementation leaks memory. In my case I use a GC to free the thunks when they are no longer accessible.
Adding a GC is a separate task and several exist for C. Though if you were using C++, you could put together some RAII sugar or smart pointers around it all, but in that case you have std::bind1st and functors available anyway (although this is still the only way to meet the raw-pointer use case).
A type is lifted iff it has bottom as an element. Closures always
have lifted types: i.e. any let-bound identifier in Core must have
a lifted type. Operationally, a lifted object is one that can be
entered. Only lifted types may be unified with a type variable.
http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler...tbh that's the first time i've seen something quite like that. i am not sure this is so common a pattern (usually, imho, you can be more explicit and have a struct that associates a known callback type with named, typed values).
Although a straight-up Google search for "g_closure_invoke" is amusing. I did add the "as long as you can get the memory management right on it" for a reason... page after page after page of "segmentation fault in g_closure_invoke" stack traces....
Of course those things aren't a problem in cases where you need to do those things, but that isn't the case for most applications.
Probably that an Haskell programmer values strong static typing just as much as functional programming.
I someone think that turning C from a weakly static type system to a strongly static one would prove quite more difficult... (but my C days are long gone so don't quote me on that).
They're jus programming paradigms. Take what you need and get the job done. Anything else is just a buzzword.
(It's also wrong, or over-simplified, in that all programming doesn't really fit into those little boxes.)
BTW, downvotes are as meaningless as i--.
No, they aren't, and a simple web search would've revealed others, such as Dataflow[1].