Reduct  v4.0.5-1-g4851deb
A functional and immutable language.
Loading...
Searching...
No Matches
Closure

Detailed Description

A closure is a function instance that has captured variables from its enclosing scope.

Data Structures

struct  reduct_closure_t
 Closure structure. More...
 

Macros

#define REDUCT_CLOSURE_SMALL_MAX   5
 The maximum number of small constants.
 

Functions

REDUCT_API reduct_closure_treduct_closure_new (struct reduct *reduct, reduct_function_t *function)
 Allocate a new closure.
 
REDUCT_API void reduct_closure_retain (struct reduct *reduct, reduct_closure_t *closure)
 Retain a closure, preventing it from being collected by the garbage collector.
 
REDUCT_API void reduct_closure_release (struct reduct *reduct, reduct_closure_t *closure)
 Release a closure, potentially allowing the garbage collector to collect it.
 

Macro Definition Documentation

◆ REDUCT_CLOSURE_SMALL_MAX

#define REDUCT_CLOSURE_SMALL_MAX   5

The maximum number of small constants.

Definition at line 19 of file closure.h.

Function Documentation

◆ reduct_closure_new()

REDUCT_API reduct_closure_t * reduct_closure_new ( struct reduct *  reduct,
reduct_function_t function 
)

Allocate a new closure.

Parameters
reductPointer to the Reduct structure.
functionThe prototype function item.
Returns
A pointer to the newly allocated closure.

◆ reduct_closure_retain()

REDUCT_API void reduct_closure_retain ( struct reduct *  reduct,
reduct_closure_t closure 
)

Retain a closure, preventing it from being collected by the garbage collector.

Parameters
reductPointer to the Reduct structure.
closurePointer to the closure.

◆ reduct_closure_release()

REDUCT_API void reduct_closure_release ( struct reduct *  reduct,
reduct_closure_t closure 
)

Release a closure, potentially allowing the garbage collector to collect it.

Parameters
reductPointer to the Reduct structure.
closurePointer to the closure.