David Matthews wrote:
I thought that it would be quicker and easier to implement this myself rather than try to explain what to do. Try it out and let me know if it does what you want. I've extended the example in the mlsource/extra/CInterface/Examples directory to include a test.
Thanks, David - this certainly does what I need (and more) - and you get to spell finalize your way! :)
On the ML side, I only have one question: why did you change the typing of your setFinal from that in my set_finalize? Besides the fact that the curried form appears to be the "style" of CInterface, it just looks more pleasing - and it reminds one that this *isn't* C/C++. ;)
Who can look at
val setFinal : vol * sym -> unit
and think it looks cooler than
val setFinal : vol -> sym -> unit
??? And of course, the lost opportunities for partial application (whether that is useful in this specific instance or not)...
On the foreign.cpp side of things, I notice 3 differences vs my version:
1) I had it so that "finalisation" was only possible with NON-owned vols, while your approach potentially allows Poly to use this feature now also.
2) My field ordering was different in Volatile - since pointers can be larger than ints, I slipped this in BEFORE the
Bool Own_C_space;
I prefer to keep structs "packed" for alignment and aesthetic reasons.
3) Your form of "return unit" is obviously canonical - I was just thrown by a couple of instances of
return h; /* to be ignored */
Again, thanks - and if you DON'T have a hardcore reason for using the non-curried form and want me to "fix" setFinal, let me know. :)
Robert