Skip to content
/ Closures Public

Hacks the calling convention to add closures to C.

License

Notifications You must be signed in to change notification settings

CPCTC/Closures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Closures in C

This hacked-up single-header C library brings the semantics (but not syntax) of closures into C. It employs a special-purpose just-in-time assembler to capture your userdata and hard-code it into runtime-generated functions.

Applications do not need any special knowledge to invoke closures. They are represented as bare function pointers, compatible with your platform's ABI. If you want, you can pass closures unmodified as callbacks to C libraries. If you've ever tried to funnel extra state into a callback, then you can think of this library as the vastly friendlier thread-safe alternative to pass-by-global-variable.

Directory Structure

About

Hacks the calling convention to add closures to C.

Topics

Resources

License

Stars

Watchers

Forks

Languages