p2  0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PNClosure Struct Reference

a closure is an anonymous function, without closed values, More...

#include <potion.h>

+ Collaboration diagram for PNClosure:

Public Member Functions

PN potion_closure_code (Potion *P, PN cl, PN self)
 
PN potion_closure_string (Potion *P, PN cl, PN self, PN maxlen)
 
PN potion_closure_arity (Potion *P, PN cl, PN self)
 
PN potion_closure_minargs (Potion *P, PN cl, PN self)
 
#define PN_CLOSURE(x)   ((struct PNClosure *)(x))
 
#define PN_CLOSURE_F(x)   ((struct PNClosure *)(x))->method
 
#define PN_FUNC(f, s)   potion_closure_new(P, (PN_F)f, potion_sig(P, s), 0)
 

Data Fields

 PN_OBJECT_HEADER
 PNType vt; PNUniq uniq. More...
 
PN_F method
 
PN sig
 signature PNTuple More...
 
int arity
 cached number of declared args, including optional More...
 
int minargs
 cached number of mandatory args, without optional More...
 
PN_SIZE extra
 0 or 1 if has code attached at data More...
 
PN name
 
PN data []
 PNString. More...
 

Detailed Description

a closure is an anonymous function, without closed values,

See also
PNProto non-volatile.

Definition at line 381 of file potion.h.

Member Function Documentation

PN potion_closure_code ( Potion P,
PN  cl,
PN  self 
)

"send" method, call a method on self by name

Parameters
self
method
Returns
the result of the method call

Definition at line 42 of file objmodel.c.

PN potion_closure_string ( Potion P,
PN  cl,
PN  self,
PN  maxlen 
)

"string" of a function proto, unserializable. without body.

Parameters
maxlen(ignored)
Returns
rough protoype as string. "function(arg1, arg2)"

Definition at line 52 of file objmodel.c.

PN potion_closure_arity ( Potion P,
PN  cl,
PN  self 
)

"arity" method, optional args do count.

Returns
number of args as PNInteger

closure_new aka PN_FUNC sets arity, always use the cached value

Definition at line 69 of file objmodel.c.

PN potion_closure_minargs ( Potion P,
PN  cl,
PN  self 
)

Number of mandatory arguments, without optional args.

Returns
number of args as PNInteger

closure_new aka PN_FUNC sets arity, always use the cached value

Definition at line 76 of file objmodel.c.

Field Documentation

PNClosure::PN_OBJECT_HEADER

PNType vt; PNUniq uniq.

Definition at line 382 of file potion.h.

PN_F PNClosure::method

Definition at line 383 of file potion.h.

PN PNClosure::sig

signature PNTuple

Definition at line 384 of file potion.h.

int PNClosure::arity

cached number of declared args, including optional

Definition at line 385 of file potion.h.

int PNClosure::minargs

cached number of mandatory args, without optional

Definition at line 386 of file potion.h.

PN_SIZE PNClosure::extra

0 or 1 if has code attached at data

Definition at line 387 of file potion.h.

PN PNClosure::name

Definition at line 388 of file potion.h.

PN PNClosure::data[]

PNString.

code

Definition at line 389 of file potion.h.


The documentation for this struct was generated from the following files: