Changes between Version 3 and Version 4 of BlockObjects


Ignore:
Timestamp:
Aug 11, 2011 7:39:47 AM (4 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BlockObjects

    v3 v4  
    22
    33Apple recently [http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1370.pdf proposed] the inclusion of lambda abstractions (closures) into C/C++/Objective-C and facilitated an implementation in the `clang` compiler framework.  They called this language extension ''blocks'' (or ''block objects'').  It is widely used in the APIs of OS X 10.6 (Snow Leopard) and 10.7 (Lion).  This page is about extending the Haskell 2010 FFI to directly support blocks — i.e., to enable Haskell functions to be marshalled as blocks to C and to enable C blocks to be marshalled as Haskell functions to Haskell land.  This extension will be enabled by the language option `BlockObjects`.
     4
     5== Example: calling a higher-order C function ==
     6
     7As an example, consider the library function [http://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man3/qsort_b.3.html qsort_b]:
     8{{{
     9void
     10qsort_b(void *base, size_t nel, size_t width, int (^compar)(const void *, const void *));
     11}}}
     12In C, we might use this function as described in Apple's introduction to block: [http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks/Articles/bxGettingStarted.html#//apple_ref/doc/uid/TP40007502-CH7-SW2 Using a Block Directly].  We would like to be able to do the same in Haskell by writing:
     13{{{
     14foreign import ccall qsort_b "#include <stdlib.h>" ::
     15}}}
    416
    517== Background ==