lambda.h
Provides functions and preprocessor definitions for lambdas (anonymous functions).
- Author: Edward Jones
- Date: 2021-09-17
func_sig
A named function signature.
- Param
r: Return type of the lambda, cannot be void - Param
n: Expression of the body of the lambda, must have non-void type - Param
ps: Parameters of the lambda
Returns: The signature of a function-pointer of name n which takes ps and returns r
#define func_sig(r, n, ps) r(fun n) ps
func_type
A function type.
- Param
r: Return type of the function signature - Param
ps: Parameters of the function
Returns: The type of a function-pointer which takes ps and returns r
#define func_type(r, ps) r(fun) ps
ilambda
Create an impure anonymous function.
- Param
r: Return type of the lambda expression - Param
ps: Paramters of the lambda expression - Param
b: Body of the lambda expression, must be surrounded by curly braces
Returns: A pointer to an anonymous function with parameters ps, return-type r and body b
# define ilambda(r, ps, b) \
lambda
Create a pure anonymous function.
- Param
r: Return type of the lambda, cannot be void - Param
ps: Parameters of the lambda - Param
e: Expression of the body of the lambda, must have non-void type
Returns: A pointer to an anonymous function which takes ps and returns the value of e of type r
# define lambda(r, ps, e) \
void
Lambda-friendly implementation of free.
- Param
p: Pointer to memory to free
extern void(fun freel)(void* p);