quot>py-callback ( quot: ( args kw -- ret ) -- alien ) - Factor Documentation

quot>py-callback ( quot: ( args kw -- ret ) -- alien )
Python binding



Vocabulary
python

Inputs
quot a quotation with stack effect ( args kw -- ret )


Outputs
alien an alien


Word description
Creates a python-compatible alien callback from a quotation.

Examples
This is how you create a callback which returns the double of its first positional parameter:
USING: python ;
: double-fun ( -- alien ) [ drop first 2 * ] quot>py-callback ;


Definition
USING: kernel python.ffi ;

IN: python

: quot>py-callback ( quot: ( args kw -- ret ) -- alien )
[ [ nipd [ [ py> ] [ { } ] if* ] bi@ ] ] dip [ >py ] compose
compose PyCallback ; inline

AltStyle によって変換されたページ (->オリジナル) /